copy LVM partition to new disk
6,093
Since the two disks are exactly the same size and need to contain exactly the same data, you could use dd:
dd if=/dev/sdb of=/dev/sda bs=16M
You'll need to boot from a live use though. Please check the if(in file) and of(out file) statements from the live usb. Once you start dd(disk destroyer), there's no going back.
Related videos on Youtube
Author by
exxon
Updated on September 18, 2022Comments
-
exxon almost 2 years
I have a question about making copy of LVM partition to new disk. I want co copy not to move data.
My operating system is Debian. On LVM partition I have running Xen virtual systems.
Information about my disk with LVM (/dev/sdb):
root@server:/# fdisk -l /dev/sdb Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000015e9 Device Boot Start End Blocks Id System /dev/sdb1 * 2048 194559 96256 83 Linux /dev/sdb2 194560 39256063 19530752 83 Linux /dev/sdb3 39258110 1953523711 957132801 5 Extended /dev/sdb5 39258112 78317567 19529728 83 Linux /dev/sdb6 78319616 117379071 19529728 83 Linux /dev/sdb7 117381120 840898559 361758720 83 Linux /dev/sdb8 840900608 1953523711 556311552 83 Linux root@server:/# pvs PV VG Fmt Attr PSize PFree /dev/sdb8 VG lvm2 a-- 530.54g 438.54g root@server:/# lvs LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert lvol1 VG -wi-ao-- 2.00g lvol2 VG -wi-ao-- 15.00g lvol3 VG -wi-a--- 2.00g lvol4 VG -wi-a--- 15.00g lvol5 VG -wi-ao-- 2.00g lvol6 VG -wi-ao-- 16.00g lvol7 VG -wi-ao-- 32.00g swap VG -wi-ao-- 8.00g root@server:/# fdisk -l | grep vd Disk /dev/mapper/VG-lvol1 doesn't contain a valid partition table Disk /dev/mapper/VG-lvol2 doesn't contain a valid partition table Disk /dev/mapper/VG-lvol3 doesn't contain a valid partition table Disk /dev/mapper/VG-lvol4 doesn't contain a valid partition table Disk /dev/mapper/VG-lvol5 doesn't contain a valid partition table Disk /dev/mapper/VG-lvol6 doesn't contain a valid partition table Disk /dev/mapper/VG-lvol7 doesn't contain a valid partition table Disk /dev/mapper/VG-swap doesn't contain a valid partition table
At the moment I made copy of all non LVM partitions to new drive (dev/sda):
root@server:/# fdisk -l /dev/sda Disk /dev/sda: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sda1 * 2048 194559 96256 83 Linux /dev/sda2 194560 39256063 19530752 83 Linux /dev/sda3 39258110 1953523711 957132801 5 Extended Partition 3 does not start on physical sector boundary. /dev/sda5 39258112 78317567 19529728 83 Linux /dev/sda6 78319616 117379071 19529728 83 Linux /dev/sda7 117381120 840898559 361758720 83 Linux /dev/sda8 840900608 1953523711 556311552 83 Linux
Correct me if I'm wrong but should I follow these steps:
- Change partition type to LVM on /dev/sda8
pvcreate /dev/sda8
vgextend VG /dev/sda8
lvconvert -m 1 --mirrorlog corelog VG/lvol1 /dev/sda8
- for all logical volumes.- To see the progress
lvs -a -o+devices
lvconvert -m 0 VG/lvol1 /dev/sda8
- for all logical volumes.
-
Dr I about 9 yearsYou should probably rather use the LVM Snapshotting features.