How to Mount an Encrypted LVM Partition

root@ubuntu:~# fdisk -l
Disk /dev/sda: 128.0 GB, 128035676160 bytes
255 heads, 63 sectors/track, 15566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a735a
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          61      487424   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              61       15567   124546048   83  Linux
root@ubuntu:~# ls /dev/mapper/
root@ubuntu:~# cryptsetup luksOpen /dev/sda2 encrypted-partition
Enter passphrase for /dev/sda2: 
Key slot 0 unlocked.
root@ubuntu:~# ls /dev/mapper/
control  encrypted-partition
root@ubuntu:~# mkdir /mnt/encrypted-partition
root@ubuntu:~# mount /dev/mapper/encrypted-partition /mnt/encrypted-partition/
mount: unknown filesystem type 'LVM2_member'
root@ubuntu:~# apt-get install lvm2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libdevmapper-event1.02.1 watershed
The following NEW packages will be installed:
  libdevmapper-event1.02.1 lvm2 watershed
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 447kB of archives.
After this operation, 1,282kB of additional disk space will be used.
Do you want to continue [Y/n]? y
root@ubuntu:~# sudo /sbin/modprobe dm-mod
root@ubuntu:~# /sbin/lsmod | grep dm_crypt
dm_crypt               11331  1 
root@ubuntu:~# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "system" using metadata type lvm2
root@ubuntu:~# vgchange -ay system
  3 logical volume(s) in volume group "system" now active
root@ubuntu:~# lvs
  LV   VG     Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  root system -wi-ao 113.19g                                      
  swap system -wi-a-   2.79g                                      
  tmp  system -wi-a-   2.79g                                      
root@ubuntu:~# ls /dev/mapper/
control  encrypted-partition  system-root  system-swap  system-tmp
root@ubuntu:~# mount /dev/mapper/system-root /mnt/encrypted-partition/
root@ubuntu:~# ls /mnt/encrypted-partition/
bin   etc         initrd.img.old  lost+found  opt   sbin     sys  var
boot  home        lib             media       proc  selinux  tmp  vmlinuz
dev   initrd.img  lib64           mnt         root  srv      usr  vmlinuz.old


root@ubuntu:~# umount /mnt/system-root 
root@ubuntu:~# cryptsetup remove encrypted-partition


2 thoughts on “How to Mount an Encrypted LVM Partition”

Leave a Reply

Your email address will not be published. Required fields are marked *