XenServer: Difference between revisions

From Network Security Wiki
Content added Content deleted
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:LoadBalancers]]
__TOC__
<br />

=Increasing free disk space in Ubuntu VM=
=Increasing free disk space in Ubuntu VM=
Source: [https://www.vmotionhost.com/client-area/knowledgebase.php?action=displayarticle&id=177 vmotionhost.com]
Source: [https://www.vmotionhost.com/client-area/knowledgebase.php?action=displayarticle&id=177 vmotionhost.com]
Line 57: Line 61:




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)
The primary partition is now correct but the swap partition is not. <br />
The type of the partition should not be “83” but “82” (marking it as a partition for the Linux swap)
<pre>
<pre>
Command (m for help): p
Command (m for help): p
Line 80: Line 85:
After creating a new partition for swap the UUID will not match and upon reboot, no swap will be available.
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
awk '/swap/ { print $1 }' /etc/fstab
#
UUID=8bb62351-4436-47df-92fe-af2865f03461
UUID=8bb62351-4436-47df-92fe-af2865f03461
root@ubuntu:~# swapoff -a
root@ubuntu:~# free -m
total used free shared buffers cached
Mem: 992 695 296 0 23 325
-/+ buffers/cache: 346 645
Swap: 0 0 0


Turn off the Swap
To make sure that there is no data (usable by the kernel) at the beginning of the partition
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
root@ubuntu:~# dd if=/dev/zero of=/dev/xvda2
dd: writing to `/dev/xvda2': No space left on device
dd: writing to `/dev/xvda2': No space left on device


Now change the UUID of the Swap disk to match the fstab:
root@ubuntu:~# mkswap -U 8bb62351-4436-47df-92fe-af2865f03461 /dev/xvda2
mkswap -U 8bb62351-4436-47df-92fe-af2865f03461 /dev/xvda2
Setting up swapspace version 1, size = 523260 KiB

no label, UUID=8bb62351-4436-47df-92fe-af2865f03461
Turn on the Swap again
root@ubuntu:~# swapon -a
swapon -a
root@ubuntu:~# free -m

total used free shared buffers cached
Confirm if swap size is non zero now
Mem: 992 693 298 0 23 325
free -m
-/+ buffers/cache: 345 646

Swap: 510 7 503
Now resize the filesystem
root@ubuntu:~#
resize2fs /dev/xvda1

Now confirm if the changes have taken effect:
df -h


Now The final and easiest step is to resize the filesystem


<br />
root@ubuntu:~# df -h
;References
Filesystem Size Used Avail Use% Mounted on
<references/>
/dev/xvda1 9.0G 2.8G 5.8G 33% /
<br />
udev 488M 4.0K 488M 1% /dev
<br />
tmpfs 199M 788K 198M 1% /run
<br />
none 5.0M 0 5.0M 0% /run/lock
none 497M 200K 496M 1% /run/shm


root@ubuntu:~# resize2fs /dev/xvda1
resize2fs 1.42 (29-Nov-2011)


{{DISQUS}}
root@ubuntu:~# df -h

Latest revision as of 16:43, 15 December 2022


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 }}