0

When comparing the disk usage for a mounted harddrive the usage is completely different when compared between the host and the container. I am running Ubuntu 14.04 on the host and in the lxc container.

The hard drive is mounted on the host as confirmed by /etc/mtab which has the following entry: /dev/nvme0n1 /mnt/SSD ext4 rw 0 0. The drive however is not mounted using /etc/fstab. The drive is mounted inside the lxc container using fstab settings in: /var/lib/lxc/container_name/fstab.

From the host:

# du -hs /mnt/SSD/
20K     /mnt/SSD/

# df -h
Filesystem                 Size  Used Avail Use% Mounted on
udev                        63G  4.0K   63G   1% /dev
tmpfs                       13G  1.4M   13G   1% /run
/dev/mapper/sifr--vg-root  314G  241G   58G  81% /
none                       4.0K     0  4.0K   0% /sys/fs/cgroup
none                       5.0M     0  5.0M   0% /run/lock
none                        63G     0   63G   0% /run/shm
none                       100M     0  100M   0% /run/user
/dev/sda1                  236M  100M  124M  45% /boot
/dev/nvme0n1               1.1T   71M  1.1T   1% /mnt/SSD

From the container

$ du -hs /mnt/SSD/
16G /mnt/SSD/

$ df -h
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/sifr--vg-root  314G  241G   58G  81% /
none                       4.0K     0  4.0K   0% /sys/fs/cgroup
none                        13G  136K   13G   1% /run
none                       5.0M     0  5.0M   0% /run/lock
none                        63G  4.0K   63G   1% /run/shm
none                       100M     0  100M   0% /run/user
  1. How and why does the same drive shows two different usages?
  2. Which is the correct usage?

Update: After unmounting the drive using sudo umount /dev/nvme0n1, I now see 16GB disk usage in the host and the container:

$ du -hs /mnt/SSD/
16G     /mnt/SSD/

I mounted another drive /dev/sdb using /etc/fstab and gave the container access to it using the same method: /var/lib/lxc/container_name/fstab. The second drive's usage is also consistent and the contents are available in both the container and the host.

The differences between the two drives are that /dev/nvme0n1 is a nvme drive which was mounted manually, whereas /dev/sdb is a magnetic drive and was mounted using /etc/fstab.

What could be causing the difference in the behaviour and how to make /dev/nvme0n1 available in the container?

  • /mnt/SSD which container sees don't have to be /mnt/SSD that host sees, because of mount namespaces isolation. That's how privateTmp on systemd works. Check mounts for particular cgroup-ed process . – Boban P. Mar 20 '16 at 14:55
  • @BobanP. Thanks for responding. How can I check mounts for cgroup-ed processes? I've updated the post: once the drive was unmounted the disk usage was consistent in both the container and how. It looks like the container was not using the drive. I mounted another drive using /etc/fstab and it works fine. Not sure if mouting it manually vs through fstab could cause this behaviour? – Greg Mar 21 '16 at 0:09
  • try systemd-cgls, and then when you find PID of process i cgroup, cat /proc/[PID]/mountinfo – Boban P. Mar 21 '16 at 6:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.