This is a fairly straight-forward process.
- Exporting the volume group from its current host
- Unmount any LV residing on that particular VG. In my case, there’s only one LV on VG vg0
- list all lv in the vg
[root@hqhcmdev1 ~]# lvdisplay --- Logical volume --- LV Name /dev/vg0/lvol0 VG Name vg0 LV UUID 7HltCU-Elaq-x1pr-S7Wm-xvOt-NGk6-Fwufyd LV Write Access read/write LV Status NOT available LV Size 97.47 GB Current LE 6238 Segments 1 Allocation inherit Read ahead sectors 0
- unmount the lv
[root@hqhcmdev1 ~]# umount /u01
- if there’s any, remove the fstab entry for that particular partition, so that the booting process will not try to mount the partition
[root@hqhcmdev1 ~]# vi /etc/fstab
The /etc/fstab should look like this:
# This file is edited by fstab-sync - see 'man fstab-sync' for details /dev/VolGroup00/LogVol00 / ext3 defaults 1 1 LABEL=/boot /boot ext3 defaults 1 2 none /dev/pts devpts gid=5,mode=620 0 0 none /dev/shm tmpfs defaults 0 0 none /proc proc defaults 0 0 none /sys sysfs defaults 0 0 /dev/VolGroup00/LogVol01 swap swap defaults 0 0 #LABEL=/u01 /u01 ext3 defaults 1 1
- list all lv in the vg
- Deactivate, and export the volume group
- Deactivating vg0
[root@hqhcmdev1 ~]# vgchange -an vg0 0 logical volume(s) in volume group "vg0" now active
- exporting vg0
[root@hqhcmdev1 ~]# vgexport vg0 file system Volume group "vg0" successfully exported
- Deactivating vg0
- Unmount any LV residing on that particular VG. In my case, there’s only one LV on VG vg0
- Import the volume group to the new server
- Present the exported partition to the new server
- Search for the new partition This step depends on what hardware are you using for the storage. Some SANs provide it’s own tool, and others use linux generic command such as:
[root@hqhcmdev2 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
- Check whether the partition has been detected by the target server using pvscan
[root@hqhcmdev2 ~]# pvscan PV /dev/sda2 VG VolGroup00 lvm2 [19.88 GB / 0 free] PV /dev/sdb1 is in exported VG vg0 [99.98 GB / 2.52 GB free] PV /dev/sdd1 VG VolGroup00 lvm2 [3.97 GB / 128.00 MB free] Total: 3 [123.83 GB] / in use: 3 [123.83 GB] / in no VG: 0 [0 ]
- Search for the new partition This step depends on what hardware are you using for the storage. Some SANs provide it’s own tool, and others use linux generic command such as:
- Activate and import the volumegroup
- Import the VG
[root@hqhcmdev2 ~]# vgimport vg0 Volume group "vg0" successfully imported
- Activate the VG
[root@hqhcmdev2 ~]# vgchange -ay vg0
- Import the VG
- Mount the imported partition
- Create a mountpoint for the imported partition
[root@hqhcmdev2 ~]# mkdir /t01
- label the partition First, look for the logical volume residing on the newly imported partition
[root@hqhcmdev2 ~]# lvdisplay vg0 --- Logical volume --- LV Name /dev/vg0/lvol0 VG Name vg0 LV UUID 7HltCU-Elaq-x1pr-S7Wm-xvOt-NGk6-Fwufyd LV Write Access read/write LV Status available # open 1 LV Size 97.47 GB Current LE 6238 Segments 1 Allocation inherit Read ahead sectors 0 Block device 253:2
Next, create a label for that LV
[root@hqhcmdev2 ~]# e2label /dev/vg0/lvol0 /t01
- optionally, create a fstab entry for the partition, if you want it to be automatically mounted on reboot
[root@hqhcmdev2 ~]# vi /etc/fstab
The /etc/fstab should look like this:
This file is edited by fstab-sync - see 'man fstab-sync' for details /dev/VolGroup00/LogVol00 / ext3 defaults 1 1 LABEL=/boot /boot ext3 defaults 1 2 none /dev/pts devpts gid=5,mode=620 0 0 none /dev/shm tmpfs defaults 0 0 none /proc proc defaults 0 0 none /sys sysfs defaults 0 0 /dev/VolGroup00/LogVol01 swap swap defaults 0 0 LABEL=/t01 /t01 ext3 defaults 1 1
- Mount the partition
[root@hqhcmdev1 ~]# mount /t01
- Create a mountpoint for the imported partition
- Present the exported partition to the new server
[…] en: http://outhereinthefield.wordpress.com/2011/06/01/moving-volume-groups-between-hosts-in-rhel/ Tweet This entry was posted in Bash, Comandos, How-to, Red Hat, Sysadmin and tagged […]