3

For some reason, the output format for df changed after a recent kernel update in Ubuntu 14.04.

When I run df -hl to show all mounted filesystems, the output looks like this:

bwvdnbro@wixie:~/Projects$ df -hl
Filesystem      Size  Used Avail Use% Mounted on
udev             12G  4.0K   12G   1% /dev
tmpfs           2.4G  1.3M  2.4G   1% /run
/dev/sda1       1.8T  1.3T  395G  78% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none             12G  168K   12G   1% /run/shm
none            100M   44K  100M   1% /run/user
/dev/md0p1      3.6T  1.4T  2.1T  40% /media/bwvdnbro/raid

However, when I only want to show one specific device, e.g. /, the output changes to

bwvdnbro@wixie:~/Projects$ df -hl /
Filesystem                                              Size  Used Avail Use% Mounted on
/dev/disk/by-uuid/90cd5449-2cbf-4f32-89fe-d66e9fb5f8ee  1.8T  1.3T  395G  78% /

This is annoying, since it makes the first line too long to fit in a standard terminal window.

Is there any way to control the output format for Filesystem and make it also show /dev/sda1 instead of the full UUID when using df for a single device?

EDIT

So I did some more research on different nodes running different kernel versions, and it turns out the problem is not with df, but rather with /proc/self/mountinfo, the file that df reads. For old kernel versions, this file contains the device name, while the newer versions list the UUID instead.

So the question is: how does the full df -hl command convert the UUID to the device name, and is there a way to reproduce this behaviour when running df -hl /?

2
  • Could there be an alias or something similar? Check what the output of type -a df says, please.
    – Byte Commander
    Mar 15, 2016 at 10:25
  • df is /bin/df Mar 15, 2016 at 13:14

2 Answers 2

1

I ran into the problem with it outputting UUID because amazon's aws ec2 cloudwatch script mon-put-instance-data.pl uses it as its Filesystem dimension and my alarms all of a sudden had insufficient data after apt-get upgrade:

This is really an initramfs-tools bug. Rebooting after initramfs-tools - 0.103ubuntu4.3 fixed the issue everywhere for me even on coreutils_8.21-1ubuntu5.4

https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/1432871/comments/33

0

I have the same problem when I use df on Ubuntu 14.04.

Waiting for the next updates will solve the problem, in the meantime I made this script to get the information correctly.

#!/bin/bash

DF="`df $1 $2 $3 $4 $5 $6 $7`"
UUID="`echo "$DF" | awk 'NR==2{print $1}'`"

if [ `echo "$UUID" | grep "/dev/disk/by-uuid/"` ]; then
    DEV="`readlink -m $UUID`"
    DF="`echo "$DF" | sed s,$(echo "$UUID"),$(echo "$DEV"), | \
        awk '
            NR==1{printf("%13s\t %10s\t %10s\t %7s %7s %7s %7s\n", ($1" "$2),$3 ,$4 ,$5 , $6, ($7" "$8), $9)}
            NR==2{printf("%13s\t %10s\t %10s\t %7s %7s %7s %7s", $1 , $2 , $3 , $4 , $5 , $6 , $7 , $8)}
        '`"
    echo "$DF"
else
    echo "$DF"
fi

I've reported this as a df-coreutils bug on Launchpad

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .