Jumat, 19 September 2014

Memperbesar Kapasitas Volume Group Pada VM CentOS

Disini saya memiliki 1 buah VM CentOS 6.5 64bit di dalam Host Citrix Xenserver. Karena pada saat awal meng-create VM CentOS 6.4 saya tidak menentukan besar hardisk virtual yang akan digunakan, maka saya mendapatkan hardisk virtual hanya sebesar 8GB sebagai tempat instalasi OS CentOS 6.4. Hardisk tempat instalasi OS CentOS ini dikenal sebagai "/dev/xvda". Partisi LVM berada di "/dev/xvda2"
Karena saat ini saya hendak menjadikan VM CentOS ini sebagai Server Database PostgreSQL, maka saya menginginkan VM ini memiliki kapasitas hardisk virtual sebesar 50GB. Maka melalui Xen Center, saya memperbesar ukuran hardisk virtual tersebut menjadi 50GB, dan saya mendapatkan kapasitas hardisk "/dev/xvda" telah berubah menjadi 50GB. Namun apa yang terjadi pada partisi yang telah terlanjur diinstal CentOS ("/dev/xvda2") ?, kapasitas hardisk virtual memang berubah menjadi 50GB, namun partisi default ("/dev/xvda2") tempat OS CentOS 6.4 di-install tetap hanya 8GB.
Untuk mengatasi masalah ini, saya harus men-delete partisi "/dev/xvda2" terlebih dahulu kemudian meng-create kembali dengan kapasitas yang tersisa (mendekati 50GB). Tetapi partisi "/dev/xvda2" adalah tempat file-file instalasi CentOS bermukim, bagaimana mungkin saya bisa men-delete partisi ini ?. Alhamdulillah, beruntung partisi ini berjenis LVM, sehingga pekerjaan menjadi mudah. Caranya adalah saya harus menambahkan sebuah hardisk virtual baru dengan kapasitas 50GB ke VM CentOS 6.4 tersebut, untuk menampung sementara file-file system yang ada di partisi "/dev/xvda2". Hardisk Virtual kedua ini dikenal sebagai "/dev/xvdb". Perhatikan hasil identifikasi berikut ini.

[root@PostgreSQL-50G ~]# fdisk -l

Disk /dev/xvda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00057c4a

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2              64        1045     7875584   8e  Linux LVM

Disk /dev/xvdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/xvdd: 119 MB, 119197696 bytes
255 heads, 63 sectors/track, 14 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/VolGroup-lv_root: 5947 MB, 5947523072 bytes
255 heads, 63 sectors/track, 723 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/VolGroup-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[root@PostgreSQL-50G ~]# pvs
  PV         VG       Fmt  Attr PSize PFree
  /dev/xvda2 VolGroup lvm2 a--  7,51g    0 

[root@PostgreSQL-50G ~]# pvs -o+pv_used
  PV         VG       Fmt  Attr PSize PFree Used 
  /dev/xvda2 VolGroup lvm2 a--  7,51g    0  7,51g

Langkah selanjutnya adalah saya harus meng-create partisi baru bertipe Linux LVM dari hardisk "/dev/xvdb". Kemudian menggabungkan partisi tersebut ke Volume Group yang sama dengan "/dev/xvda2". Perhatikan langkah-langkah berikut ini.

[root@PostgreSQL-50G ~]# fdisk /dev/xvdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x6e3f1ea5.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-5221, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-5221, default 5221): 
Using default value 5221

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Create PV dari hardisk kedua ini.

[root@PostgreSQL-50G ~]# pvcreate /dev/xvdb1
  Physical volume "/dev/xvdb1" successfully created
 
[root@PostgreSQL-50G ~]# pvs
  PV         VG       Fmt  Attr PSize  PFree 
  /dev/xvda2 VolGroup lvm2 a--   7,51g     0 
  /dev/xvdb1          lvm2 a--  39,99g 39,99g

Kemudian gabungkan PV yang baru ini kedalam Volume Group yang sama dengan "/dev/xvda2".

[root@PostgreSQL-50G ~]# vgextend VolGroup /dev/xvdb1
  Volume group "VolGroup" successfully extended
 
