Backup

我無法在 XEN 主機上掛載 LVM 快照

  • March 26, 2013

我想通過複製-rsyncing LVM 快照來備份我的 XEN VM。我正在嘗試掛載包含 XEN 來賓虛擬磁碟 (ext4) 的快照。

以下是我遵循的所有步驟。我無法掛載快照,並且其中似乎沒有分區表。

唯一現有的捲組是“VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a”

我嘗試備份的虛擬磁碟是:“/dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/VHD-8c8064d2-0101-46d4-b1e5-607ad4a92621”

我的快照 LV 的名稱是“vmbackup”。

Xen 主機上 mount 命令的手冊頁沒有顯示支持 ext4。因此,我使用 ext3 磁碟進行了相同的測試,但結果相同。

[root@ ~]# vgdisplay

 --- Volume group ---
 VG Name               VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a
 System ID
 Format                lvm2
 Metadata Areas        1
 Metadata Sequence No  76
 VG Access             read/write
 VG Status             resizable
 MAX LV                0
 Cur LV                4
 Open LV               3
 Max PV                0
 Cur PV                1
 Act PV                1
 VG Size               1.08 TB
 PE Size               4.00 MB
 Total PE              283852
 Alloc PE / Size       5258 / 20.54 GB
 Free  PE / Size       278594 / 1.06 TB
 VG UUID               n4NO4a-fLFT-GCO0-PSye-oW06-UWYP-qryubC

[root@ ~]# lvdisplay

 --- Logical volume ---
 LV Name                /dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/MGT
 VG Name                VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a
 LV UUID                uBsbF7-2O3B-S3S2-7t5M-wSCt-b8qu-2AufzM
 LV Write Access        read/write
 LV Status              available
 # open                 0
 LV Size                4.00 MB
 Current LE             1
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 currently set to     1024
 Block device           252:1

 --- Logical volume ---
 LV Name                /dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-
438139457a4a/ISORepository
 VG Name                VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a
 LV UUID                Bw8KcC-vexj-WEHx-W3dh-lo8b-UpGu-y7qWB4
 LV Write Access        read/write
 LV Status              available
 # open                 1
 LV Size                10.00 GB
 Current LE             2560
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 currently set to     1024
 Block device           252:0

 --- Logical volume ---
 LV Name                /dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/VHD-
8c8064d2-0101-46d4-b1e5-607ad4a92621
 VG Name                VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a
 LV UUID                rCtzAA-VFUZ-tHLP-oJ1D-EHtR-ilXW-RcXwFg
 LV Write Access        read/write
 LV Status              available
 # open                 1
 LV Size                10.03 GB
 Current LE             2567
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 currently set to     1024
 Block device           252:2

 --- Logical volume ---
 LV Name                /dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/VHD-b1f9c38a-042e-4589-8ec5-6389aac8ee4d
 VG Name                VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a
 LV UUID                1Ks1pR-MSbr-U4Q4-bq2T-Py2d-HtUX-0PZnbu
 LV Write Access        read/write
 LV Status              available
 # open                 1
 LV Size                520.00 MB
 Current LE             130
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 currently set to     1024
 Block device           252:3

[root@ ~]# lvcreate -L1G -s -n vmbackup /dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/VHD-8c8064d2-0101-46d4-b1e5-607ad4a92621
 Logical volume "vmbackup" created

[root@ ~]# lvscan
 ACTIVE            '/dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/MGT' [4.00 MB] inherit
 ACTIVE            '/dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/ISORepository' [10.00 GB] inherit
 ACTIVE   Original '/dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/VHD-8c8064d2-0101-46d4-b1e5-607ad4a92621' [10.03 GB] inherit
 ACTIVE            '/dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/VHD-b1f9c38a-042e-4589-8ec5-6389aac8ee4d' [520.00 MB] inherit
 ACTIVE   Snapshot '/dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/vmbackup' [1.00 GB] inherit

[root@ ~]# kpartx -a -v /dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/vmbackup

[root@ ~]# ls /dev/mapper/
control                                                                                                     
VG_XenStorage--2be5fe38--c04b--3277--4ce0--438139457a4a-VHD--8c8064d2--0101--46d4--b1e5--607ad4a92621-real
VG_XenStorage--2be5fe38--c04b--3277--4ce0--438139457a4a-ISORepository

