Creating an LVM Mirror for Fault Tolerance or Moving Data
This document (7009321) is provided subject to the disclaimer at the end of this document.
Environment
SUSE Linux Enterprise Server 10
Situation
Resolution
Add the additional devices to the volume group containing the pre-existing volume to be mirrored. For example,
server:~ # pvscan
PV /dev/sdb VG vg lvm2 [196.00 MB / 96.00 MB free]
Total: 1 [196.00 MB] / in use: 1 [196.00 MB] / in no VG: 0 [0 ]
server:~ # vgs
VG #PV #LV #SN Attr VSize VFree
vg 1 1 0 wz--n- 196.00M 96.00M
server:~ # lvs
LV VG Attr LSize Origin Snap% Move Log Copy%
lv1 vg -wi-ao 100.00M
server:~ # mount | grep exports
/dev/mapper/vg-lv1 on /exports/lv1 type ext3 (rw)
server:~ # cat /proc/partitions
major minor #blocks name
8 0 15728640 sda
8 1 1542208 sda1
8 2 14185395 sda2
8 16 204800 sdb
8 32 204800 sdc
8 48 204800 sdd
253 0 102400 dm-0
After adding the free disks, the configuration might look like this:
server:~ # pvcreate /dev/sd[c-d]
Physical volume "/dev/sdc" successfully created
Physical volume "/dev/sdd" successfully created
server:~ # vgextend vg /dev/sd[c-d]
Volume group "vg" successfully extended
server:~ # pvscan
PV /dev/sdb VG vg lvm2 [196.00 MB / 96.00 MB free]
PV /dev/sdc VG vg lvm2 [196.00 MB / 196.00 MB free]
PV /dev/sdd VG vg lvm2 [196.00 MB / 196.00 MB free]
Total: 3 [588.00 MB] / in use: 3 [588.00 MB] / in no VG: 0 [0 ]
server:~ # vgs
VG #PV #LV #SN Attr VSize VFree
vg 3 1 0 wz--n- 588.00M 488.00M
server:~ # lvs -a -o +devices
LV VG Attr LSize Origin Snap% Move Log Copy% Devices
lv1 vg -wi-ao 100.00M /dev/sdb(0)
Convert the linear logical volume to a mirrored logical volume.
lvconvert -m1 /dev/vg/lv1
server:~ # lvconvert -m1 /dev/vg/lv1
Logical volume lv1 converted.
server:~ # lvs -a -o +devices
LV VG Attr LSize Origin Snap% Move Log Copy% Devices
lv1 vg mwi-ao 100.00M lv1_mlog 88.00 lv1_mimage_0(0),lv1_mimage_1(0)
[lv1_mimage_0] vg iwi-ao 100.00M /dev/sdb(0)
[lv1_mimage_1] vg iwi-ao 100.00M /dev/sdc(0)
[lv1_mlog] vg lwi-ao 4.00M /dev/sdd(0)
server:~ # lvs -a -o +devices
LV VG Attr LSize Origin Snap% Move Log Copy% Devices
lv1 vg mwi-ao 100.00M lv1_mlog 100.00 lv1_mimage_0(0),lv1_mimage_1(0)
[lv1_mimage_0] vg iwi-ao 100.00M /dev/sdb(0)
[lv1_mimage_1] vg iwi-ao 100.00M /dev/sdc(0)
[lv1_mlog] vg lwi-ao 4.00M /dev/sdd(0)
This can be done while the logical volume is mounted. Use the lvs command to see the status of the mirror Copy%. If any of the disks ever fail, the logical volume will be converted back to a linear volume using the remaining physical disk. If the data got moved to another disk, the old disk can be simply remove. LVM will detect the lost disk and convert the volume back to a linear logical volume using the existing disk on the new SAN or location. Please make sure the data is backed up prior to doing this operation.
Disclaimer
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:7009321
- Creation Date: 09-Sep-2011
- Modified Date:06-Mar-2021
-
- SUSE Linux Enterprise Desktop
- SUSE Linux Enterprise Server
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com