[root@PostgreSQL-50G ~]# pvs
  PV         VG       Fmt  Attr PSize  PFree 
  /dev/xvda2 VolGroup lvm2 a--   7,51g     0 
  /dev/xvdb1 VolGroup lvm2 a--  39,99g 39,99g

[root@PostgreSQL-50G ~]# vgs
  VG       #PV #LV #SN Attr   VSize  VFree 
  VolGroup   2   2   0 wz--n- 47,50g 39,99g

[root@PostgreSQL-50G ~]# pvs -o+pv_used
  PV         VG       Fmt  Attr PSize  PFree  Used 
  /dev/xvda2 VolGroup lvm2 a--   7,51g     0  7,51g
  /dev/xvdb1 VolGroup lvm2 a--  39,99g 39,99g    0 

Dan ini adalah proses inti dari trik ini. Pindahkan seluruh isi "/dev/xvda2" ke "/dev/xvdb1".

[root@PostgreSQL-50G ~]# pvmove /dev/xvda2 /dev/xvdb1
  /dev/xvda2: Moved: 0,1%
  /dev/xvda2: Moved: 3,1%
  /dev/xvda2: Moved: 5,3%
  /dev/xvda2: Moved: 7,8%
  /dev/xvda2: Moved: 10,5%
  /dev/xvda2: Moved: 17,1%
  /dev/xvda2: Moved: 24,9%
  /dev/xvda2: Moved: 29,6%
  /dev/xvda2: Moved: 31,8%
  /dev/xvda2: Moved: 35,6%
  /dev/xvda2: Moved: 43,3%
  /dev/xvda2: Moved: 51,1%
  /dev/xvda2: Moved: 55,9%
  /dev/xvda2: Moved: 62,7%
  /dev/xvda2: Moved: 70,3%
  /dev/xvda2: Moved: 73,8%
  /dev/xvda2: Moved: 81,6%
  /dev/xvda2: Moved: 89,4%
  /dev/xvda2: Moved: 97,1%
  /dev/xvda2: Moved: 100,0%
 
[root@PostgreSQL-50G ~]# pvs -o+pv_used
  PV         VG       Fmt  Attr PSize  PFree  Used 
  /dev/xvda2 VolGroup lvm2 a--   7,51g  7,51g    0 
  /dev/xvdb1 VolGroup lvm2 a--  39,99g 32,48g 7,51g

Sekarang seluruh isi "/dev/xvda2" sudah dipindahkan ke "/dev/xvdb1". Kita dapat mengeluarkan "/dev/xvda2" dari Volume Group, melepasnya dari Physical Volume, kemudian men-delete seluruh partisinya untuk kemudian di-create kembali dengan kapasitas yang lebih besar.

[root@PostgreSQL-50G ~]# vgreduce VolGroup /dev/xvda2
  Removed "/dev/xvda2" from volume group "VolGroup"
 
[root@PostgreSQL-50G ~]# pvs -o+pv_used
  PV         VG       Fmt  Attr PSize  PFree  Used 
  /dev/xvda2          lvm2 a--   7,51g  7,51g    0 
  /dev/xvdb1 VolGroup lvm2 a--  39,99g 32,48g 7,51g
 
[root@PostgreSQL-50G ~]# vgs
  VG       #PV #LV #SN Attr   VSize  VFree 
  VolGroup   1   2   0 wz--n- 39,99g 32,48g
 
[root@PostgreSQL-50G ~]# pvremove /dev/xvda2
  Labels on physical volume "/dev/xvda2" successfully wiped
 
[root@PostgreSQL-50G ~]# pvs
  PV         VG       Fmt  Attr PSize  PFree 
  /dev/xvdb1 VolGroup lvm2 a--  39,99g 32,48g

[root@PostgreSQL-50G ~]# reboot

Disini saya me-reboot komputer untuk membuktikan bahwa proses pemindahan Volume Group "/dev/xvda2" ke "/dev/xvdb1" benar-benar telah berhasil. Setelah reboot dan berhasil login kembali ke system, saya mulai melakukan perubahan partisi pada "/dev/xvda".

[root@PostgreSQL-50G ~]# fdisk -l

Disk /dev/xvda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00057c4a

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2              64        1045     7875584   8e  Linux LVM

