LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   LVM and LUKS Question (http://www.linuxquestions.org/questions/linux-general-1/lvm-and-luks-question-939537/)

ferdog 04-12-2012 05:41 PM

LVM and LUKS Question
 
I want to make sure that I've correctly configured my system to install Linux on a fully encrypted disk (minus /boot). I'm using LVM on LUKS - both of which I've got very little experience with. Here's what I did:

First, I created two partitions.

Code:

/dev/sda1 (100mb. I'll use this for /boot)
/dev/sda2 (Rest of disk. This is the LVM Container)

I then encrypted /dev/sda2:

Code:

cryptsetup -c aes-xts-plain -y -s 512 luksFormat /dev/sda2
I opened the LUKS partition:

Code:

cryptsetup luksOpen /dev/sda2 container
So, now I have:

Code:

/dev/mapper/container
I setup my logical volumes:

Code:

pvcreate /dev/mapper/container
vgcreate VolGroup00 /dev/mapper/container
lvcreate -L 20G VolGroup00 -n root
lvcreate -C y -L 10G VolGroup00 -n swap
lvcreate -l +100%FREE VolGroup00 -n home

created filesystems:

Code:

mkfs.ext4 /dev/VolGroup00/root
mkswap /dev/VolGroup00/swap
mkfs.ext4 /dev/VolGroup00/home

and mounted them:
Code:

swapon /dev/VolGroup00/swap
mount /dev/VolGroup00/root /
mount /dev/VolGroup00/home /home

Does this look correct? Did I miss anything?

roger_heslop 04-12-2012 06:53 PM

It looks correct as far as I can tell, however when I set up a LUKS partition, I do it the opposite way. In other words I create the logical volume / use luksFormat to open that logical volume as a seperate device in /dev/mapper, and then format that with ext4 (or whatever).

The important difference is that creating a the encrypted volume on top of the logical volume allows me to initially set the pv properly to type 8e, though your method may allow more flexibility in resizing the volumes. (I've never tested your method though.) I've written a few blog entries on this topic (to include automounting LUKS) here:

http://thehomelab.blogspot.com/

Edit: Both methods should work, see discussion here:
https://bbs.archlinux.org/viewtopic.php?id=87897

ferdog 04-13-2012 01:31 PM

Thanks for your advice and the links, Roger. Your blog is a helpful resource for someone new to LUKS such as myself.


All times are GMT -5. The time now is 04:54 AM.