Gentoo Archives: gentoo-user

From: Jonathan Callen <jcallen@g.o>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Re: Weird "df" output
Date: Thu, 26 Nov 2015 00:16:02
Message-Id: 56564F30.70901@gentoo.org
In Reply to: [gentoo-user] Weird "df" output by waltdnes@waltdnes.org
1 -----BEGIN PGP SIGNED MESSAGE-----
2 Hash: SHA512
3
4 On 11/25/2015 05:10 PM, waltdnes@××××××××.org wrote:
5 > I'll admit that my system setup is a bit unusual. A long time ago, in
6 > a place far away, hard drives were small, compared to today's standards.
7 > The usual unix practice of multiple seprate partitions was not feasable
8 > for me, but I did want to keep root on its own partition. So I
9 > compromised with a small / partition, with empty /home, /opt, /var,
10 > /usr, and /tmp directories. Their real equivalents are bind-mounted
11 > from a much larger partition. I just re-did my oldest machine. It has
12 > a primary partition 1, which covers the entire hard drive. The /
13 > partion on /dev/sda5 is approximately 500 megabytes (YES!). There's a
14 > 3.8 gigabyte swap partion /dev/sda6, and the rest of the drive is
15 > /dev/sda7. Here's the relevant portion of /etc/fstab...
16 >
17 > /dev/sda5 / ext2 noatime,async 0 1
18 > /dev/sda7 /home ext3 noatime,async 0 1
19 > /home/bindmounts/opt /opt auto bind 0 0
20 > /home/bindmounts/var /var auto bind 0 0
21 > /home/bindmounts/usr /usr auto bind 0 0
22 > /home/bindmounts/tmp /tmp auto bind 0 0
23 > /dev/sda6 none swap sw 0 0
24 >
25 > ...and the output from "df"...
26 >
27 > Filesystem 1K-blocks Used Available Use% Mounted on
28 > /dev/root 495944 49416 420928 11% /
29 > devtmpfs 10240 0 10240 0% /dev
30 > tmpfs 310080 356 309724 1% /run
31 > shm 1550384 0 1550384 0% /dev/shm
32 > cgroup_root 10240 0 10240 0% /sys/fs/cgroup
33 > /dev/sda7 476205120 292365556 159643008 65% /opt
34 >
35 > ...showing /dev/sda7 mounted on /opt !?!? mc (Midnight Commander) shows
36 > 152 of 454 gigabytes free on all of /home, /opt, /var, /usr, and /tmp,
37 > which is correct, since they're all really bindmounts from /dev/sda7.
38 > The / partition (/dev/sda5) has 411 of 484 megabytes free. The machine
39 > works OK, but the "df" output is a head-scratcher. I've re-booted a
40 > couple of times, with no change.
41 >
42
43 df reads /proc/self/mountinfo to get the list of mount points. This file
44 will probably look something like this for your system (exact numbers,
45 order, and contents may vary):
46
47 1 0 4:0 / / rw,noatime,async - ext2 /dev/root rw
48 2 1 0:1 / /sys rw,nosuid,nodev,noexec,relatime - sysfs sysfs rw
49 3 1 0:2 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
50 4 1 0:3 / /dev rw,nosuid - devtmpfs devtmpfs rw,size=10240k,mode=755
51 5 1 0:4 / /run rw,nosuid,nodev - tmpfs tmpfs rw,size=310080k,mode=755
52 5 4 0:5 / /dev/shm rw,nosuid,nodev - shm tmpfs rw
53 6 4 0:6 / /dev/pts rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
54 7 2 0:7 / /sys/fs/cgroup rw,nosuid,nodev,noexec - tmpfs cgroup_root rw,size=1024k,mode=755
55 8 1 8:7 / /home rw,noatime,async - ext3 /dev/sda7 rw,data=ordered
56 9 1 8:7 /bindmounts/opt /opt rw,noatime,async - ext3 /dev/sda7 rw,data=ordered
57 10 1 8:7 /bindmounts/var /var rw,noatime,async - ext3 /dev/sda7 rw,data=ordered
58 11 1 8:7 /bindmounts/usr /usr rw,noatime,async - ext3 /dev/sda7 rw,data=ordered
59 12 1 8:7 /bindmounts/tmp /tmp rw,noatime,async - ext3 /dev/sda7 rw,data=ordered
60
61 Note that all the bind mounts show up with the exact same device name as
62 the original mount they were bound off of. In the interest of not
63 showing duplicate information, df will only show the mountpoint that has
64 the shortest path, using the first of those that have the same length
65 path. As "/opt" is shorter than "/home", that is the mountpoint df uses
66 as its display name.
67
68 The fields in the file are as follows:
69
70 1: mount number
71 2: parent mount number
72 3: device major:minor mounted (0:x for filesystems not backed by a
73 block device)
74 4: path within filesystem mounted
75 5: mountpoint
76 6: per-mount options (may differ with multiple mounts of same
77 filesystem)
78 (any number of optional per-mount flags may follow, terminated with...)
79 7: the exact string "-"
80 8: filesystem type
81 9: filesystem device name (or string passed to mount(2) for virtual
82 filesystems)
83 10: per-device options (always the same for multiple mounts of same
84 device)
85 (any number of optional per-device flags may follow)
86
87 Note that on Linux, df now prefers to use /proc/self/mountinfo
88 *instead* of the old /etc/mtab file that (usually) gets written when
89 mount is called.
90
91 - --
92 Jonathan Callen
93 -----BEGIN PGP SIGNATURE-----
94 Version: GnuPG v2
95
96 iQIcBAEBCgAGBQJWVk7iAAoJEEIQbvYRB3mg0pkP/2q3QsRDFFNZShv/tH5W6zkO
97 tDk9GX/fMa6R+DyY151ZHiMNOqb/DZRupFudOHJOAIP8oUHAJxOdDg8NXrLFsbcs
98 8iNEKfLLQq2VrTPpdOoFZcNu2I8vVhc9F08IFTo2wqS8CXPzu7qBH/e5cpDsq43S
99 W0QKxEptgaGoYSdy3PLRoXcz8kUHYC/tbnJo33tZFu9iRss2WF1EAw3jOtZh0SNO
100 IoZmowzVNml9WQr7SKVGx/8lrOqzUfahb+vBRnpGi+B+VSLrhbAnkWLtxz7Kv5ws
101 OyuCuN2DCkyDKFjF/KxP/vp4Uyx6xkqX2KEfG0FcctMD17eHMJFscXb6RMNKQhUu
102 LNgqfn3Tkk555GC2lP9ZWlT08BqijQ8Tg7d36iCcwJcb5qQpCsszH2j1uHq+4pzi
103 pVxlshP06puswtOv6paHrTZYecavpSqLXd1VJL4p/iOwW/bgr9a70OAwVA2dQYH2
104 nxU84l/K76IEtj6SRz7L4rqY2B9a6uVEznDOKnPuUQ7zWg0NN8m+EYtIFLorBGE7
105 rDaebAeyFZurq0OvHLt3YQ6FtJMlS6zJviBCqVedgYHII2kdi0Sa54kwA2R0v2Cz
106 XiM9EojdYGRmmbOVFFDl41lyQC9MODzSQS+GnkwTLn11rwF6WVgmXtl+U8u3Le6c
107 Ogp2XYHBEOxiAhF21N9I
108 =MJKk
109 -----END PGP SIGNATURE-----

Replies

Subject Author
Re: [gentoo-user] Re: Weird "df" output waltdnes@××××××××.org