掛載LVM分割區的DD鏡像

掛載LVM分割區的DD鏡像

我陷入了困境。我需要從之前建立的備份映像中提取資料。我以為我對 LVM 已經足夠了解了……至少到目前為止是這樣。

我的錯誤似乎是我備份了 LVM 快照磁碟區而不是整個磁碟區組或磁碟分割區。我讀過的大多數文章都暗示您已經備份了整個磁碟。

這是我的 LVM 佈局:

xvda          202:0    0    10G  0 disk
└─xvda1       202:1    0    10G  0 part
  ├─lvm1-root 254:2    0   8.1G  0 lvm  /
  └─lvm1-swap 254:3    0   956M  0 lvm  [SWAP]

這是我的備份指令:

lvcreate -L800M -s -n rootsnapshot /dev/lvm1/root
dd if=/dev/lvm1/rootsnapshot conv=sync,noerror bs=128K status=progress of=/path/to/snapshot.dd

我已將 DD 檔案作為 /dev/loop0 安裝在另一台電腦上。

這是我得到的:

# fdisk -l

Disk /dev/loop0: 8.1 GiB, 8657043456 bytes, 16908288 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

# lvmdiskscan
  /dev/loop0 [       8.06 GiB]
  /dev/sda1  [      <7.00 GiB]
  /dev/sda5  [    1022.00 MiB]
  0 disks
  3 partitions
  0 LVM physical volume whole disks
  0 LVM physical volumes

# vgscan -v
  Reading all physical volumes.  This may take a while...
    No volume groups found.

知道如何安裝此快照以從中檢索資料嗎?

答案1

弄清楚了。這非常簡單。

首先,我的問題是我最新的 DD 備份檔案完全充滿了 0x00 位元組...

一旦我獲取了包含真實資料的舊備份,事情就變得非常順利。

losetup /dev/loop0 /path/to/snapshot.dd
mount -f ext4 /dev/loop0 /mnt/tmp

完美運作!

相關內容