Memperbesar Kapasitas Disk Virtual Machine Pada XCP atau Xenserver


Saat membuat VM pada XCP atau xenserver mungkin kita belum terpikir apakah suatu saat akan membutuhkan space yang lebih atau tidak. Lalu bagaimana jika suatu saat kita menginginkan storage VM yang sudah ada kita tambah? Setidaknya dengan teknologi virtualisasi dan SAN kita tidak perlu repot untuk memasang Hardisk tambahan. :D.

Memperbesar Disk VM XCP Xenserver

mari kita coba Memperbesar Kapasitas Disk Virtual Machine Pada XCP atau Xenserver. pada contoh di bawah ini saya memiliki VM pada XCP yang tersetting menggunakan storage disk sebesar 8GB.

[root@vm1 ~]# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 7.88 GB
PE Size 32.00 MB
Total PE 252
Alloc PE / Size 252 / 7.88 GB
Free PE / Size 0 / 0
VG UUID Rs4m3k-ao1N-XPyD-PakQ-7NRu-dPGr-buaEw

[root@vm1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
5.7G 1.4G 4.1G 26% /
/dev/xvda1 99M 14M 81M 15% /boot
tmpfs 3.0G 0 3.0G 0% /dev/shm

Shutdown dahulu VM yang akan di ditambahkan kapasitas storagenya, lalu rubah kapasitas storagenya melalui xencenter, pada contoh ini saya menambahkan storage menjadi 80GB, lalu start kembali VM tersebut, selanjutnya setelah VM aktif kembali kita akan melakukan perubahan pada partisi yang sudah pernah dibuat dengan melakukan melalui

user@computer:$ fdisk
  • Print partisi yang ada
  • Delete partisi yang akan di rubah sizenya
  • Create ulang partisi dengan size yang dimaksud
  • Setting partisi ke LVM
  • Print kembali partisi
  • Reboot
[root@vm1 ~]# fdisk -l

Disk /dev/xvda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          13      104391   83  Linux
/dev/xvda2              14        1044     8281507+  8e  Linux LVM

Disk /dev/xvdd: 66 MB, 66883584 bytes
255 heads, 63 sectors/track, 8 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/xvdd doesn't contain a valid partition table
[root@vm1 ~]# fdisk /dev/xvda

The number of cylinders for this disk is set to 10443.
There is nothing wrong with that, 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 other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/xvda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          13      104391   83  Linux
/dev/xvda2              14        1044     8281507+  8e  Linux LVM

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-10443, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-10443, default 10443):
Using default value 10443

Command (m for help): p

Disk /dev/xvda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          13      104391   83  Linux
/dev/xvda2              14       10443    83778975   83  Linux

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.
[root@vm1 ~]# reboot

 

lalu kita akan menginfokan kepada sistem LVM bahwa ada perubahan yang kita lakukan di dalam partisi. pada bagian ini kita menggunakan command

user@computer:$ lvresize
[root@vm1 ~]# pvdisplay
--- Physical volume ---
PV Name               /dev/xvda2
VG Name               VolGroup00
PV Size               7.90 GB / not usable 23.41 MB
Allocatable           yes (but full)
PE Size (KByte)       32768
Total PE              252
Free PE               0
Allocated PE          252
PV UUID               8TAYVD-k8G7-lcZ4-Zkmy-Of3X-YKHx-sLMCSH

[root@vm1 ~]# pvresize /dev/xvda2
Physical volume "/dev/xvda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
[root@vm1 ~]# pvdisplay
--- Physical volume ---
PV Name               /dev/xvda2
VG Name               VolGroup00
PV Size               79.90 GB / not usable 23.22 MB
Allocatable           yes
PE Size (KByte)       32768
Total PE              2556
Free PE               2304
Allocated PE          252
PV UUID               8TAYVD-k8G7-lcZ4-Zkmy-Of3X-YKHx-sLMCSH

[root@vm1 ~]# vgdisplay
--- Volume group ---
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  4
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                1
Act PV                1
VG Size               79.88 GB
PE Size               32.00 MB
Total PE              2556
Alloc PE / Size       252 / 7.88 GB
Free  PE / Size       2304 / 72.00 GB
VG UUID               Rs4m3k-ao1N-XPyD-PakQ-7NRu-dPGr-buaEwV

[root@vm1 ~]# lvdisplay
--- Logical volume ---
LV Name                /dev/VolGroup00/LogVol00
VG Name                VolGroup00
LV UUID                uK9MD1-v7YV-Nwye-uPmN-0kDt-dJ08-lAegnI
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                5.84 GB
Current LE             187
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           253:0

--- Logical volume ---
LV Name                /dev/VolGroup00/LogVol01
VG Name                VolGroup00
LV UUID                SimRQs-VSpp-2GBB-IN25-Bnc6-Q2I3-TiZHy9
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                2.03 GB
Current LE             65
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           253:1

[root@vm1 ~]# lvresize -l +100%FREE /dev/VolGroup00/LogVol00
Extending logical volume LogVol00 to 77.84 GB
Logical volume LogVol00 successfully resized
[root@vm1 ~]# vgdisplay
--- Volume group ---
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  5
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                1
Act PV                1
VG Size               79.88 GB
PE Size               32.00 MB
Total PE              2556
Alloc PE / Size       2556 / 79.88 GB
Free  PE / Size       0 / 0
VG UUID               Rs4m3k-ao1N-XPyD-PakQ-7NRu-dPGr-buaEwV

Langkah terakhir adalah melakukan resize pada file system dengan command

user@computer:$ resize2fs

lalu melakukan reboot

[root@vm1 ~]# 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 20406272 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 20406272 blocks long.

[root@vm1 ~]# reboot

Broadcast message from root (pts/0) (Sat Nov 19 18:36:39 2011):

The system is going down for reboot NOW!