Skip to content

Instantly share code, notes, and snippets.

@groldo
Created January 19, 2022 12:13
Show Gist options
  • Select an option

  • Save groldo/564744b76f73f9a433957b97983290ff to your computer and use it in GitHub Desktop.

Select an option

Save groldo/564744b76f73f9a433957b97983290ff to your computer and use it in GitHub Desktop.
How to install encrypted arch linux on an iMac 6,1

How to install arch linux on an iMac 6,1

I recently purchased an old iMac 6,1. It's capable of some modern nix distributions, but doesn't play well if there is to "much" GUI. (e.g. default kali linux can be a bit laggy) So I decided to install an arch linux from scratch. I won't cover the whole installation as it may vary. And there are already a dozen straigt forward tutorials. So topics to be discussed are:

  • loading arch installer via a kali usb stick
  • installing grub as bootloader

All I was doing is just switching the (great) different arch tutorials. This gist might help one or another, getting it all together, for this special use case.

loading arch installer via a kali usb stick

The iMac 6,1 does have a 32-bit EFI, but a 64-Bit CPU. Most modern installer/live USB Images does not include a 32-Bit EFI executable.

To get a hackable boot loader I installed the recent version of a kali live USB (kali-linux-2021.4a-live-amd64) onto an USB Stick. And arch linux to another. Plug them both.

Obviously kali does ship a 32-Bit EFI executable to boot with grub. So when you're in (kali) grub boot menu, get into a grub shell by pressing , now boot into arch by entering:

set gfxpayload=keep
search --no-floppy --set=root --label ARCH_YYYYMM
# if you know which partition is you're stick you can also use
set root=(hd1)
linux /arch/boot/x86_64/vmlinuz-linux archisobasedir=arch archisolabel=ARCH_YYYYMM add_efi_memmap
initrd /arch/boot/intel-ucode.img /arch/boot/x86_64/initramfs-linux.img
boot

to get the label of the partition you can list all available partitions with ls Then just try all partitions available e.g. ls (hd1) ... for arch linux the label should be something like ARCH_202112

mostly taken from https://wiki.archlinux.org/title/Unified_Extensible_Firmware_Interface#Using_GRUB

now it should boot into the arch linux installer.

Install arch

Next you can follow https://wiki.archlinux.org/title/Installation_guide as you may like. I wanted to have a seperate (unencrypted) boot partition and a encrypted root partition.

So I followed https://wiki.archlinux.org/title/Dm-crypt/Encrypting_an_entire_system#Preparing_the_logical_volumes without creating a seperate home partition. I managed to already have a EFI boot partition, so I'm not able to tell what has to be done for this. I've just formatted it with a FAT 32 mkfs.fat -F 32 /dev/efi_system_partition as mentioned.

install grub

grub and 32-Bit EFI

When installing grub I've just hoped to follow the instructions from the (arch) grub tutorial. But there is one big difference:

Following the instructions from https://wiki.archlinux.org/title/GRUB#Installation_2 for iMac 6,1 you do have to change the target to i386-efi, because the iMac 6,1 has a 32-Bit EFI boot. The command should look similar to this:

grub-install --target=i386-efi --efi-directory=/boot/ --bootloader-id=GRUB

encrypted boot

Because of some misdirections while troubleshooting my problems I also came across a solution to have an encrypted boot partition taken from https://wiki.archlinux.org/title/GRUB#Encrypted_/boot

Because grub 2.06 is not able to load an luks encrypted partition all by himself, you have create a capable EFI binary which can do this:

# cat grub-pre.cfg
set crypto_uuid=<some_uuid>
cryptomount -u $crypto_uuid
set root=(hd0,gpt1)
set prefix=($root)/grub
insmod normal
normal
grub-mkimage -p /boot/grub -O i386-efi -c grub-pre.cfg -o /tmp/grubx64.efi fat luks2 lvm part_gpt cryptodisk gcry_rijndael pbkdf2 gcry_sha256 ext2
install -v /tmp/grubia32.efi /boot/EFI/GRUB/grubia32.efi

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment