[virt-tools-list] e2fsck an encrypted LVM root partition within a virtual machine

Keith Roberts keith.roberts at ecric.nhs.uk
Thu Aug 13 15:24:00 UTC 2015

On 31 Jul 2015, at 12:15, Richard W.M. Jones <rjones at redhat.com> wrote:

> On Wed, Jul 29, 2015 at 01:12:11PM +0100, Keith Roberts wrote:
>>> <rescue> cryptsetup open /dev/sda2 sysroot
>> Enter passphrase for /dev/sda2: 
>> [  355.726880] device-mapper: table: 253:0: crypt: unknown target type
>> [  355.727799] device-mapper: ioctl: error adding target to table
>> device-mapper: reload ioctl on temporary-cryptsetup-148 failed: Invalid argument
>> Failed to open temporary keystore device.
>> device-mapper: remove ioctl on temporary-cryptsetup-148 failed: No such device or address
>> ...
>>> <rescue> 
>> Any ideas why I cannot open the LUKS encrypted partition please?
> It's a good question.  The error seems to indicate that the
> dm-crypt.ko kernel module is not loaded, so I guess you could try
> 'modprobe dm-crypt' before the cryptsetup command.  (Also check your
> *host* kernel supports dm-crypt).

Hi Rich.

That was on an openSUSE 13.1 box using the default guestfs-tools package.

However on an openSUSE 12.3 box with the 3rd party OBS repo installed all went well.

# unlock the encrypted root partition
><rescue> cryptsetup luksOpen /dev/sda2 luksdev
Enter passphrase for /dev/sda2:
[  901.852083] bio: create slab <bio-1> at 1
[  906.679106] bio: create slab <bio-1> at 1
# scan for all volume groups on encrypted LVM device
><rescue> lvm vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "system" using metadata type lvm2
# list logical volumes found
><rescue> lvm lvs
  LV   VG     Attr      LSize Pool Origin Data%  Move Log Copy%
  root system -wi------ 8.53g
  swap system -wi------ 1.31g
# activate the root LV so we can e2fsck it:

><rescue> lvm lvchange -ay /dev/system/root
We can now see that /dev/system/root is marked as active
with the -wi-a---- attribute:
><rescue> lvm lvs
  LV   VG     Attr      LSize Pool Origin Data%  Move Log Copy%
  root system -wi-a---- 8.53g
  swap system -wi------ 1.31g
Once the LV for /dev/system/root has been activated, we can then
run a filesystem check using e2fsck:
><rescue> e2fsck -vfy -C0 /dev/system/root
e2fsck 1.42.6 (21-Sep-2012)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
So I’m using that 12.3 box for fixing VM filesystems until I get the other issue on 13.1 sorted out.

Kind Regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20150813/745cd53e/attachment.htm>

More information about the virt-tools-list mailing list