Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I know about df, of course, but df does not output volume labels. I have 5 USB hard drives plugged into my NAS box, and would love to know which is which.

Current df output:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              27G  2.2G   24G   9% /
none                   56M  476K   55M   1% /dev
none                   60M     0   60M   0% /dev/shm
none                   60M  332K   59M   1% /var/run
none                   60M     0   60M   0% /var/lock
none                   60M     0   60M   0% /lib/init/rw
/dev/sde1             150G  102G   48G  68% /media/usb0
/dev/sdb1             299G  196G  103G  66% /media/usb1
/dev/sdc1             233G  183G   51G  79% /media/usb2
/dev/sdd1             233G  209G   25G  90% /media/usb3
/dev/sdf1             150G  101G   49G  68% /media/usb4
share|improve this question
    
Have you looked into using fdisk -l ? –  PenguinCoder May 31 '12 at 20:44
    
Strangely, fdisk -l isn't showing me any volume labels. It is giving me lots of nice info about partitions, though... –  DavidH May 31 '12 at 23:05
add comment

2 Answers

up vote 1 down vote accepted

Sure. Here's a shell one-liner that wraps df with the information from blkid:

df | while read line; do dev=${line%% *}; \
  blkid -s LABEL $dev | sed 's/.*LABEL=//; s/"//g'; \
  echo "$line"; done

That will print the label before each line from df, when there is a label. You can play around with it to suit the formatting to taste.

share|improve this answer
    
Thanks! That's perfect. –  DavidH Jun 3 '12 at 20:05
add comment

You can use df to find out the disk space information and use blkid -o list to obtain information about the disk labels and UUIDs.

# blkid -o list
device     fs_type label    mount point    UUID
-------------------------------------------------------------------------------
/dev/sda1  ext4             /              2ea411b8-f6eb-456b-9ac8-efc1f264bee4
/dev/sda5  swap             <swap>         e5732469-d123-4f24-948b-ab356576c140

You have to be root to see the label and UUID values.

share|improve this answer
    
Funny... blkid isn't reading my filesystem's label although I can see it with e2label. –  devius May 31 '12 at 22:55
    
Thanks. There isn't any way to get both volume labels and disk space usage back from the same utility, is there? It's easy enough to cross-reference between the two when I'm running them manually, but I'm trying to write a nightly script that will send me a disk space report for each drive (and include volume labels). –  DavidH May 31 '12 at 23:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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