Move /home to a new HDD encrypt it with luks

2

as I'm getting more into linux, I'd like to make a few changes to my setup which seem pretty advanced to me.

But first of all let me explain my setup so you know with what you are dealing with.

This is a Lenovo T430s with a 500GB HDD and an additional 128GB mSATA crucial M4 SSD. I'm currently running Fedora 19 and I chose to encrypt the whole SSD during the inital setup of Fedora. Fedora used 60GB as luks encrypted /home partition which isn't that much after a while.

If I use a lsblk right now, it looks like this:

NAME                                          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                                             8:0    0 465,8G  0 disk  
└─sda1                                          8:1    0 465,8G  0 part  /mnt/newhome
sdb                                             8:16   0 119,2G  0 disk  
├─sdb1                                          8:17   0   200M  0 part  /boot/efi
├─sdb2                                          8:18   0   500M  0 part  /boot
└─sdb3                                          8:19   0 118,6G  0 part  
  └─luks-32ead9fa-03af-46a6-9503-a9426ab00d86 253:0    0 118,6G  0 crypt 
    ├─fedora_klinkpad-swap                    253:1    0   7,8G  0 lvm   [SWAP]
    ├─fedora_klinkpad-root                    253:2    0    50G  0 lvm   /
    └─fedora_klinkpad-home                    253:3    0  60,8G  0 lvm   /home
sr0 

    

So I'd like to move the /home partition from /dev/sdb3 to /dev/sda1. That is pretty easy. The rather hard part is that I'd also like to encrypt the HDD as well so that it is getting decrypted together with my SSD during the boot process and correctly mounted as my new /home (I'm guessing fstab is my friend in here). In Addition to that, I'd like to enlarge the root luks encrypted partition by the now freed up 60 GB of my old /home folder as I don't need that anymore.

My questions for you are if this is possible at all, and if it is, how would be the best way to approach this?

Many Thanks in advance!

Stefan

Stefan

Posted 2013-08-08T16:55:28.533

Reputation: 21

Can you do an output of "pvs; vgs; lvs" - You appear to be using LVM, and it would be useful to know how its configured. (Having LVS is good for moving stuff around, it abstracts the partitions from the hard drive, but it does mean stuff is not always where you think it is. – davidgo – 2013-08-10T09:01:01.443

Only a partial answer, but after you have moved /home you can use LVM to remove fedora_klinkpad-home, and then reassign this space to fedora_klinkpad-root, and then resize the filesystem for fedora_klinkpad-root. (man lvremove lvresize and resize2fs or resize4fs if you are using an ext4 filesystem) IT GOES WITHOUT SAYING YOU SHOULD BACK UP BEFORE PLAYING WITH THIS. – davidgo – 2013-08-10T09:06:30.217

Answers

0

Easiest way is:

  1. encrypt sda1 as desired

  2. create lvm or standard partition on sda1 for /home

  3. sudo lvm lvmove /dev/mapper/fedora_klinkpad-home /dev/mapper/{blah|sda1}

  4. with newly freed space run :sudo lvm lvextend /dev/mapper/fedora_klinkpad-root -l+$someamt of the 60 g)

  5. confirm uuids are sane in BOTH /etc/fstab & /etc/crypttab

  6. rebuild the initramfs with sudo update-initramfs -u -k all (optionally recreate all together replaceing -u with -c) followed by sudo update-grub

linuxdev2013

Posted 2013-08-08T16:55:28.533

Reputation: 1 051