[virt-tools-list] e2fsck an encrypted LVM root partition within a virtual machine
Keith Roberts
keith.roberts at ecric.nhs.uk
Wed Jul 29 12:12:11 UTC 2015
On 29 Jul 2015, at 12:18, Keith Roberts <keith.roberts at ecric.nhs.uk> wrote:
> Hi all.
>
> I have a virtual machine with an encrypted LVM root partition that has some fsck errors.
>
> Is there any way I can use virt-rescue to fix the errors on the encrypted LVM partition please?
>
> I found this post, but it does not mention fixing the LVM partition inside of a virtual machine.
>
> http://serverfault.com/questions/375090/using-fsck-to-check-and-repair-luks-encrypted-disk
>
> Kind Regards,
>
> Keith Roberts
I have made some progress with this now:
The volume I need to fsck:
# lvm lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
root system -wi-ao--- 8.53g
swap system -wi-ao--- 1.31g
# lvdisplay -v /dev/system/root
Using logical volume(s) on command line
--- Logical volume ---
LV Path /dev/system/root
LV Name root
VG Name system
LV UUID xyAkG1-24Zu-tP7k-3eEc-Q8mN-d2ke-6QklGK
LV Write Access read/write
LV Creation host, time linux, 2013-11-07 14:38:34 +0000
LV Status available
# open 1
LV Size 8.53 GiB
Current LE 2184
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 1024
Block device 253:1
>From inside the running VM:
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/system-root 8.3G 2.0G 5.9G 25% /
devtmpfs 362M 32K 362M 1% /dev
tmpfs 393M 0 393M 0% /dev/shm
tmpfs 393M 25M 369M 7% /run
tmpfs 393M 0 393M 0% /sys/fs/cgroup
tmpfs 393M 25M 369M 7% /var/lock
tmpfs 393M 25M 369M 7% /var/run
/dev/xvda1 148M 43M 94M 32% /boot
So now I start virt-rescue on the VM domain file:
# ls
xvda
# virt-rescue -a ./xvda
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
...
[ 8.292332] scsi0 : Virtio SCSI HBA
[ 8.310917] scsi 0:0:0:0: Direct-Access QEMU QEMU HARDDISK 1.6. PQ: 0 ANSI: 5
[ 8.327277] sd 0:0:0:0: [sda] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
[ 8.330556] sd 0:0:0:0: [sda] Write Protect is off
[ 8.331910] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 8.557825] sda: sda1 sda2
[ 8.611387] sd 0:0:0:0: [sda] Attached SCSI disk
Cannot find device "eth0"
Cannot find device "eth0"
RTNETLINK answers: Network is unreachable
mdadm: No arrays found in config file or automatically
No volume groups found
No volume groups found
------------------------------------------------------------
Welcome to virt-rescue, the libguestfs rescue shell.
Note: The contents of / are the rescue appliance.
You have to mount the guest's partitions under /sysroot
before you can examine them. A helper script for that exists:
mount-rootfs-and-do-chroot.sh /dev/sda2
><rescue> e2fsck /dev/sda1
e2fsck 1.42.8 (20-Jun-2013)
/dev/sda1: clean, 88/40000 files, 52691/159744 blocks
><rescue>
><rescue> mount-rootfs-and-do-chroot.sh /dev/sda2
mount: unknown filesystem type 'crypto_LUKS'
><rescue>
><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?
Kind Regards,
Keith
More information about the virt-tools-list
mailing list