Oct
26
Published by Kieran in Computer Science
· Leave your thoughts
( words)
( words)
Clean the virtual server
The below process assumes that you’ve already deleted any large files to free up disk space.
- Login to the virtual server via SSH
- Run the following to identify what file systems exist on the server
# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 38G 23G 15G 62% / devtmpfs 908M 0 908M 0% /dev tmpfs 918M 0 918M 0% /dev/shm tmpfs 918M 8.8M 910M 1% /run tmpfs 918M 0 918M 0% /sys/fs/cgroup /dev/sda1 497M 307M 191M 62% /boot /dev/mapper/centos-home 19G 1.8G 17G 10% /home tmpfs 184M 0 184M 0% /run/user/0 tmpfs 184M 0 184M 0% /run/user/1001
- Choose which filesystem you would like to reclaim space from and then run the following to fill ALL free space with zeros. Note: This may take several minutes, so please be patient and wait for it to finish.
# dd if=/dev/zero of=/zeroes dd: writing to ‘/zeroes’: No space left on device 56287833+0 records in 56287832+0 records out 28819369984 bytes (29 GB) copied, 424.182 s, 67.9 MB/s
- Delete the file created by dd
# rm -rf /zeroes
- Note: Repeat the above 2 steps for every file system you would like to reclaim space from… you will need to change the output of dd so that the file is created on the appropriate file system.
- Shutdown the virtual server
# shutdown -h now
Punch zeroes
- Login to the ESXi server via SSH
- Browse to the directory where your .vmdk files are held
- Check the current disk usage of the .vmdk files
# du -ah 8.0K ./myserver.vmx 0 ./myserver.vmxf 0 ./myserver.vmsd 41.0G ./myserver-flat.vmdk 0 ./myserver.vmdk 1.0M ./myserver.nvram 0 ./myserver-aux.xml 1.0M ./vmware.log
- Punch zeroes
# vmkfstools -K myserver.vmdk vmfsDisk: 1, rdmDisk: 0, blockSize: 1048576 Hole Punching: 100% done.
- Check the disk usage again and you should see that it has reduced. In this example it was reduced from 41.0G to 17.6G – a good result!
# du -ah 8.0K ./myserver.vmx 0 ./myserver.vmxf 0 ./myserver.vmsd 17.6G ./myserver-flat.vmdk 0 ./myserver.vmdk 1.0M ./myserver.nvram 0 ./myserver-aux.xml 1.0M ./vmware.log 8.0K ./myserver.vmx