Migrating /home to a new encrypted drive
System: Arch Linux with LUKS + LVM
Overview
This guide documents the process of migrating /home from an existing LUKS+LVM setup to a new encrypted drive while maintaining the same security architecture (LVM on LUKS).
System Configuration:
- Arch Linux
- LUKS encryption
- LVM for volume management
- Existing setup:
/dev/sda2โ LUKS โ LVM (root, swap, home) - Goal: Move home to new
/dev/sdb1โ LUKS โ LVM
Prerequisites
- Root access (SSH as root enabled)
- New disk added to VM/system
- Existing data backed up (recommended)
Step 1: Prepare the New Disk
1.1 Verify New Disk
Expected output shows new disk (e.g., /dev/sdb).
1.2 Create Partition
Commands in fdisk:
n- new partitionp- primary1- partition number- Press Enter twice (default start/end)
w- write changes
1.3 Verify Partition
Should show /dev/sdb1.
Step 2: Encrypt with LUKS
2.1 Format with LUKS
- Type
YES(uppercase) to confirm - Enter a strong passphrase
2.2 Open Encrypted Partition
Enter the passphrase you just set.
Step 3: Setup LVM
3.1 Create Physical Volume
3.2 Create Volume Group
3.3 Create Logical Volume
3.4 Format with ext4
Step 4: Copy Data
4.1 Create Mount Points
4.2 Mount Old and New Home
4.3 Copy Data with rsync
Options explained:
-a- archive mode (preserves permissions, timestamps, etc.)-v- verbose-x- don’t cross filesystem boundaries-H- preserve hard links-A- preserve ACLs-X- preserve extended attributes
4.4 Verify Copy
Both should show the same size.
Step 5: Configure Automatic Decryption
5.1 Generate Keyfile
5.2 Secure Keyfile
5.3 Add Keyfile to LUKS
Enter your LUKS passphrase when prompted.
Step 6: Update System Configuration
6.1 Get UUID of Encrypted Partition
Copy the UUID value.
6.2 Update /etc/crypttab
Add this line (replace with your actual UUID):
6.3 Update /etc/fstab
Comment out the old home line:
Add new home line:
6.4 Reload systemd
Step 7: Test Configuration
7.1 Unmount Everything
7.2 Test New Home Mount
Verify your user directory and files are present.
7.3 Test Automatic Decryption
If this works without asking for a passphrase, configuration is correct!
Step 8: Reboot and Verify
8.1 Reboot System
8.2 After Reboot Verification
Expected behavior:
- System prompts for passphrase once (for main disk)
- New home decrypts automatically via keyfile
/homeis mounted and accessible- All user data intact
Step 9: Cleanup Old Home (Optional)
WARNING: Only proceed after confirming new home works perfectly for several days!
9.1 Verify New Home Usage
9.2 Remove Old Home LV
Type y to confirm.
9.3 Extend Root LV (Optional)
If you want to add the reclaimed space to root:
Troubleshooting
Emergency Mode on Boot
Symptoms: System boots into emergency mode, home not mounted
Solution:
- Enter root password in emergency mode
- Check logs:
- Check configuration:
- Verify UUID matches:
- Manually decrypt and mount:
- Fix configuration files and reboot
Keyfile Not Working
Verify keyfile permissions and location:
Should show: ---------- 1 root root
Test manual decryption with keyfile:
Security Notes
- Keyfile Security: The keyfile is stored on the encrypted root partition, so it’s only accessible after the main disk is decrypted
- Passphrase: Keep a secure backup of your LUKS passphrase - the keyfile is for convenience, but passphrase recovery is the fallback
- Root SSH: Disable root SSH after completing migration:
Summary
This process successfully migrates /home to a new encrypted drive while:
- โ Maintaining LUKS encryption
- โ Using LVM for flexibility
- โ Automatic decryption via keyfile
- โ Single passphrase prompt at boot
- โ All data integrity preserved
- โ Proper permissions and ownership maintained