Linuxでパーティションサイズを確認するには? [コピー]

Linuxでパーティションサイズを確認するには? [コピー]

次のように2Gパーティションを作成しましたfdisk

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 
First sector (4196352-16777215, default 4196352): 
Using default value 4196352
Last sector, +sectors or +size{K,M,G} (4196352-16777215, default 16777215): +2G
Partition 2 of type Linux and of size 2 GiB is set

Command (m for help): w
The partition table has been altered!

しかし、寸法を確認すると(fdisk再び

fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/sdb: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xe82746a5

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     4196351     2097152   83  Linux
/dev/sdb2         4196352     8390655     2097152   83  Linux


blockdev --getbsz /dev/sdb2
4096

その後、もう一度確認してください。

echo "2097152*4096/1024/1024/1024" | bc
8

(ブロック*バイト/ 1024 ^ 3はGBを提供する必要がありますか?)これは8 GBのパーティションを意味します。

私はどのように計算を間違っていた可能性がありますか?

ベストアンサー1

「ブロック」列を無視します。終了セクタは 8390655 で、開始セクタは 4196352 です。したがって、このパーティションにまたがるセクタの数は8390655 - 4196351(最初のセクタを含むため)、つまり4,194,304です。各セクタは512バイトなので、2つのセクタは1KB、つまり4,194,304/2 = 2,097,152KBです。 1024**2で割ってギガバイトを求めると2GBパーティションになります。

おすすめ記事