Score:0

Mount DD image of LVM partition

in flag

I am in a conundrum. I need to extract data from a backup image I created previously. I thought I knew enough about LVM to get by... at least until now.

It seems my blunder is that I backed up an LVM snapshot volume rather than the whole volume group or disk partition. Most articles I've read imply that you've backed up the entire disk.

Here is my LVM layout:

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]

Here is my backup command:

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

I've mounted the DD file as /dev/loop0 on another machine.

Here is what I get:

# 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.

Any idea how I might go about mounting this snapshot to retrieve data from it?

Score:1
in flag

Figured it out. It's super simple.

First off, my problem was that my latest DD backup file was entirely full of 0x00 bytes...

Once I grabbed an older backup that contained real data, things went very smoothly.

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

Works perfectly!

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.