1

I did a fresh install of ubuntu server 12.04 as a KVM virtual guest. I used a kickstart file to automate the installation, I've included the command to create the guest as well as the partitioning section of the kickstart file. These numbers were taken right after a fresh installation the only main service that is running is an ssh server. There is 7GB of disk usage that I can't account for.

Kickstart partitioning section

part /boot --fstype ext4 --size 200 
part / --fstype ext4 --size 1 --grow 

KVM installation command

virt-install -n bigtest -r 4096 
--disk path=/var/lib/libvirt/images/bigtest.img,bus=virtio,size=500 \
-c ubuntu-12.04.1-server-amd64.iso --accelerate 
--network=bridge:br0 --connect=qemu:///system  \
--vnc --noautoconsole -v --os-type linux

disk usage

Running df and du reports different disk usages, which I understand can happen. The difference though of 8G vs 512M is about 7G.

root@ubuntu:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda5       500G  8.0G  467G   2% /
udev            2.0G  4.0K  2.0G   1% /dev
tmpfs           792M  220K  791M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            2.0G     0  2.0G   0% /run/shm
/dev/vda1       188M   34M  146M  19% /boot
root@ubuntu:~# du -hs /
512M    /

Small Guest Test

In the guest called bigtest the virtual disk was 500GB. When I create another guest called smalltest with a virtual disk of size 10GB, the numbers for df and du are 764M and 512M.

KVM host reports

Now if we look at the size of the kvm image files on the host file system we get another interesting story.

root@vbox1:/var/lib/libvirt/images# du -hs *
753M    bigtest.img
744M    smalltest.img

Reserved filesystem blocks

Just to rule out other stuff as much as possible all these numbers were taken after I set the reserved blocks percentage to 0%.

root@ubuntu:~# tune2fs -m 0  /dev/vda5
tune2fs 1.42 (29-Nov-2011)
Setting reserved blocks percentage to 0% (0 blocks)

The Question

What is taking up this 7GB of physical space. If it is used why isn't that being reflected in the host file system disk usage.

UPDATE 1

I discovered something very interesting. If you I run the following commands and reboot the new numbers for df and du are 1.1G and 875M! which are within normal expectations.

apt-get update
apt-get upgrade
apt-get dist-upgrade

Here are a few observations I made about this:

  1. After a fresh install I tried rebooting many times it didn't change the 8GB usage
  2. running apt-get update and upgrade don't reduce the disk usage, even with reboots.
  3. only when the kernel is updated with apt-get dist-upgrade, and even then only after the system has rebooted with the new kernel will the usage drop back to normal levels.

UPDATE 2

I've tested this independently in virtualbox and this same exact behaviour happens. So this issue is related to Ubuntu Server and not anything specifically related to KVM or virtualbox.

UPDATE 3

Some additional commands run on the machine as suggested in an answer below.

root@ubuntu:/# du --apparent-size -sh --exclude=/proc /
963M    /

using ncdu

ncdu 1.8 ~ Use the arrow keys to navigate, press ? for help           
--- / ----------------------------------------------------------------
  230.6MiB [##########] /usr                                          
  202.4MiB [########  ] /lib
  193.0MiB [########  ] /var
   23.7MiB [#         ] /boot
    8.6MiB [          ] /bin
    6.7MiB [          ] /sbin
    4.9MiB [          ] /etc
  220.0KiB [          ] /run
   28.0KiB [          ] /root
   20.0KiB [          ] /opt
e  16.0KiB [          ] /lost+found
    8.0KiB [          ] /media
    4.0KiB [          ] /dev
    4.0KiB [          ] /lib64
e   4.0KiB [          ] /tmp
e   4.0KiB [          ] /srv
e   4.0KiB [          ] /selinux
e   4.0KiB [          ] /mnt
e   4.0KiB [          ] /home
    0.0  B [          ] /proc
    0.0  B [          ] /sys
@   0.0  B [          ]  initrd.img
@   0.0  B [          ]  vmlinuz

 Total disk usage: 670.2MiB  Apparent size: 128.0TiB  Items: 54464    

The Linux kernel versions before and after the dist-upgrade are as follows:

Linux ubuntu 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012
Linux ubuntu 3.2.0-30-generic #48-Ubuntu SMP Fri Aug 24 16:52:48 UTC 2012
Marwan Alsabbagh
  • 391
  • 7
  • 13
  • "I've tested this independently in virtualbox" - was this without any preseed/kickstart and using a regular text-based installation? – gertvdijk Dec 13 '12 at 12:18
  • @gertvdijk using the same kickstart file and also 500GB hard disk. got the same 8GB reported disk usage. – Marwan Alsabbagh Dec 13 '12 at 12:34

1 Answers1

1

Sparse files?

What does du --apparent-size -sh / report?

Try the ncdu utility to drill down the directory tree.

What are the actual kernel versions involved? Maybe it's just a bug. You should bu updating the kernel to the newest release anyway, right?

ewwhite
  • 194,921
  • 91
  • 434
  • 799
  • Thanks for the useful commands. I've updated the question with their output. Once I've upgraded to the latest kernel everything gets resolved. So this won't pose any issues for me on the systems I am setting up. I would however like to understand what has happened though. The two commands you suggested where helpful, but Now I am even more confused. How can the apparent size be 129T on a 500GB disk? – Marwan Alsabbagh Dec 13 '12 at 12:53
  • 1
    @MarwanAlsabbagh You didn't exclude `/proc` and other non-disk filesystems. Add `-x` as a `du` option. – gertvdijk Dec 13 '12 at 13:49
  • @gertvdijk Although, `ncdu` is smart enough to ignore /proc. – ewwhite Dec 13 '12 at 13:57
  • @gertvdijk You are right once I excluded /proc the disk usage appeared correctly. I updated the question with the correct command and output. – Marwan Alsabbagh Dec 18 '12 at 05:41