[HOWTO] mount encrypted LVM partitions for service

Here you'll find a place for solutions and hints.

Please use one of the support subforums below for questions or if you have any issues and need support.

[HOWTO] mount encrypted LVM partitions for service

Postby morgano » Jan 11th, '13, 01:19

Caused by immediate need i now learned how to mount my partitions hidden in an encrypted LVM
(my fstab got borked so the machine could not boot)

You need to boot on a competent live disk, i used http://www.sysresccd.org/ started it in graphical mode for convenience, and so can we use Gparted to see partitions, text editor for notes like this, file manager, and work in a terminal. Enough talk, you should always have such tool available on CD or USB stick! Another tip is to always have a nother computer nearby to search internet for help. sysressc.org also have good documents on site.

Here is a log of what I did: ( based on http://forums.fedoraforum.org/showpost.php?p=1599223 )
§ booted sysresccd, graphical mode, go to graphical terminal, and:
§ put in a USB stick for making backup and this document
root@sysresccd /root % ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sda5 /dev/sdb /dev/sdb1
root@sysresccd /root % mount /dev/sdb1 /mnt/backup
§ Used GParted to see it is sda5 that is encrypted, decided to decrypt it under name "krypterad"
root@sysresccd /root % cryptsetup luksOpen /dev/sda5 krypterad
Enter passphrase for /dev/sda5:
root@sysresccd /root % pvscan
PV /dev/mapper/krypterad VG vg-mga lvm2 [58.58 GiB / 14.31 GiB free]
Total: 1 [58.58 GiB] / in use: 1 [58.58 GiB] / in no VG: 0 [0 ]
root@sysresccd /root % vgscan
Reading all physical volumes. This may take a while...
Found volume group "vg-mga" using metadata type lvm2
root@sysresccd /root % lvscan
inactive '/dev/vg-mga/root' [10.95 GiB] inherit
inactive '/dev/vg-mga/swap' [3.91 GiB] inherit
inactive '/dev/vg-mga/home' [29.41 GiB] inherit
root@sysresccd /root % vgchange -ay
3 logical volume(s) in volume group "vg-mga" now active
§ Nice, all 3 LVM volumes in encrypted partition are OK
mounting the root partition, can be done from two locations:
rroot@sysresccd /root % dir /dev/vg-mga/
home root swap
root@sysresccd /root % dir /dev/mapper/
control krypterad vg--mga-home vg--mga-root vg--mga-swap
root@sysresccd /root % mkdir /mnt/vg-mga_root
root@sysresccd /root % mount /dev/vg-mga/root /mnt/vg-mga_root
root@sysresccd /root % cd /mnt/vg-mga_root
root@sysresccd /mnt/vg-mga_root % ls
bin dead.letter etc initrd lib64 media opt root sbin sys usr
boot dev home lib lost+found mnt proc run srv tmp var
§ working on it (e.g. repairing fstab), then
# sync
# reboot


__Variants

Here is a copy from a terminal when I repaired the root filesystem in an encrypted LVM; unlocking encryption, activating LVM, running e2fsck.

All above is for one encrypted physical partition containing a LVM, that holds the partitions you want.

If you have a LVM that is not encrypted, you only have to boot and you find your partitions as /dev/vg-* so just create mount point in /mnt and mount.

If you have encrypted partition without LVM, do the luksOpen and then (i think) look in /dev/ or /dev/mapper/ for something to mount

If you have encrypted partitions in LVM, you need to luksOpen each one you want.
At home & work Mandriva since 2006, Mageia 2011. Thinkpad T40, T43, T60, T400, T510, Dell M4400, M6300, Acer Aspire 7. Workstation using LVM, LUKS, VirtualBox, BOINC
morgano
 
Posts: 1488
Joined: Jun 15th, '11, 17:51
Location: Kivik, Sweden

Return to The magician suggests...

Who is online

Users browsing this forum: No registered users and 1 guest

cron