大网数据广告活动
服务器运维问答

Why there is a difference in size reported by lsblk, gdisk and parted

· 52CE 我爱测

[anaconda root@861767 ~]# lsblk /dev/sda NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 465.8G 0 disk ├─sda1 8:1 0 512M 0 part └─sda2 8:2 0 465.3G 0 part ├─sys-root 253:2 0 10G 0 lvm ├─sys-var 253:3 0 4G 0 lvm ├─sys-tmp 253:4 …

问题原文

原帖链接 · zer0c00l · CC BY-SA 3.0

[anaconda root@861767 ~]# lsblk /dev/sda
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda            8:0    0 465.8G  0 disk 
├─sda1         8:1    0   512M  0 part 
└─sda2         8:2    0 465.3G  0 part 
  ├─sys-root 253:2    0    10G  0 lvm  
  ├─sys-var  253:3    0     4G  0 lvm  
  ├─sys-tmp  253:4    0     4G  0 lvm  
  └─sys-home 253:5    0 447.3G  0 lvm  
[anaconda root@861767 ~]# gdisk -l /dev/sda
GPT fdisk (gdisk) version 0.8.6

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 2029 sectors (1014.5 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1050623   512.0 MiB   0700  
   2         1050624       976773119   465.3 GiB   8E00  
[anaconda root@861767 ~]# parted -s /dev/sda unit GB print
Model: ATA GB0500EAFYL (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      0.00GB  0.54GB  0.54GB  ext4
 2      0.54GB  500GB   500GB                      lvm

[anaconda root@861767 ~]# 

lsblk and gdisk reports the disk size is 465.5G parted says the size is 500G

Which one is real? And why there is inconsistency?

已采纳解答

原帖链接 · Craig Estey · CC BY-SA 3.0

Disk manufacturers advertise disk sizes in multiples of 1000. That is, a "KB" is 1000 and not 1024 as software people are used to.

For you, it seems that lsblk and gdisk are using the 1024 value but parted is using 1000.

465.5 * 1024 * 1024 * 1024 == 499,826,819,072

Now, divide:

499,826,819,072 / (1000 * 1000 * 1000) == 499.826

which maps to the 500 that parted is reporting

Notice that lsblk and gdisk use GiB but you gave the GB option to parted. Try parted with the GiB option

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-04-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。