GNU bug report logs - #34143
[coreutils 8.28] du -x is reporting a lower disk usage for /mnt when partitions are mounted

Previous Next

Package: coreutils;

Reported by: "Joseph Paul" <joseph.paul1 <at> gmx.com>

Date: Sun, 20 Jan 2019 09:16:01 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 34143 in the body.
You can then email your comments to 34143 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#34143; Package coreutils. (Sun, 20 Jan 2019 09:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Joseph Paul" <joseph.paul1 <at> gmx.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sun, 20 Jan 2019 09:16:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Joseph Paul" <joseph.paul1 <at> gmx.com>
To: bug-coreutils <at> gnu.org
Subject: [coreutils 8.28]  du -x is reporting a lower disk usage for /mnt
 when partitions are mounted
Date: Sat, 19 Jan 2019 23:11:24 +0100
[Message part 1 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#34143; Package coreutils. (Sun, 20 Jan 2019 10:31:02 GMT) Full text and rfc822 format available.

Message #8 received at 34143 <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Joseph Paul <joseph.paul1 <at> gmx.com>, 34143 <at> debbugs.gnu.org
Subject: Re: bug#34143: [coreutils 8.28] du -x is reporting a lower disk usage
 for /mnt when partitions are mounted
Date: Sun, 20 Jan 2019 03:30:14 -0700
tags 34143 notabug
close 34143
stop

Hello,

On 2019-01-19 3:11 p.m., Joseph Paul wrote:
>     It may not be a bug at all, but I was surprised to find out that 'du
>     -x' is reporting a lower disk usage on /mnt when partitions are
>     mounted.

This is not a bug.

Technically, as you wrote below, du simply skips (and does not count)
any directory that is not on the same filesystem.

[...]
>     linux$ du -x /mnt
>     4    /mnt/data
>     4    /mnt/VL1800
>     4    /mnt/nfs/nas
>     8    /mnt/nfs
>     20    /mnt
> 
>     /mnt is now bigger.
> 
>     Is this a normal result, because even when mounted, physically, the
>     directories '/mnt/VL1800' and '/mnt/data' still  exist on the '/'
>     filesystem, or not ?
>     Shouldn't they still occupy 4Kb of disk space each on the '/'
>     filesystem when partitions are mounted ?

They do occupy as much disk space as before,
but du has no way to know how much they occupy,
because the kernel reports that they are on a different device
and you requested -x/--one-file-system.

We can even take it a step further, and mount a new filesyetem
on a non-empty directory - all the directory's content won't be counted:

As root, create the directory structure:

    cd /tmp
    mkdir -p a a/b a/c a/d

Now fill the "b" directory with a large file:

    dd if=/dev/zero of=a/b/bigfile bs=1M count=1

Before any mounts, "b" is counted:

    # du -x a
    4     a/c
    1028  a/b
    4     a/d
    1040  a

Now create a temporary file system loop file, and mount it over "b":

    dd if=/dev/zero of=disk.img bs=1M count=10
    mkfs.ext3 disk.img
    mount -o loop disk.img a/b

Re-checking disk-usage, "b" is not even listed,
and its content (1MB) is not counted:

   # du -x a
   4   a/c
   4   a/d
   12  a

---

To see why du skips it, you can check the Device-ID associated with each 
directory:

   # stat -c "%n   Device-ID: %D   Mount-Point: %m" a a/b a/c a/d
   a   Device-ID: 812   Mount-Point: /tmp
   a/b   Device-ID: 700   Mount-Point: /tmp/a/b
   a/c   Device-ID: 812   Mount-Point: /tmp
   a/d   Device-ID: 812   Mount-Point: /tmp

Your device numbers will differ, but the number for "a/b" will not be
the same as for the rest.

When du sees a different device number, it simply skips the directory.

Once unmounted, the device-id returns to the old value,
and "a/b" will be counted with its content:

   # umount a/b
   # stat -c "%n   Device-ID: %D   Mount-Point: %m" a a/b a/c a/d
   a   Device-ID: 812   Mount-Point: /tmp
   a/b   Device-ID: 812   Mount-Point: /tmp
   a/c   Device-ID: 812   Mount-Point: /tmp
   a/d   Device-ID: 812   Mount-Point: /tmp


As such, I'm closing this as "not a bug",
but discussion can continue by replying to this thread.


regards,
 - assaf





Added tag(s) notabug. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 20 Jan 2019 10:31:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 34143 <at> debbugs.gnu.org and "Joseph Paul" <joseph.paul1 <at> gmx.com> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 20 Jan 2019 10:31:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 17 Feb 2019 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 63 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.