[gentoo-user] Re: Weird "df" output

2015-11-25 Thread Jonathan Callen
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

On 11/25/2015 05:10 PM, waltd...@waltdnes.org wrote:
>   I'll admit that my system setup is a bit unusual.  A long time ago, in
> a place far away, hard drives were small, compared to today's standards.
> The usual unix practice of multiple seprate partitions was not feasable
> for me, but I did want to keep root on its own partition.  So I
> compromised with a small / partition, with empty /home, /opt, /var,
> /usr, and /tmp directories.  Their real equivalents are bind-mounted
> from a much larger partition.  I just re-did my oldest machine.  It has
> a primary partition 1, which covers the entire hard drive.  The /
> partion on /dev/sda5 is approximately 500 megabytes (YES!).  There's a
> 3.8 gigabyte swap partion /dev/sda6, and the rest of the drive is
> /dev/sda7.  Here's the relevant portion of /etc/fstab...
>
> /dev/sda5   /   ext2 noatime,async  0 1
> /dev/sda7   /home   ext3 noatime,async  0 1
> /home/bindmounts/opt/optauto bind   0 0
> /home/bindmounts/var/varauto bind   0 0
> /home/bindmounts/usr/usrauto bind   0 0
> /home/bindmounts/tmp/tmpauto bind   0 0
> /dev/sda6   noneswap sw 0 0
>
> ...and the output from "df"...
>
> Filesystem 1K-blocks  Used Available Use% Mounted on
> /dev/root 495944 49416420928  11% /
> devtmpfs   10240 0 10240   0% /dev
> tmpfs 310080   356309724   1% /run
> shm  1550384 0   1550384   0% /dev/shm
> cgroup_root10240 0 10240   0% /sys/fs/cgroup
> /dev/sda7  476205120 292365556 159643008  65% /opt
>
> ...showing /dev/sda7 mounted on /opt !?!?  mc (Midnight Commander) shows
> 152 of 454 gigabytes free on all of /home, /opt, /var, /usr, and /tmp,
> which is correct, since they're all really bindmounts from /dev/sda7.
> The / partition (/dev/sda5) has 411 of 484 megabytes free.  The machine
> works OK, but the "df" output is a head-scratcher.  I've re-booted a
> couple of times, with no change.
>

df reads /proc/self/mountinfo to get the list of mount points. This file
will probably look something like this for your system (exact numbers,
order, and contents may vary):

1 0 4:0 / / rw,noatime,async - ext2 /dev/root rw
2 1 0:1 / /sys rw,nosuid,nodev,noexec,relatime - sysfs sysfs rw
3 1 0:2 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
4 1 0:3 / /dev rw,nosuid - devtmpfs devtmpfs rw,size=10240k,mode=755
5 1 0:4 / /run rw,nosuid,nodev - tmpfs tmpfs rw,size=310080k,mode=755
5 4 0:5 / /dev/shm rw,nosuid,nodev - shm tmpfs rw
6 4 0:6 / /dev/pts rw,nosuid,noexec,relatime - devpts devpts 
rw,gid=5,mode=620,ptmxmode=000
7 2 0:7 / /sys/fs/cgroup rw,nosuid,nodev,noexec - tmpfs cgroup_root 
rw,size=1024k,mode=755
8 1 8:7 / /home rw,noatime,async - ext3 /dev/sda7 rw,data=ordered
9 1 8:7 /bindmounts/opt /opt rw,noatime,async - ext3 /dev/sda7 rw,data=ordered
10 1 8:7 /bindmounts/var /var rw,noatime,async - ext3 /dev/sda7 rw,data=ordered
11 1 8:7 /bindmounts/usr /usr rw,noatime,async - ext3 /dev/sda7 rw,data=ordered
12 1 8:7 /bindmounts/tmp /tmp rw,noatime,async - ext3 /dev/sda7 rw,data=ordered

Note that all the bind mounts show up with the exact same device name as
the original mount they were bound off of. In the interest of not
showing duplicate information, df will only show the mountpoint that has
the shortest path, using the first of those that have the same length
path. As "/opt" is shorter than "/home", that is the mountpoint df uses
as its display name.

The fields in the file are as follows:

1: mount number
2: parent mount number
3: device major:minor mounted (0:x for filesystems not backed by a
block device)
4: path within filesystem mounted
5: mountpoint
6: per-mount options (may differ with multiple mounts of same
filesystem)
(any number of optional per-mount flags may follow, terminated with...)
7: the exact string "-"
8: filesystem type
9: filesystem device name (or string passed to mount(2) for virtual
filesystems)
10: per-device options (always the same for multiple mounts of same
device)
(any number of optional per-device flags may follow)

Note that on Linux, df now prefers to use /proc/self/mountinfo
*instead* of the old /etc/mtab file that (usually) gets written when
mount is called.

- -- 
Jonathan Callen
-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iQIcBAEBCgAGBQJWVk7iAAoJEEIQbvYRB3mg0pkP/2q3QsRDFFNZShv/tH5W6zkO
tDk9GX/fMa6R+DyY151ZHiMNOqb/DZRupFudOHJOAIP8oUHAJxOdDg8NXrLFsbcs
8iNEKfLLQq2VrTPpdOoFZcNu2I8vVhc9F08IFTo2wqS8CXPzu7qBH/e5cpDsq43S
W0QKxEptgaGoYSdy3PLRoXcz8kUHYC/tbnJo33tZFu9iRss2WF1EAw3jOtZh0SNO
IoZmowzVNml9WQr7SKVGx/8lrOqzUfahb+vBRnpGi+B+VSLrhbAnkWLtxz7Kv5ws
OyuCuN2DCkyDKFjF/KxP/vp4Uyx6xkqX2KEfG0FcctMD17eHMJFscXb6RMNKQhUu
LNgqfn3Tkk555GC2lP9ZWlT08BqijQ8Tg7d36iCcwJcb5qQpCsszH2j1uHq+4pzi

Re: [gentoo-user] Re: Weird "df" output

2015-11-25 Thread waltdnes
On Wed, Nov 25, 2015 at 07:15:44PM -0500, Jonathan Callen wrote

> Note that all the bind mounts show up with the exact same device name as
> the original mount they were bound off of. In the interest of not
> showing duplicate information, df will only show the mountpoint that has
> the shortest path, using the first of those that have the same length
> path. As "/opt" is shorter than "/home", that is the mountpoint df uses
> as its display name.

  Thanks for the info.  I'm not that knowledgable to be able to figure
out that it was a df "feature", rather than a problem with my system.

-- 
Walter Dnes 
I don't run "desktop environments"; I run useful applications