How to resize a disk partition on a Xen Guest Linux host

Alcuni semplici step per allargare una partizione Linux di un sistema operativo ospitato su Xen:

1) Spegnere la VM guest

2) Dal Dom0 eseguire: xe vdi-resize uuid=13575f55-e55d-7f49-f22d-62427cb8fa22 disk-size=5500MiB

3) Start VM

4) Nella VM: fdisk /dev/xvda
Command (m for help): d
Partition number (1-4): 2
Command (m for help): p
Disk /dev/xvda: 5767 MB, 5767168000 bytes
255 heads, 63 sectors/track, 701 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 13 104391 83 Linux
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-701, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-701, default 701):
Using default value 701
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

5) reboot

6) Dalla VM: pvresize -v /dev/xvda2
Using physical volume(s) on command line
Archiving volume group “VolGroup00” metadata (seqno 5).
Resizing physical volume /dev/xvda2 from 115 to 168 extents.
Resizing volume “/dev/xvda2” to 11052336 sectors.
Updating physical volume “/dev/xvda2”
Creating volume group backup “/etc/lvm/backup/VolGroup00” (seqno 6).
Physical volume “/dev/xvda2” changed
1 physical volume(s) resized / 0 physical volume(s) not resized

7) lvextend -l +100%FREE /dev/VolGroup00/LogVol00
Extending logical volume LogVol00 to 5.25 GB
Logical volume LogVol00 successfully resized
resize2fs /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 1376256 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 1376256 blocks long.



Leave a Comment