In the follow example, I have a 4GB virtual IDE disk, and we'll resize to 5GB.
Requirements:
- Xen Project virtual machine
- Virtual IDE Disk
- Partition with EXT4 filesystem
- A partition where reside all the files, wich will be resized, and a swap partition (primary or extended)
1) Open virtual machine Manager, open virtual machine Details, and annotate the IDE Disk Source Path.
2) Shutdown the virtual machine
3) For safety, backup your virtual harddisk
# cp disk0.raw disk0.raw.backup
4) Increase the virtual IDE disk in the hypervisor:
Before: -rwxr-xr-x 1 root root 4.0G Jun 9 09:16 disk0.raw
# dd if=/dev/zero bs=1G count=1 >> disk0.raw
After: -rwxr-xr-x 1 root root 5.0G Jun 9 09:16 disk0.raw
Note: To increase the disk space more, change the "count" value.
5) Yet in the hypervisor, annotate the "Start" value of the first partition.
In this case, disk0.raw1 is the operational system partition, this is the partition that will be increased.
The partition disk0.raw2 and disk0.raw5 is the swap partition.
6) Yet in the hypervisor, with FDISK delete all the partitions from the virtual disk and create again with more space. The first partition must start in the same sector.
# fdisk disk0.raw
Verify the partitions:
Command: p
Delete the partitions:
Command: d →
2 → d → 1
Create the new primary partition with the new size:
Command: n →
p → 1 → 2048 → +4800M → enter
Note: 2048 is the start of first partition, annotated in the item 5, +4800M is the new partition size. Leave some space for the swap partition.
Rebuild the extended partition for swap
Rebuild the external partition for swap:
Command: n → e → 2 → enter → enter
Command: n → e → 2 → enter → enter
Create the logical partition for swap:
Command: n →
l → enter → enter
Change the partition type for swap filesystem:
Command: t → 5 → 82
Verify the partitions:
7) Start the Virtual Machine. The next commands will be executed inside the Virtual Machine.
Verify the current free space in the virtual machine:
We still have only 4GB of Disk Size and 124MB of free space.
Resize the partition using RESIZE2FS
Note: Online resizing is only possible with EXT4 filesystem.
Verify the new Disk Size:
Now your virtual disk have 4.7GB and 997MB of free space.
8) Fix the swap partition:
The swap partition was deleted and recreated, so you need to reconfigure again.
Format the swap partition:
Annotate the UUID of the swap partition and fix it in the /etc/fstab
Enable the swap partition:
Verify if the swap is configured:
Done!
References:
Nenhum comentário:
Postar um comentário