[SOLVED]Booting on a MacBookPro with LVM on LUKS and UEFI

Here you'll find a place for solutions and hints.

Please use one of the support subforums below for questions or if you have any issues and need support.

[SOLVED]Booting on a MacBookPro with LVM on LUKS and UEFI

Postby monolith » Jun 11th, '14, 15:02

edit doktor5000: split out from viewtopic.php?f=8&t=7421


Hi,

I'm hijacking this thread because I have some questions regarding Mageia on a MacBook Pro. I'm a freshly baked Mageia user, I just installed it on a laptop (with MBR) and I love it. A short introduction about me. I've been using Linux and BSD since 2006, I started with Ubuntu and Dapper Drake. I have been using Ubuntu, Mint, Fedora, Debian, FreeBSD, PC-BSD, Arch Linux and now Mageia. But I still need some help every now and then with Linux because I'm not a natural talent in computing ;) I am shredding /dev/sda4 on my MacBook at the moment to prepare for the Mageia install. I have been using Arch Linux on the MacBook with encrypted LVM and LUKS and it has beed working very good and that is the setup I am looking for with Mageia. But I am simplifying my computer use and I will put Mageia with Mate on all my computers back home (even if I am a deb user) because Mageia impressed me after my first install on the laptop. I especially liked the Mageia Control Center, the balanced choice of programs and the fact that my old laptop is finally running cool again.

I will dualboot on the MacBook and the partitions on the HDD will be:

1. sda1 with 200MB for EFI System
2. sda2 where OS X is installed
3. sda3 på 620MB which is a recovery partition for OS X
4. 128MB unused disk (they say this is the way OSX like it)
5. sda4 with /boot
6. sda5 with encrypted LVM
6a. lv /
6b. lv swap
6c. lv home

I have tried to install Mageia yesterday on the MacBook but I ran into problems while booting. I have reFind installed from OS X and it found the Mageia install but I ended up in grub rescue mode when I tried to start Mageia. My questions are:

1. Where shall I put EFI and install GRUB. When I installed Arch Linux I did the following
Code: Select all
# mkdir -p /boot/efi
# mount -t vfat /dev/sda1 /boot/efi
# modprobe dm-mod
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck --debug
# mkdir -p /boot/grub/locale
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo

Shall i try to do the same thing with Mageia?

2. Is it enough to encrypt the LVM or shall I also encrypt the /, swap and /home within the LVM? It seems overkill to me.

3. Shall I install reFind again after the installation of Mageia but as a rpm package? Is refind in the repositories?

These are the questions I can come up with at the moment, but there will be more! Anyways, thanks a lot for any help!

//haveaniceday
Last edited by monolith on Jun 12th, '14, 13:57, edited 3 times in total.
monolith
 
Posts: 5
Joined: Jun 11th, '14, 14:22

Re: Booting on a MacBookPro

Postby doktor5000 » Jun 11th, '14, 21:08

Please next time don't hijack an existing thread.

For one of your question, I can provide an answer:
You should be aware of the differences of LUKS over LVM or LVM over LUKS
https://wiki.archlinux.org/index.php/Dm ... VM_on_LUKS
https://wiki.archlinux.org/index.php/Dm ... UKS_on_LVM
That, in combination with your security requirements should answer your question.
Usually LVM over LUKS is totally sufficient - you only need to keep in mind that normally /boot will not be encrypted.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 17659
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Booting on a MacBookPro

Postby monolith » Jun 12th, '14, 11:30

You are right, sorry about hijacking the thread. Bad manners. Anyway I was trying to get things to work yesterday and I ended up with a good solution in the end. When I tried to setup an encrypted LVM with the different installers I got stuck with having to reboot to let the changes take effect. Since that was impossible I had to find another solution and I ended up using a mix between information from the Mageia community and from how I did it before with Arch Linux. The final result was an encrypted LVM container (LVM on LUKS). These are my resourses:

1. https://wiki.mageia.org/en/UEFI_how-to
2. https://www.youtube.com/watch?v=SLu1NwsZr48 (excellent video)
3. https://wiki.archlinux.org/index.php/Beginners%27_Guide

I updated my MacBookPro before I started and that whiped out the rEFInd boot manager. So in a way I started from scratch. This is how I proceeded, maybe it can help someone else with the same problem.

1. I had to use the live DVD installer with Gnome in my case since it can boot in EFI mode. Start up the MacBookPro and press alt immediately. Insert the DVD (much easier to use than an USB) and you will be presented with an EFI boot disk. Select it and the live DVD will boot.

2. Test if you have booted in UEFI mode. Start the terminal and do
Code: Select all
# ls -1 /sys/firmware/efi
If this folder exisits it is OK.

