XenServer
Increasing free disk space in Ubuntu VM
Source: vmotionhost.com
Increase disk size under Storage section in XenCenter.
Boot up the VM & log into it.
Verify Disk Space:
df -h
Check the partition layout
sudo fdisk -l /dev/xvda
To create new partitions, all old partiotions have to be deleted. To be able to delete the swap partitions the swap has to be turned off.
Verify Swap usage:
free -m
Turn off Swap disk
sudo swapoff -a
Now delete all partitions
sudo fdisk /dev/xvda
Command (m for help): d Partition number (1-5): 1 Command (m for help): d Partition number (1-5): 2
Now Create new partition and the Swap partition:
Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-31457279, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-31457279, default 31457279): 30410751 Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p Partition number (1-4, default 2): Using default value 2 First sector (30410752-31457279, default 30410752): Using default value 30410752 Last sector, +sectors or +size{K,M,G} (30410752-31457279, default 31457279): Using default value 31457279
The primary partition is now correct but the swap partition is not.
The type of the partition should not be “83” but “82” (marking it as a partition for the Linux swap)
Command (m for help): p Device Boot Start End Blocks Id System /dev/xvda1 2048 30410751 15204352 83 Linux /dev/xvda2 30410752 31457279 523264 83 Linux Command (m for help): t Partition number (1-4): 2 Hex code (type L to list codes): 82 Changed system type of partition 2 to 82 (Linux swap / Solaris) Command (m for help): w The partition table has been altered!
Now reboot the VM:
shutdown -r now
The swap partition will be mounted using an UUID identifier. After creating a new partition for swap the UUID will not match and upon reboot, no swap will be available.
Note the UUID of Swap Partition
awk '/swap/ { print $1 }' /etc/fstab UUID=8bb62351-4436-47df-92fe-af2865f03461
Turn off the Swap
sudo swapoff -a
Confirm if the SWAp disk size is zero now:
free -m
To make sure that there is no data (usable by the kernel) at the beginning of the partition use DD (Carefully)
root@ubuntu:~# dd if=/dev/zero of=/dev/xvda2 dd: writing to `/dev/xvda2': No space left on device
Now change the UUID of the Swap disk to match the fstab:
mkswap -U 8bb62351-4436-47df-92fe-af2865f03461 /dev/xvda2
Turn on the Swap again
swapon -a
Confirm if swap size is non zero now
free -m
Now resize the filesystem
resize2fs /dev/xvda1
Now confirm if the changes have taken effect:
df -h
- References
{{#widget:DISQUS
|id=networkm
|uniqid=XenServer
|url=https://aman.awiki.org/wiki/XenServer
}}