将 LVM 分区复制到新磁盘

将 LVM 分区复制到新磁盘

我对将 LVM 分区复制到新磁盘有疑问。我希望复制时不移动数据。

我的操作系统是 Debian。在 LVM 分区上,我运行着 Xen 虚拟系统。

有关我的具有 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

目前,我将所有非 LVM 分区复制到新驱动器 (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

如果我错了请纠正我但我应该遵循以下步骤:

  1. 将 /dev/sda8 上的分区类型更改为 LVM
  2. pvcreate /dev/sda8
  3. vgextend VG /dev/sda8
  4. lvconvert -m 1 --mirrorlog corelog VG/lvol1 /dev/sda8- 适用于所有逻辑卷。
  5. 查看进度lvs -a -o+devices
  6. lvconvert -m 0 VG/lvol1 /dev/sda8- 适用于所有逻辑卷。

答案1

由于两个磁盘的大小完全相同,而且需要包含完全相同的数据,因此您可以使用 dd:

dd if=/dev/sdb of=/dev/sda bs=16M

不过,您需要从实时使用中启动。请检查 if(in file) 和 of(out file) 语句从实时 USB。一旦启动 dd(磁盘销毁器),就无法再恢复。

相关内容