VG_XenStorage--2be5fe38--c04b--3277--4ce0--438139457a4a-VHD--b1f9c38a--042e--4589--8ec5--6389aac8ee4d
VG_XenStorage--2be5fe38--c04b--3277--4ce0--438139457a4a-MGT

VG_XenStorage--2be5fe38--c04b--3277--4ce0--438139457a4a-vmbackup
VG_XenStorage--2be5fe38--c04b--3277--4ce0--438139457a4a-VHD--8c8064d2--0101--46d4--b1e5--607ad4a92621       VG_XenStorage--2be5fe38--c04b--3277--4ce0--438139457a4a-vmbackup-cow

[root@ ~]# mount /dev/mapper/VG_XenStorage--2be5fe38--c04b--3277--4ce0--438139457a4a-vmbackup /mnt
mount: you must specify the filesystem type

[root@ ~]# mount VG_XenStorage--2be5fe38--c04b--3277--4ce0--438139457a4a-vmbackup-cow /mnt
mount: you must specify the filesystem type

[root@ ~]# dmesg | tail
[1531258.118928] device vif7.0 entered promiscuous mode
[1531258.515365] blkback: event-channel 8
[1531258.515551] blkback: ring-ref 8
[1531258.515742] blkback: protocol 3 (x86_64-abi)
[1531258.517356] blkback: event-channel 9
[1531258.517446] blkback: ring-ref 9
[1531258.517480] blkback: protocol 3 (x86_64-abi)
[1531258.521059] /local/domain/7/device/vif/0: Connected
[1531265.156744] /local/domain/7/device/vif/0: Connected
[1531265.157147] /local/domain/7/device/vif/0: Closed

[root@ ~]# mount -t ext4 /dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/vmbackup /mnt
mount: wrong fs type, bad option, bad superblock on /dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/vmbackup,
      missing codepage or other error
      In some cases useful info is found in syslog - try
      dmesg | tail  or so

[root@ ~]# dmesg | tail
[1531258.515365] blkback: event-channel 8
[1531258.515551] blkback: ring-ref 8
[1531258.515742] blkback: protocol 3 (x86_64-abi)
[1531258.517356] blkback: event-channel 9
[1531258.517446] blkback: ring-ref 9
[1531258.517480] blkback: protocol 3 (x86_64-abi)
[1531258.521059] /local/domain/7/device/vif/0: Connected
[1531265.156744] /local/domain/7/device/vif/0: Connected
[1531265.157147] /local/domain/7/device/vif/0: Closed
[1534417.547412] EXT4-fs (dm-4): VFS: Can't find ext4 filesystem

[root@ ~]# fdisk -l /dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/vmbackup
Disk /dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/vmbackup: 10.7 GB, 10766778368 bytes
255 heads, 63 sectors/track, 1308 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/vmbackup doesn't contain a valid partition table

[root@ ~]# fdisk -l /dev/mapper/VG_XenStorage--2be5fe38--c04b--3277--4ce0--438139457a4a-vmbackup-cow
Disk /dev/mapper/VG_XenStorage--2be5fe38--c04b--3277--4ce0--438139457a4a-vmbackup-cow: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/mapper/VG_XenStorage--2be5fe38--c04b--3277--4ce0--438139457a4a-vmbackup-cow doesn't contain a valid partition table

[root@ ~]# lsmod | grep ext4
ext4                  312546  0
jbd2                   75354  1 ext4

以下是我遵循的步驟的摘要:

lvcreate -L1G -s -n vmbackup /dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/VHD-8c8064d2-0101-46d4-b1e5-607ad4a92621

kpartx -a -v /dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/vmbackup

mount /dev/VG_XenStorage-2be5fe38-c04b-3277-4ce0-438139457a4a/vmbackup /mnt mount:必須指定文件系統類型

最後,我根據以下命令製作了一個腳本:

xe vm-list is-control-domain=false is-a-snapshot=false

xe vm-snapshot 列表中的虛擬機

xe template-param-set is-a-template=false ha-always-run=false uuid= …

xe vm-export vm=snap_uuid 文件名=| ssh … REMOTE_HOST “cat > /path/backup.xva”

xe vm-uninstall uuid=snap_uuid force=true

感謝您的建議。

引用自:https://serverfault.com/questions/481494