0

I'm having some trouble restoring a back-up I made of a encrypted filesystem. The back-up is a .img file containing a single disc partition. This partition is a luks container in which a logical volume group 'vg-crypt' resides. Within this volume group I have two logical volumes, lv-crypt-root and lv-crypt-swap.

In my new Ubuntu install I proceed as following

cryptsetup luksOpen /media/lars/SHD/disk.img backup

pasword.... and to check if the logical volumegroup is recognised I type:

pvs

which tells me:

  PV                 VG      Fmt  Attr PSize   PFree  
/dev/mapper/backup vgcrypt lvm2 a--  151,11g 196,00m
/dev/mapper/tphd   vgtphd  lvm2 a--  151,11g 116,00m

so far so good, my current root volume (tphd or vgtphd) is recognised as well as my backup vg (backup or vgcrypt) Now lets check out the lv's in the backup volume:

lvdisplay /dev/vgcrypt

...

      --- Logical volume ---
  LV Path                /dev/vgcrypt/lv-crypt-root
  LV Name                lv-crypt-root
  VG Name                vgcrypt
  LV UUID                Nc4vsK-IcqB-l2S1-iyIJ-rSOj-vzqt-osGcn5
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2013-06-19 10:40:44 +0200
  LV Status              suspended
  # open                 0
  LV Size                147,12 GiB
  Current LE             37663
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:5

  --- Logical volume ---
  LV Path                /dev/vgcrypt/lv-crypt-swap
  LV Name                lv-crypt-swap
  VG Name                vgcrypt
  LV UUID                ExEizv-aHCn-ZG1Q-nqj5-jSQE-NKYG-2RKyVb
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2013-06-19 10:41:14 +0200
  LV Status              suspended
  # open                 0
  LV Size                3,80 GiB
  Current LE             973
 ..... bla bla

conclusion, lv is recognized.

This is where the problems start, I try to mount the lv:

mount /dev/vgcrypt/lv-crypt-root /mnt/lvm/

gives me

mount: special device /dev/vgcrypt/lv-crypt-root does not exist

when making sure it is active by:

vgchange -ay /dev/vgcrypt

I got this:

  device-mapper: resume ioctl on  failed: Invalid argument
  Unable to resume vgcrypt-lv--crypt--root (252:5)
  device-mapper: resume ioctl on  failed: Invalid argument
  Unable to resume vgcrypt-lv--crypt--swap (252:6)
  2 logical volume(s) in volume group "vgcrypt" now active

I got pretty much no idea what that means so I start googling and find that maybe I should export the inactivated vg with vgexport so:

vgchange -an /dev/vgcrypt
  Attempted to decrement suspended device counter below zero.
  Attempted to decrement suspended device counter below zero.
  0 logical volume(s) in volume group "vgcrypt" now active

and

vgexport vgcrypt
  Volume group "vgcrypt" has active logical volumes

seems pretty paradoxical to me.

Can anyone point me in the right direction? Any help would be greatly appreciated :)

P.S. just checked the syslog, seems relevant but doesn't make much sense to me:

(filtered al the wifi info out:)

cat /var/log/syslog | grep kernel | grep -v wlan | grep -v cfg80211 | tail -n 40 | cut -f 5-90 -d " "

kernel: [58297.025013] device-mapper: table: 252:8: linear: dm-linear: Device lookup failed
kernel: [58297.025023] device-mapper: ioctl: error adding target to table
kernel: [58297.026024] device-mapper: table: 252:8: linear: dm-linear: Device lookup failed
kernel: [58297.026030] device-mapper: ioctl: error adding target to table
kernel: [58297.026901] device-mapper: table: 252:8: linear: dm-linear: Device lookup failed
kernel: [58297.026907] device-mapper: ioctl: error adding target to table
kernel: [58297.077530] device-mapper: multipath: version 1.5.1 loaded
kernel: [59654.867358] device-mapper: table: 252:5: dm-7 too small for target: start=2048, len=308535296, dev_size=284453912
kernel: [59654.867994] device-mapper: table: 252:6: dm-7 too small for target: start=308537344, len=7970816, dev_size=284453912
kernel: [59655.179856] device-mapper: table: 252:5: dm-7 too small for target: start=2048, len=308535296, dev_size=284453912
kernel: [59655.180623] device-mapper: table: 252:6: dm-7 too small for target: start=308537344, len=7970816, dev_size=284453912
kernel: [59776.851223] device-mapper: table: 252:5: dm-7 too small for target: start=2048, len=308535296, dev_size=284453912
kernel: [59776.851860] device-mapper: table: 252:6: dm-7 too small for target: start=308537344, len=7970816, dev_size=284453912
kernel: [59777.149049] device-mapper: table: 252:5: dm-7 too small for target: start=2048, len=308535296, dev_size=284453912
kernel: [59777.149561] device-mapper: table: 252:6: dm-7 too small for target: start=308537344, len=7970816, dev_size=284453912
kernel: [60837.153424] device-mapper: table: 252:5: dm-7 too small for target: start=2048, len=308535296, dev_size=284453912
kernel: [60837.154789] device-mapper: table: 252:6: dm-7 too small for target: start=308537344, len=7970816, dev_size=284453912
kernel: [61508.827915] device-mapper: table: 252:5: dm-7 too small for target: start=2048, len=308535296, dev_size=284453912
kernel: [61508.831243] device-mapper: table: 252:6: dm-7 too small for target: start=308537344, len=7970816, dev_size=284453912
kernel: [61514.020906] device-mapper: table: 252:5: dm-7 too small for target: start=2048, len=308535296, dev_size=284453912
kernel: [61514.021532] device-mapper: table: 252:6: dm-7 too small for target: start=308537344, len=7970816, dev_size=284453912
kernel: [61514.311394] device-mapper: table: 252:5: dm-7 too small for target: start=2048, len=308535296, dev_size=284453912
kernel: [61514.311906] device-mapper: table: 252:6: dm-7 too small for target: start=308537344, len=7970816, dev_size=284453912

2 Answers 2

1

LVM is not opening your LVs, this is already apparent in the lvdisplay output (suspended). The device-mapper syslog output has some additional detail: two devices couldn't be activated because one of their components was missing; two others couldn't be activated because the backing device is too small. The later messages have device numbers that match the failed vgchange.

I'm guessing that your backup image is truncated.

To get more info:

sudo vgchange --refresh
sudo pvs --partial --verbose
sudo lvs --partial --segments -o+devices vgcrypt/lv-crypt-root
sudo blockdev --getsize64 /dev/mapper/backup
sudo pvdisplay --units=b /dev/mapper/backup

The first command forces a reread of the VG metadata that's stored on your PVs, the second lists all PVs including any missing ones, the third gives more detailed info about your LV and where the data is located. The last two compare the expected and actual size of your PV.

1

I fix this problem with those steps:

  • check the size (parted) of the physical partition (ie. /dev/sda5) is smaller than the lvm Physical volume (PV) (pvscan)
  • disable lvm pvchange -an
  • with fdisk -l, write down the starting block for each partition
  • with fdisk delete the partition (ie. /dev/sda5) and write changes
  • with fdisk create a new partition of the same type (primary, logical)starting exactly from the same block than the previous one and a ending block farther than previously (if you can the entire disk after it), then change type to Linux LVM (8e), write changes to disk
  • check size as step 1
  • enable lvm pvchange -ay

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .