Migrating from btrfs to ext4 on my MacBook Pro (Mid 2014), while migrating from Fedora to Arch Linux.
If you want to stick with your current partitioning (keeping the EFI partition and the separate /boot
partition untouched) while only changing the root partition to ext4 and adding a swap partition for hibernation, here’s how you can proceed.
High-Level Plan
- Keep the EFI partition (
/dev/sda1
) and/boot
partition (/dev/sda2
) intact. - Reformat the root partition (
/dev/sda3
) to ext4 and set it up with LUKS encryption. - Create a new swap partition for hibernation.
Step-by-Step Instructions
1. Boot into Arch Linux Live Environment
- Boot from an Arch Linux USB installation medium.
- Open a terminal.
2. Back Up Important Data
If there’s any data on your root partition (/dev/sda3
) that you want to keep, back it up before proceeding.
3. Repartition the Disk
Open a partitioning tool (e.g.,
cfdisk
,gdisk
, orparted
):cfdisk /dev/sda
Modify the partitions as follows:
- Reduce the size of the root partition (
/dev/sda3
) to leave space for a new swap partition.
For example:- Shrink
/dev/sda3
by 16 GB (to match your RAM size) for swap. - Assign the remaining space as a new Linux swap partition (
/dev/sda4
).
- Shrink
- Reduce the size of the root partition (
4. Format and Encrypt the Partitions
Root Partition
Encrypt the root partition with LUKS:
cryptsetup luksFormat /dev/sda3 cryptsetup open /dev/sda3 cryptroot
Format the encrypted partition as ext4:
mkfs.ext4 /dev/mapper/cryptroot
Swap Partition
Format the new swap partition (
/dev/sda4
):mkswap /dev/sda4
Enable the swap:
swapon /dev/sda4
5. Mount the Partitions
Mount the root partition:
mount /dev/mapper/cryptroot /mnt
Mount the
/boot
partition:mkdir -p /mnt/boot mount /dev/sda2 /mnt/boot
Mount the EFI partition:
mkdir -p /mnt/boot/efi mount /dev/sda1 /mnt/boot/efi
6. Install Arch Linux
Follow the standard Arch Linux installation process:
Install the base system:
pacstrap /mnt base linux linux-firmware
Generate an
fstab
file:genfstab -U /mnt >> /mnt/etc/fstab
Chroot into the new system:
arch-chroot /mnt
7. Configure Swap for Hibernation
Identify the swap partition’s UUID:
blkid /dev/sda4
Add the
resume
hook to/etc/mkinitcpio.conf
:HOOKS=(base udev autodetect modconf block encrypt filesystems keyboard resume fsck)
Rebuild the initramfs:
mkinitcpio -P
Update your bootloader configuration:
Edit the systemd-boot entry in
/boot/loader/entries/arch.conf
:title Arch Linux linux /vmlinuz-linux initrd /initramfs-linux.img options cryptdevice=UUID=<root-partition-UUID>:cryptroot root=/dev/mapper/cryptroot resume=/dev/sda4 rw
Replace
<root-partition-UUID>
with the UUID of/dev/sda3
, which you can find using:blkid /dev/sda3
8. Finalize Installation
- Exit the chroot:
exit umount -R /mnt cryptsetup close cryptroot
- Reboot the system:
reboot
Post-Reboot
- Ensure the system prompts for the LUKS passphrase during boot.
- Test hibernation:
systemctl hibernate
- Confirm the system successfully resumes from hibernation.
By keeping your existing EFI and /boot
partitions intact, you’re preserving your current setup while enhancing it with a new root filesystem and swap for hibernation.