lshw and df -h see a different partition size (5.5 TB vs. 200 MiB) for one of the partitions of my computer (Ubuntu 14.04.4 LTS x64). I'm pretty sure df -h is right, as when I created the partition with parted, I configured the partition to be of size 5.5 TB. (here are the instructions I used to create the partition if it matters). Also, I tried to place more than 200 MiB of files in that partition and it worked fine.

How comes lshw doesn't seem the same size as df -h?

Below is the output of the two commands (the partition in question is /dev/sdb1, mounted to /crimea)

username@server:/crimea$ df -h
Filesystem                     Size  Used Avail Use% Mounted on
udev                            63G   12K   63G   1% /dev
tmpfs                           13G  1.7M   13G   1% /run
/dev/dm-2                      923G   54G  823G   7% /
none                           4.0K     0  4.0K   0% /sys/fs/cgroup
none                           5.0M     0  5.0M   0% /run/lock
none                            63G     0   63G   0% /run/shm
none                           100M     0  100M   0% /run/user
/dev/mapper/vg_system-openafs  2.9G   49M  2.7G   2% /var/cache/openafs
AFS                            2.0T     0  2.0T   0% /afs
/dev/sdb1                      5.5T   58M  5.2T   1% /crimea
username@server:/crimea$ sudo lshw -C volume
       description: LVM Physical Volume
       vendor: Linux
       physical id: 1
       bus info: scsi@0:0.0.0,1
       logical name: /dev/sda1
       serial: S3pp6Q-ZaaU-1Y3I-DE05-0cdd-xYZZ-4WvaKP
       size: 953GiB
       capabilities: multi lvm2
       configuration: name=primary
       description: BIOS Boot partition
       vendor: EFI
       physical id: 2
       bus info: scsi@0:0.0.0,2
       logical name: /dev/sda2
       serial: ce1dec5b-2888-49fd-a770-1f159765f7c5
       capacity: 1023KiB
       capabilities: nofs
       configuration: name=primary
       description: EXT4 volume
       vendor: Linux
       physical id: 1
       bus info: scsi@1:0.0.0,1
       logical name: /dev/sdb1
       logical name: /crimea
       version: 1.0
       serial: c3552308-705b-99db-9855-8e456c96a1ce
       size: 200MiB
       capacity: 5589GiB
       capabilities: journaled extended_attributes huge_files dir_nlink extents ext4 ext2 initialized
       configuration: created=2016-06-24 14:56:55 filesystem=ext4 lastmountpoint=/boot modified=2016-07-01 17:15:55 mount.fstype=ext4 mount.options=rw,relatime,data=ordered mounted=2016-07-01 17:07:19 name=primary state=mounted
  • The lshw appears to still be showing the pre-mke2fs settings (eg "lastmountpoint" value). Odd! – Stephen Harris Aug 14 '16 at 1:04
  • df makes system calls, lshw actually reads the disk. If you look at the lshw code you can see that it sets size to whatever the partition gives, and then makes a huge do-while calculating the size and putting it into capacity. Not sure where the call to getCapacity() is taking the info from, though. – grochmal Aug 14 '16 at 1:19
  • @grochmal You're reading the wrong part of the code: this is for extended partitions. For a partition containing an ext4 filesystem, the size is set in detect_ext2. I don't understand how that's coming up to 200MB. – Gilles 'SO- stop being evil' Aug 14 '16 at 22:22
  • @Gilles - good point (ext confusion on my side). But yeah, I cannot see either from where that size can be coming from. I'd like OP to try it again after restartig the machine (maybe, just maybe, it is some cache in the disk firmware?) – grochmal Aug 14 '16 at 23:20
  • @grochmal I will let you know how it goes after the restart, but since it's a server it doesn't happen often. Also, sudo blkid /dev/sdb1 shows a different UUID than sudo lshw -C volume, so it does look like something gets cached somewhere. – Franck Dernoncourt Aug 14 '16 at 23:46

But they do show the same, it's right there in lshw output: capacity: 5589GiB. Now, a better question would be what is the difference between lshw capacity and size

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.