Disk /dev/xvdd: 119 MB, 119197696 bytes
255 heads, 63 sectors/track, 14 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/xvdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6e3f1ea5

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1               1        5221    41937651   8e  Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 5947 MB, 5947523072 bytes
255 heads, 63 sectors/track, 723 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

 
[root@PostgreSQL-50G ~]# fdisk /dev/xvda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/xvda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00057c4a

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2              64        1045     7875584   8e  Linux LVM


Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): d
Partition number (1-4): 2

Command (m for help): p

Disk /dev/xvda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00057c4a

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.


Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (64-6527, default 64): 
Using default value 64
Last cylinder, +cylinders or +size{K,M,G} (64-6527, default 6527): 
Using default value 6527

Command (m for help): p

Disk /dev/xvda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00057c4a

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2              64        6527    51915103+  83  Linux

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: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00057c4a

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2              64        6527    51915103+  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 or after you run partprobe(8) or kpartx(8)
Syncing disks.
 
[root@PostgreSQL-50G ~]# reboot

Setelah berhasil reboot dan login kembali ke system, pindahkan kembali Volume Group dari "/dev/xvdb1" ke "/dev/xvda2" yang sekarang sudah memiliki kapasitas sekitar 40GB.

[root@PostgreSQL-50G ~]# fdisk -l

Disk /dev/xvda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00057c4a

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2              64        6527    51915103+  8e  Linux LVM

Disk /dev/xvdd: 119 MB, 119197696 bytes
255 heads, 63 sectors/track, 14 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/xvdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6e3f1ea5

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1               1        5221    41937651   8e  Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 5947 MB, 5947523072 bytes
255 heads, 63 sectors/track, 723 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/VolGroup-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


[root@PostgreSQL-50G ~]# pvs
  PV         VG       Fmt  Attr PSize  PFree 
  /dev/xvdb1 VolGroup lvm2 a--  39,99g 32,48g
 
[root@PostgreSQL-50G ~]# pvcreate /dev/xvda2
  Physical volume "/dev/xvda2" successfully created
 
[root@PostgreSQL-50G ~]# pvs
  PV         VG       Fmt  Attr PSize  PFree 
  /dev/xvda2          lvm2 a--  49,51g 49,51g
  /dev/xvdb1 VolGroup lvm2 a--  39,99g 32,48g

[root@PostgreSQL-50G ~]# vgextend VolGroup /dev/xvda2
  Volume group "VolGroup" successfully extended
 
[root@PostgreSQL-50G ~]# vgs
  VG       #PV #LV #SN Attr   VSize  VFree 
  VolGroup   2   2   0 wz--n- 89,50g 81,99g
 
[root@PostgreSQL-50G ~]# pvs
  PV         VG       Fmt  Attr PSize  PFree 
  /dev/xvda2 VolGroup lvm2 a--  49,51g 49,51g
  /dev/xvdb1 VolGroup lvm2 a--  39,99g 32,48g

[root@PostgreSQL-50G ~]# pvs -o+pv_used
  PV         VG       Fmt  Attr PSize  PFree  Used 
  /dev/xvda2 VolGroup lvm2 a--  49,51g 49,51g    0 
  /dev/xvdb1 VolGroup lvm2 a--  39,99g 32,48g 7,51g

[root@PostgreSQL-50G ~]# pvmove /dev/xvdb1 /dev/xvda2
  /dev/xvdb1: Moved: 0,1%
  /dev/xvdb1: Moved: 2,9%
  /dev/xvdb1: Moved: 5,9%
  /dev/xvdb1: Moved: 8,7%
  /dev/xvdb1: Moved: 11,6%
  /dev/xvdb1: Moved: 14,4%
  /dev/xvdb1: Moved: 17,3%
  /dev/xvdb1: Moved: 20,1%
  /dev/xvdb1: Moved: 23,0%
  /dev/xvdb1: Moved: 25,9%
  /dev/xvdb1: Moved: 28,7%
  /dev/xvdb1: Moved: 31,6%
  /dev/xvdb1: Moved: 34,3%
  /dev/xvdb1: Moved: 37,0%
  /dev/xvdb1: Moved: 39,9%
  /dev/xvdb1: Moved: 42,6%
  /dev/xvdb1: Moved: 45,2%
  /dev/xvdb1: Moved: 48,0%
  /dev/xvdb1: Moved: 50,8%
  /dev/xvdb1: Moved: 53,5%
  /dev/xvdb1: Moved: 56,2%
  /dev/xvdb1: Moved: 59,1%
  /dev/xvdb1: Moved: 61,8%
  /dev/xvdb1: Moved: 64,6%
  /dev/xvdb1: Moved: 67,4%
  /dev/xvdb1: Moved: 70,1%
  /dev/xvdb1: Moved: 72,9%
  /dev/xvdb1: Moved: 73,8%
  /dev/xvdb1: Moved: 76,5%
  /dev/xvdb1: Moved: 79,3%
  /dev/xvdb1: Moved: 82,2%
  /dev/xvdb1: Moved: 84,9%
  /dev/xvdb1: Moved: 87,6%
  /dev/xvdb1: Moved: 90,4%
  /dev/xvdb1: Moved: 93,1%
  /dev/xvdb1: Moved: 95,9%
  /dev/xvdb1: Moved: 98,6%
  /dev/xvdb1: Moved: 100,0%