3. After bootup I started gparted and cleaned up old partitions behind /dev/sda1 to 3. (These are the MacBook partitions. sda1 is the EFI partition, sda2 is the MacBook hdd and sda3 is the MacBook rescue disk. I had since before already shrunk my MacBook partition to around 30G, the rest 470G is for linux). I then created a new partition after sda3 that filled up the rest of the disk called sda4.

4. It is good practice to overwrite the disk with random data before you install an encrypted partition on it. It will take some time.
Code: Select all
# shred -v -z /dev/sda4


5. I used gdisk to create the partitions on the HDD.
Code: Select all
# gdisk /dev/sda
First erase sda4 using the menu. Then create a new partition (sda4) which will become /boot. Remember to put this partition +128M behind sda3 since OSX apparently need some space behind sda3. Don't know why. This is a standard linux partition type, i.e. 8300. Also label the disk, I used boot. Then create another partition (sda5) and fill up the rest of the disk (if you wish) and make this a Linux LVM partition i.e. 8e00. I labeled the disk sda5_crypt. Write and save changes.

6. Now it is time to set up the encrypted partition in the LVM, to create the volume groups and the logical volumes. This is what I did
Code: Select all
# modprobe dm-crypt
# cryptsetup --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random --verify-passphrase luksFormat /dev/sda5
# cryptsetup luksOpen /dev/sda5 sda5_crypt
# pvcreate /dev/mapper/sda5_crypt
# vgcreate busta_crypt /dev/mapper/sda5_crypt
# vgdisplay
# lvcreate -L 15G -C y -n root busta_crypt
# lvcreate -L 4G -C y -n swap busta_crypt
# lvcreate -l +100%FREE -C y -n home busta_crypt
# lvdisplay


7. Now start the installer. When you come to the partition setup chose custom install and set up the mountpoints for (in my case) /boot, / and /home. Also change the type to swap for the swap partition. Proceed until you get the choice to select bootloader. Select grub2 and then go back to the terminal.

8. It is time to install grub2-efi
Code: Select all
# chroot /mnt/install
# urpmi grub2-efi
Overwrite the old grub2 program. After the installation is complete, go back to the installer and continue to install grub2. I installed it on sda1. There will pop up some error messages, but it is OK.

9. Go back to the terminal and run
Code: Select all
# fdisk -l
to check where the EFI partition is situated. In my case sda1
Code: Select all
# chroot /mnt/install
# mkdir /boot/EFI
# mount /dev/sda1 /boot/EFI
# grub2-install --target=x86_64-efi --efi-directory=/boot/EFI/ --boot-directory=/boot/
grub2 is now installed on sda1 in the right place.

10. It is time to edit fstab. It is cruicial that the hdd are listed in the right order in this file otherwise you will get stuck in limbo while trying to boot. I found out the hard way and in my case I was unable to type the password for the LVM since the keyboard was not loaded. Select:
10.1 /boot/EFI
10.2 /dev/sda4 (the /boot partition)
10.3 /dev/busta_crypt/root (in my case)
10.4 and after that /home, proc and swap
Code: Select all
# blkid
Note the UUID label for your EFI partition, mine in UUID="2860-11F4"
I use vim
Code: Select all
vim /etc/fstab
and add the following at the top of the file. Edit the file as nessecary to load the partitions in the right sequence as I mentioned above.
Code: Select all
UUID=2860-11F4 /boot/EFI vfat defaults 1 1
Save and reboot!

11. Continue with the installation and setup network and users. Start the terminal
Code: Select all
# grub2-mkconfig -o /boot/grub2/grub.cfg
# grub2-install /dev/sda
Reboot.

12. Important! Remember to save the LUKS header on a USB stick. Keep the USB in a safe place. I use encfs to encrypt a folder on the usb, just in case.
Code: Select all
cryptsetup luksHeaerBackup /dev/sda5 --header-backup-file /path/to/usb/LUKS_heaer.img


This is how far I have come in my setup. I still need to edit the grub.cfg file because I cannot load OSX from grub, I have to press alt during boot to start OSX. But I will do that later. I recommend to watch the youtube clip I linked to above. That was basically my only resource I used to get the EFI boot to work.

If there are any typos please let me know so that I can correct it :D

Cheers!
monolith
 
Posts: 5
Joined: Jun 11th, '14, 14:22

Re: Booting on a MacBookPro

Postby doktor5000 » Jun 12th, '14, 22:53

monolith wrote:You are right, sorry about hijacking the thread. Bad manners.

Baah, no hard feelings over here :)

And thanks a lot for the extensive guide. Moved it to the Tips&Tricks section, and made it a sticky :mrgreen:
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 17659
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: [SOLVED]Booting on a MacBookPro with LVM on LUKS and UEF

Postby monolith » Jun 13th, '14, 15:33

Very good! I'm glad I could help ;)
monolith
 
Posts: 5
Joined: Jun 11th, '14, 14:22


Return to The magician suggests...

Who is online

Users browsing this forum: No registered users and 1 guest

cron