LUKS encryption for multiple internal hard drives

Having fun again. Purchased a new PC from TradeMe, had a internal 80Gb SSD (boot device) plus two 80GB hard drives. A few other things like 6Gb of memory, bargain for $270 really. But them I bid on the machines with no OS provided because they always go for less.

Anyway, the disks were my issue… not really an issue but I had to wake up long dead brain cells.

So this is just another post to remind me of what I need to do when playing with disks (not nearly as interesting reading as the one where I was resizing/shrinking/fdisk partition size overwrites on a running system etc while moving physical disk partitions around a cluster of bad sectors on a disk (got another two years from that disk) but I had trouble remembering this stuff (obviously it’s not done a lot at home).

Did the normal Fedora install, unencrypted /boot ( as thats not supported :-) ) with the rest of the boot disk (sda2) encypted where all the LVMs live. No probs there.

Getting the other two disks into use really had to fire up those dead brain cells.

Making those two disks LUKS encrypted disks (sdb1 and sdc1) was easy enough, although I had to delete some windows raid header information from one (thanks google for the dm command for that).

Getting them to automount from crypttab at boot was my main concern, I investigated keyscripts etc but then though lets start at the basics and just let all three disks prompt for a password at boot.
And… yippee, dunno if it’s a bug or not but if all three disks have the same encryption password all three disk entries in crypttab get unlocked by a single password prompt needed for the boot disk at boot time (F17 anyway). I’m happy with that.

Then of course I had to add the mapped (unencypted device definitions created by cryptsetup in /dev/mapper) physical disks to LVM with pvcreate (easy), add them into seperate volume groups (vgcreate) (decided on seperate volume groups as I’m not going to mirror them at this time) and create a new logical volume (lvcreate, mkfs) for home using all of one of them and fiddle about with copying files and moving mountpoints and selinux relabeling etc. but that was done ok.

Then I deleted the old lv_home logical volume from the ssd and used lvextend to expand lv_root to the entire free space on that disk, which worked ok but the filesystem size didn’t grow… which is where the old brain cells needed to fire up, and read one of my old blog posts (to shrink not expand, but same operation)… resize2fs to resize a filesystem when the underlying structure has changed.
Which is the main reason for this blog post, my prior posts remind me of how I did things in the past and I will probably refer to this one again.

So now I have an encrypted disk for the OS, another for home, and a third sitting there encrypted and available (in a pv and vg) if I need it.

Might have a post about software raid in the future as I might mirror the disk used for the home filesystem onto that third disk. Or I might not.

About mark

At work, been working on Tandems for around 30yrs (programming + sysadmin), plus AIX and Solaris sysadmin also thrown in during the last 20yrs; also about 5yrs on MVS (mainly operations and automation but also smp/e work). At home I have been using linux for decades. Programming background is commercially in TAL/COBOL/SCOBOL/C(Tandem); 370 assembler(MVS); C, perl and shell scripting in *nix; and Microsoft Macro Assembler(windows).
This entry was posted in Unix. Bookmark the permalink.