I needed to add more storage space on the /home directory of a Xen guest running on a RHEL5 system.
I investigated extending its LUN on the NetApp Filer and then tried running pvresize to see if the Xen guest would recognise the new size. No luck.
In the end, i created another iSCSI LUN, mapped it to the Xen host, configured the Xen guest to see the new LUN and let LVM know it had another physical disk to play with.
This is how i did it.
First, i created and mapped a new iSCSI LUN on the NetApp Filer. In the example below, the iSCSI LUN is called /vol/xen_guest/grimlock/lun2 which is found in the qtree i created in the tutorial titled '
RHEL5 Xen Guest with a backend NetApp iSCSI device'.
nas> lun create -s 10g -t linux /vol/xen_guest/grimlock/lun2
nas> lun map /vol/xen_guest/grimlock/lun2 grimlock
On the RHEL5 Xen host, i rescanned the iSCSI session asking for any new iSCSI LUNs on offer.
# echo '- - -' > /sys/class/scsi_host/host0/scan
I then added the disk to the disk directive within the Xen configuration file. In the example im using, the Xen configuration file would be found at /etc/xen/auto/grimlock. The new disk as seen by the Xen host is /dev/sdd. The new disk as seen by the Xen guest will be /dev/xvdb.
disk = [ 'phy:/dev/sdc,xvda,w','phy:/dev/sdd,xvdb,w' ]
Then i shutdown and started the Xen guest using 'xm create' so it registered the new physical device.
# xm shutdown grimlock
# xm create /etc/xen/auto/grimlock
Once the Xen guest had started back up again, i logged in and checked that the new /dev/xvdb was available.
# fdisk -l /dev/xvdb
Disk /dev/xvdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/xvdb doesn't contain a valid partition table
I then initialised the new device as an LVM device
# pvcreate /dev/xvdb
Added /dev/xvdb to the volume group 'VolGroup00'.
# vgextend VolGroup00 /dev/xvdb
I wanted to add this new device to the /home partition within the Xen guest. As i have partitioned my disk with /home on its own partition i had to extend the logical volume called LogVol03.
# df -hP | grep home
/dev/mapper/VolGroup00-LogVol03 13G 2.8G 9.4G 23% /home
# lvextend -L +10G /dev/VolGroup00/LogVol03
As the /home partition is formatted using ext3, i had to complete the resizing by running resize2fs. Its a good idea to unmount the file system before running resize2fs.
# umount /home
# e2fsck -fy /dev/VolGroup00/LogVol03
# resize2fs /dev/VolGroup00/LogVol03
# mount /home
Once the resize2fs had completed and /home was remounted, the Xen guest had more disk to use.
Post new comment