![Linux에서 파티션 크기를 확인하는 방법은 무엇입니까? [복사]](https://linux55.com/image/105356/Linux%EC%97%90%EC%84%9C%20%ED%8C%8C%ED%8B%B0%EC%85%98%20%ED%81%AC%EA%B8%B0%EB%A5%BC%20%ED%99%95%EC%9D%B8%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F%20%5B%EB%B3%B5%EC%82%AC%5D.png)
다음과 같이 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를 제공해야 합니다. 그렇죠?) 이는 8GB 파티션을 의미합니다.
내가 어떻게 계산을 잘못했을 수 있었을까?
답변1
"차단" 열을 무시하십시오. 끝 섹터는 8390655이고 시작 섹터는 4196352입니다. 따라서 이 파티션에 걸쳐 있는 섹터 수는 8390655 - 4196351(첫 번째 섹터가 포함되어 있으므로), 즉 4,194,304입니다. 각 섹터는 512바이트이므로 두 섹터는 1KB, 즉 4,194,304/2 = 2,097,152KB입니다. 1024**2로 나누어 기가바이트를 구하면 2GB 파티션이 됩니다.