- Log in to XenServer.
- To modify the virtual machine disk size
Modify the storage disk size
- Start a virtual machine
- Modify Partition size
Fdisk/dev/xvda
The number of cylinders for this disk was set to 5221.
There is nothing wrong with the, but this is larger than 1024,
And could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from the other OSs
(e.g., DOS fdisk, OS/2 fdisk)
Command (M for help):P
disk/dev/xvda:42.9 GB, 42949672960 bytes
255 heads, Sectors/track, 5221 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/DEV/XVDA1 * 1 104391 Linux
/dev/xvda2 2610 20860402+ 8e Linux LVM
Command (M for help): command (M-help):P
DOS compatibility flag is not set
Command (M for help):D
Partition Number (1-4): 2
Command (M for help):N
Command Action
E Extended
P primary partition (1-4)
P
Partition Number (1-4): 2
First cylinder (14-5221, default 14):
Using Default Value 14
Last cylinder or +size or +sizem or +sizek (14-5221, default 5221):
Using Default Value 5221
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):P
disk/dev/xvda:42.9 GB, 42949672960 bytes
255 heads, Sectors/track, 5221 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/DEV/XVDA1 * 1 104391 Linux
/dev/xvda2 5221 41833260 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 is used at the next reboot.
Syncing disks.
- Restart virtual machine:reboot
- Adjust PV size
PVs
PV VG Fmt Attr PSize pfree
/dev/xvda2 VolGroup00 lvm2 a-19.88g 0
pvresize-v/dev/xvda2
Using physical Volume (s) on command line
Archiving Volume Group "VolGroup00" metadata (seqno 3).
Resizing physical volume/dev/xvda2 from 636 to 1276 extents.
Resizing volume "/dev/xvda2" to 83666136 sectors.
Updating physical Volume "/dev/xvda2"
Creating Volume group Backup "/etc/lvm/backup/volgroup00" (seqno 4).
Physical volume "/dev/xvda2" changed
1 physical Volume (s) resized/0 physical volume (s) not resized
PVs
PV VG Fmt Attr PSize pfree
/dev/xvda2 VolGroup00 lvm2 a-39.88g 20.00G
- Adjust the LV size
Lvs
LV VG Attr lsize Origin snap% Move Log copy% Convert
LogVol00 Volgroup00-wi-ao 17.84G
LogVol01 Volgroup00-wi-ao 2.03G
Lvextend-l +100%free/dev/volgroup00/logvol00
Extending logical Volume LogVol00 to 37.84 GB
Logical Volume LogVol00 successfully resized
Lvs
LV VG Attr lsize Origin snap% Move Log copy% Convert
LogVol00 Volgroup00-wi-ao 37.84G
LogVol01 Volgroup00-wi-ao 2.03G
- Resizing a partition
df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup00-logvol00
5.7G 4.5G 950M 83%/
/DEV/XVDA1 99M 22M 73M 24%/boot
Tmpfs 2.0G 0 2.0G 0%/dev/shm
resize2fs/dev/mapper/volgroup00-logvol00
RESIZE2FS 1.39 (29-may-2006)
Filesystem at/dev/mapper/volgroup00-logvol00 is mounted on/; On-line resizing required
Performing an on-line resize of/dev/mapper/volgroup00-logvol00 to 9920512 (4k) blocks.
The filesystem on/dev/mapper/volgroup00-logvol00 is now 9920512 blocks long.
df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup00-logvol00
37G 4.5G 31G 13%/
/DEV/XVDA1 99M 22M 73M 24%/boot
Tmpfs 2.0G 0 2.0G 0%/dev/shm
Task complete
Problems encountered
When the Linux system is CENTOS7, an error is encountered with the RESIZE2FS command Resize2fs:bad magic number in Super-block and trying to open
Xfs_growfs/dev/root_vg/root with Xfs_growfs instead of command resize2fs
How to adjust the disk size of Linux virtual machines under XenServer