[root@PostgreSQL-50G ~]# pvs
  PV         VG       Fmt  Attr PSize  PFree 
  /dev/xvda2 VolGroup lvm2 a--  49,51g 42,00g
  /dev/xvdb1 VolGroup lvm2 a--  39,99g 39,99g

Setelah semua data dikembalikan ke "/dev/xvda2", kita dapat mengeluarkan hardisk "/dev/xvdb1" dari system kemudian melepasnya dari mesin fisik atau dalam hal ini adalah VM CentOS di XenServer Host.

[root@PostgreSQL-50G ~]# vgreduce VolGroup /dev/xvdb1
  Removed "/dev/xvdb1" from volume group "VolGroup"
 
[root@PostgreSQL-50G ~]# pvs
  PV         VG       Fmt  Attr PSize  PFree 
  /dev/xvda2 VolGroup lvm2 a--  49,51g 42,00g
  /dev/xvdb1          lvm2 a--  39,99g 39,99g
 
[root@PostgreSQL-50G ~]# pvremove /dev/xvdb1
  Labels on physical volume "/dev/xvdb1" successfully wiped

[root@PostgreSQL-50G ~]# fdisk -l

Disk /dev/xvda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00057c4a

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2              64        6527    51915103+  8e  Linux LVM

Disk /dev/xvdd: 119 MB, 119197696 bytes
255 heads, 63 sectors/track, 14 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/xvdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6e3f1ea5

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1               1        5221    41937651   8e  Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 5947 MB, 5947523072 bytes
255 heads, 63 sectors/track, 723 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/VolGroup-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[root@PostgreSQL-50G ~]# fdisk /dev/xvdb

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/xvdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6e3f1ea5

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1               1        5221    41937651   8e  Linux LVM

Command (m for help): d
Selected partition 1

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

[root@PostgreSQL-50G ~]# shutdown -h now

Setelah proses shutdown berhasil, silahkan cabut Virtual Hardisk ke dua ini ("/dev/xvdb") dari VM melalui Xen Center.

4 komentar:

  1. Saya sudah bukmak. Benar-benar blog yang serius membahas Linux. Ini yang saya cari. Terima kasih.

    BalasHapus
  2. Assalamu'alaikum..
    Saya newbie di linux, dan mengalami masalah yg sama ketika install centos7 di vmware ws10. Artikel ini sangat membantu dan bermanfaat bagi newbie seperti saya. Pertanyaan saya apakah langkah2 ini bisa dijalankan di real machine? sekaligus fungsi banckup dari sebuah server ( dibuat seperti clone). Terima kasih dan mohon ijin untuk menshare kembali di blog saya
    Wassalmu'alaikum

    BalasHapus
    Balasan
    1. Seharusnya bisa, karena teknik ini sebenarnya memang diperuntukkan bagi mesin fisik / hardisk fisik yang real.
      Kalau untuk fungsi backup menggunakan LVM gunakan saja perintah copy volume group bukan moving volume group, namun perlu diingat bahwa walaupun VG dapat di copy / di cloning, namun partisi /boot tetap tertinggal. Ada teknik lain untuk membackup keseluruhan hardisk baik partisi /boot maupun LVM yaitu dengan cara RAID software.

      Hapus