0

I am a bit confused about the /dev/sda* references since I installed Wheezy instead of Squeeze on a testing box.

fdisk -l returns:

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 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 identifier: 0x000e9623

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   480278527   240138240   83  Linux
/dev/sda2       480280574   488396799     4058113    5  Extended
/dev/sda5       480280576   488396799     4058112   82  Linux swap / Solaris

This seems correct. But df -h /dev/sda (and /dev/sda1 and /dev/sda2 and /dev/sda5) returns:

Filesystem      Size  Used Avail Use% Mounted on
udev             10M     0   10M   0% /dev

The same happens with every entry under /dev/disk/by-id and /dev/disk/by-path. Only one of two entries under /dev/disk/by-uuid returns the correct volume size:

df -h /dev/disk/by-uuid/cacdbad6-7e6b-4e80-84ba-e3c77ef48796
Filesystem                                              Size  Used Avail Use% Mounted on
/dev/disk/by-uuid/cacdbad6-7e6b-4e80-84ba-e3c77ef48796  229G   22G  196G  11% /

Contents of /etc/fstab:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=cacdbad6-7e6b-4e80-84ba-e3c77ef48796 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=45840d13-ee36-4e77-8e73-16cbdff25eb1 none            swap    sw              0       0
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto  0       0

It seems all other references than the uuid points to the swap partition. Is this because Wheezy is in testing, and should it be reported as an error?

aef
  • 1,745
  • 4
  • 25
  • 43

3 Answers3

0

Not sure how df should know this if you just give it the device name. In case of sda2 there is no free space, as its an extended parition and in case of sda5 neither as it's swap and should be looked up via free.

What definetly works is df -h / or df -h /somemountpoint.

And after a short try-out on my machine you can pass df any device-name that is listed in mount output. No other (alias) name for the same device/partition will work. I would say it is maybe a missing feature, but not a real bug.

zhenech
  • 1,492
  • 9
  • 13
0

df give infos abount mounted partitions only. From man df:

If an argument is the absolute file name of a disk device node containing a mounted file system, df shows the space available on that file system rather than on the file system containing the device node (which is always the root file system).

df could not by used to ask for devices.

Usualy basic un*x tools working around mounted partition look at /etc/mtab for finding mounted partitions. Now there is ways for making a permanent symlink from /proc/mounts to /etc/mtab.

0

Thank you, it has helped me, I had the same problem but in Nagios. After reading this topic I changed in nrpe.cfg on the client side

command[check_rootpart]=/usr/local/nagios/libexec/check_disk -p /dev/sda1

to

command[check_rootpart]=/usr/local/nagios/libexec/check_disk -p /

and Nagios has started to show free space properly. Looks like it uses similar mechanisms to determine free space.

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47