LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   question about LVM with a DD image from full disk? (https://www.linuxquestions.org/questions/linux-general-1/question-about-lvm-with-a-dd-image-from-full-disk-4175543442/)

lleb 05-23-2015 10:38 PM

question about LVM with a DD image from full disk?
 
I made a full disk backup using dd earlier today on an Ubuntu LTS 14.04 system running a LVM partition.

I am able to mount the .img file and see the /boot but im unable to get to the LVM, then when I attempt the following:

Code:

[root@jackknife ~]# fdisk -lu /exports/backup/BOAT/BOAT.img

Disk /exports/backup/BOAT/BOAT.img: 120.0 GB, 120034123776 bytes, 234441648 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 label type: dos
Disk identifier: 0x000a2421

                        Device Boot      Start        End      Blocks  Id  System
/exports/backup/BOAT/BOAT.img1  *        2048      499711      248832  83  Linux
/exports/backup/BOAT/BOAT.img2          501758  234440703  116969473    5  Extended
/exports/backup/BOAT/BOAT.img5          501760  234440703  116969472  8e  Linux LVM
[root@jackknife ~]# kpartx -av /exports/backup/BOAT/BOAT.img
[root@jackknife ~]# umount /mnt/old/
[root@jackknife ~]# mount -o loop,offset=256901120 /exports/backup/BOAT/BOAT.img /mnt/old/
mount: unknown filesystem type 'LVM2_member'

Im sure there is just something simple I'm missing.

Code:

[root@jackknife ~]# mount -o loop,offset=1048576 /exports/backup/BOAT/BOAT.img /mnt/old/
[root@jackknife ~]# d /mnt/old/
total 62298
drwxr-xr-x. 4 root root    1024 May 18 18:43 ./
drwxr-xr-x. 5 root root      37 Apr 19 16:15 ../
-rw-r--r--. 1 root root  1207386 Jan 15 13:22 abi-3.16.0-30-generic
-rw-r--r--. 1 root root  1206938 May  6 12:22 abi-3.16.0-37-generic
-rw-r--r--. 1 root root  171768 Jan 15 13:22 config-3.16.0-30-generic
-rw-r--r--. 1 root root  171816 May  6 12:22 config-3.16.0-37-generic
drwxr-xr-x. 5 root root    1024 May 18 18:43 grub/
-rw-r--r--. 1 root root 20246540 May 18 15:46 initrd.img-3.16.0-30-generic
-rw-r--r--. 1 root root 20249911 May 18 18:43 initrd.img-3.16.0-37-generic
drwx------. 2 root root    12288 May 18 15:15 lost+found/
-rw-r--r--. 1 root root  176500 Mar 12  2014 memtest86+.bin
-rw-r--r--. 1 root root  178176 Mar 12  2014 memtest86+.elf
-rw-r--r--. 1 root root  178680 Mar 12  2014 memtest86+_multiboot.bin
-rw-------. 1 root root  3511040 Jan 15 13:22 System.map-3.16.0-30-generic
-rw-------. 1 root root  3512899 May  6 12:22 System.map-3.16.0-37-generic
-rw-r--r--. 1 root root  6345120 May 18 15:17 vmlinuz-3.16.0-30-generic
-rw-------. 1 root root  6352688 May  6 12:22 vmlinuz-3.16.0-37-generic

so i can mount it, just can not gain access to the LVM partition. this is were my data resides. help is greatly appreciated in advance. Thank you.

syg00 05-23-2015 11:29 PM

You can only mount filesystems, not (block) devices. Attempting to mount the "LVM Member" is akin to trying to mount /dev/sda (when /dev/sda has partitions).
I imagine vgscan should find your vg(s) - then you'd have to activate it/them with vgchange then mount them. Remember to reverse it all when finished.

Another reason to add to my long list of not advocating image backups.

rknichols 05-24-2015 12:00 AM

Since your image will contain an LVM structure identical to the one you copied it from, you cannot have both the original and the copy connected to the system at the same time. They have the same VG and LV names, and the same PV, VG, and LV UUIDs. When accessing an LV, the system will randomly select one or the other. With the system already up and running, connecting the other disk won't cause confusion; you just won't be able to access it. Should you be so unfortunate as to boot with both copies connected, you would need to run "pvs" to see which physical volumes were actually in use.

lleb 05-24-2015 09:03 AM

after mounting as the successful way in the first post, neither vgscan or pvscan detect the LVM on the .img mounted system.

no the LCM structure is not identical as it is not from the live system, it is from an external HDD, has nothing to do with it.

veerain 05-24-2015 09:25 AM

Instead of using offset with loop device you can with recent util-inux create multiple block devices for each partition and then mount fs or use for other purposes.

See this link.

michaelk 05-24-2015 09:37 AM

As stated you can not mount a volume group image the same way as you mount a regular partition image. Check out the links before. Your setting up the loop device to the LVM partition then mounting the volume group.

http://www.utilities-online.info/art.../#.VWHedGGQlpU
http://forensicswiki.org/wiki/Linux_..._from_an_image

rknichols 05-24-2015 10:14 AM

Quote:

Originally Posted by lleb (Post 5366743)
no the LCM structure is not identical as it is not from the live system, it is from an external HDD, has nothing to do with it.

OK, good.

Your original post showed no output from the "kpartx -av /exports/backup/BOAT/BOAT.img" command. With that "-v" option, I would expect to see output like
Code:

add map loop0p1 (253:3): 0 6848224 linear /dev/loop0 32
add map loop0p2 (253:4): 0 1048832 linear /dev/loop0 6848256

and those "loop?p?" block devices are what pvscan should be examining and finding the LVM structure. Did no loop devices show up in /dev/mapper after that kpartx command? That sounds like the key to the problem.

lleb 05-24-2015 10:59 AM

Quote:

Originally Posted by rknichols (Post 5366769)
OK, good.

Your original post showed no output from the "kpartx -av /exports/backup/BOAT/BOAT.img" command. With that "-v" option, I would expect to see output like
Code:

add map loop0p1 (253:3): 0 6848224 linear /dev/loop0 32
add map loop0p2 (253:4): 0 1048832 linear /dev/loop0 6848256

and those "loop?p?" block devices are what pvscan should be examining and finding the LVM structure. Did no loop devices show up in /dev/mapper after that kpartx command? That sounds like the key to the problem.

running the kpartx -av did the trick. that allowed pvscan to detect the LVM i was missing earlier. now i should be able to access, ill report back with progress:

Code:

[root@jackknife ~]# kpartx -av /exports/backup/BOAT/BOAT.img
add map loop1p1 (253:3): 0 497664 linear /dev/loop1 2048
add map loop1p2 (253:4): 0 2 linear /dev/loop1 501758
add map loop1p5 (253:5): 0 233938944 linear /dev/loop1 501760
[root@jackknife ~]# df -Th
Filesystem    Type      Size  Used Avail Use% Mounted on
/dev/md127    xfs        20G  14G  6.0G  70% /
devtmpfs      devtmpfs  7.7G    0  7.7G  0% /dev
tmpfs          tmpfs    7.8G  4.0K  7.8G  1% /dev/shm
tmpfs          tmpfs    7.8G  17M  7.7G  1% /run
tmpfs          tmpfs    7.8G    0  7.8G  0% /sys/fs/cgroup
/dev/sda2      xfs      506M  262M  245M  52% /boot
/dev/md126    xfs        30G  21G  9.0G  70% /home
/dev/md125    xfs        11T  7.4T  3.6T  68% /exports
/dev/loop0    udf      4.4G  4.4G    0 100% /mnt/ISO
[root@jackknife ~]# pvscan
  PV /dev/mapper/loop1p5  VG ubuntu-vg          lvm2 [111.55 GiB / 0    free]
  PV /dev/sda5            VG centos_jackknife  lvm2 [332.00 MiB / 0    free]
  PV /dev/sdb3            VG centos_jackknife  lvm2 [332.00 MiB / 0    free]
  PV /dev/sdc3            VG centos_jackknife  lvm2 [332.00 MiB / 0    free]
  PV /dev/sdd3            VG centos_jackknife  lvm2 [332.00 MiB / 0    free]
  PV /dev/sde3            VG centos_jackknife  lvm2 [332.00 MiB / 0    free]
  PV /dev/sdf3            VG centos_jackknife  lvm2 [332.00 MiB / 0    free]
  Total: 7 [113.49 GiB] / in use: 7 [113.49 GiB] / in no VG: 0 [0  ]


lleb 05-24-2015 11:18 AM

so im doing something horridly wrong:

Code:

[root@jackknife ~]# mount /dev/mapper/loop1p5 /mnt/home/
mount: unknown filesystem type 'LVM2_member'
[root@jackknife ~]# kpartx -av /exports/backup/BOAT/BOAT.img
add map loop1p1 (253:3): 0 497664 linear /dev/loop1 2048
add map loop1p2 (253:4): 0 2 linear /dev/loop1 501758
add map loop1p5 (253:5): 0 233938944 linear /dev/loop1 501760
[root@jackknife ~]# pvscan
  PV /dev/mapper/loop1p5  VG ubuntu-vg          lvm2 [111.55 GiB / 0    free]
  PV /dev/sda5            VG centos_jackknife  lvm2 [332.00 MiB / 0    free]
  PV /dev/sdb3            VG centos_jackknife  lvm2 [332.00 MiB / 0    free]
  PV /dev/sdc3            VG centos_jackknife  lvm2 [332.00 MiB / 0    free]
  PV /dev/sdd3            VG centos_jackknife  lvm2 [332.00 MiB / 0    free]
  PV /dev/sde3            VG centos_jackknife  lvm2 [332.00 MiB / 0    free]
  PV /dev/sdf3            VG centos_jackknife  lvm2 [332.00 MiB / 0    free]
  Total: 7 [113.49 GiB] / in use: 7 [113.49 GiB] / in no VG: 0 [0  ]
[root@jackknife ~]# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "ubuntu-vg" using metadata type lvm2
  Found volume group "centos_jackknife" using metadata type lvm2
[root@jackknife ~]# mount -t ext3 /dev/mapper/loop1p5 /mnt/home/
mount: /dev/mapper/loop1p5 is already mounted or /mnt/home busy
[root@jackknife ~]# d /mnt/home/
total 0
drwxr-xr-x. 2 root root  6 Dec 17 07:55 ./
drwxr-xr-x. 5 root root 37 Apr 19 16:15 ../
[root@jackknife ~]# cd /dev/mapper/loop1p5
-bash: cd: /dev/mapper/loop1p5: Not a directory
[root@jackknife ~]# d /dev/mapper/loop1p5
lrwxrwxrwx. 1 root root 7 May 24 12:14 /dev/mapper/loop1p5 -> ../dm-5
[root@jackknife ~]# d /dm-t
/bin/ls: cannot access /dm-t: No such file or directory

how can i access the LVM partition from the .img file if i do not mount the .img?

FYI, my system is CentOS v7, yes it an Ubuntu system I'm attempting to gain access to. I know the Ubuntu does some strange stuff with their LVM's is that the problem?

lleb 05-24-2015 11:23 AM

nm, im a total idiot. i was mounting the wrong LVM on the .img:

Code:

[root@jackknife ~]# lvmdiskscan /mnt/old/
  /dev/loop0                [      4.36 GiB]
  /dev/centos_jackknife/swap [      1.95 GiB]
  /dev/loop1                [    111.79 GiB]
  /dev/ubuntu-vg/root        [    103.66 GiB]
  /dev/sda2                  [    512.00 MiB]
  /dev/ubuntu-vg/swap_1      [      7.89 GiB]
  /dev/mapper/loop1p1        [    243.00 MiB]
  /dev/sda5                  [    333.00 MiB] LVM physical volume
  /dev/mapper/loop1p5        [    111.55 GiB] LVM physical volume
  /dev/sdb3                  [    333.00 MiB] LVM physical volume
  /dev/sdc3                  [    333.00 MiB] LVM physical volume
  /dev/sdd3                  [    333.00 MiB] LVM physical volume
  /dev/sde3                  [    333.00 MiB] LVM physical volume
  /dev/sdf3                  [    333.00 MiB] LVM physical volume
  /dev/sdh                  [      1.91 GiB]
  /dev/md125                [      10.86 TiB]
  /dev/md126                [      29.34 GiB]
  /dev/md127                [      19.57 GiB]
  3 disks
  8 partitions
  0 LVM physical volume whole disks
  7 LVM physical volumes
[root@jackknife ~]# lvdisplay /mnt/old/
  "/mnt/old/": Invalid path for Logical Volume.
[root@jackknife ~]# lvdisplay ubuntu-vg
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/root
  LV Name                root
  VG Name                ubuntu-vg
  LV UUID                0vyHeH-W7Xs-QadH-evLz-cp1s-nsmO-G2AUS5
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2015-05-18 15:15:07 -0400
  LV Status              available
  # open                0
  LV Size                103.66 GiB
  Current LE            26536
  Segments              1
  Allocation            inherit
  Read ahead sectors    auto
  - currently set to    256
  Block device          253:1

  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/swap_1
  LV Name                swap_1
  VG Name                ubuntu-vg
  LV UUID                9w32hF-Rd4v-02W3-wGn1-9P1W-L0W1-cUzJzO
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2015-05-18 15:15:07 -0400
  LV Status              available
  # open                0
  LV Size                7.89 GiB
  Current LE            2020
  Segments              1
  Allocation            inherit
  Read ahead sectors    auto
  - currently set to    256
  Block device          253:2

[root@jackknife ~]# lvscan
  ACTIVE            '/dev/ubuntu-vg/root' [103.66 GiB] inherit
  ACTIVE            '/dev/ubuntu-vg/swap_1' [7.89 GiB] inherit
  ACTIVE            '/dev/centos_jackknife/swap' [1.95 GiB] inherit
[root@jackknife ~]# mount /dev/ubuntu-vg/root /mnt/home/

Success... marking post as such. Thanks for pointing me in the right direction.


All times are GMT -5. The time now is 10:00 PM.