Advertisement
Guest User

Arch Install Guide (BTRFS/LUKS) on Macbook Pro

a guest
Jan 21st, 2014
1,424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.41 KB | None | 0 0
  1. There are a lot of macbook pro install guides out there... but they're either too rigid (process doesn't allow for using other bootloaders, etc.) or add unecessary steps (like using Refind/Refit). NOTE: I have not tested these steps with filevault enabled in OSX. I suggest you disable it to start out.
  2.  
  3. 1. Download ArchIso. You want the latest one.
  4.  
  5. 2. In the meantime, resize your OSX partition using diskutility. Don't create a partition where you'll install Arch. Instead, just leave free space. Also, plug in a thumb drive. Erase it with the diskutility and format it with a GUID Partition table (GPT) and whatever kind of filesystem (OSX Journaled is fine... we'll delete this anyways).
  6.  
  7. 3. Open up your terminal (still in OSX). type:
  8. > diskutil list
  9. This will show you the attached devices. Look for the entry that corresponds to your thumbdrive (the size will be a dead giveaway). Take note of its path. For instance, my thumb drive looks like /dev/disk2.
  10.  
  11. 4. Now, you want to unmount it (so that we can interact with the thumb drive on a raw level (OSX won't be able to read the filesystem you'll install to it)). To do this, type:
  12. sudo diskutil unmountDisk /dev/<disknumber>
  13. where <disknumber> might be disk2 or disk3, etc (the thing you noted in step 3).
  14.  
  15. 5. Now, we're going to copy the Arch install medium to the USB disk. First, change the directory to where you downloaded the installation iso. So, if you downloaded to /home/users/<username>/Downloads, the command to do this will look like:
  16. cd ~/Downloads
  17.  
  18. 6. Now, for the copying. Remember that disk number from step 3? Just in case, run "diskutil list" and verify the disk number (disk1, disk2, etc.) that corresponds to your thumb drive. DO NOT GET THIS WRONG.
  19. sudo dd if='<filename of arch iso image>' of='/dev/r<disknumber>' bs=1m
  20. if you start typing the filename and hit 'tab', it will autocomplete. Make sure it's enclosed in quotes. Similarly, make sure you're using rdisk1/rdisk2/etc. rather than disk1/disk2/etc. This can take a minute or two (sometimes more).
  21.  
  22. 7. You should now have a thumb drive with the arch install medium on it. Before doing anything else, find another thumb drive and install a bootable OSX installation disk to it (instructions are online). Back up all your stuff. I'm not fucking around, stuff happens and you'll be sorry later. In fact, it's pretty easy to botch an arch install.
  23.  
  24. 8. Find an ethernet cable and plug your macbook pro into your router directly. If you have a spare USB wifi adapter, that *might* work but no guarantees.
  25.  
  26. 9. Reboot your computer. Hold the option key during boot up and if you did everything right then you should see a boot option that says "EFI boot" or something similar. Select it (with the arrow keys) and hit enter. Now, select the Arch option (the other ones will be an EFI shell and something else, you don't want that). Arch will now boot and take you to a root shell.
  27.  
  28. 10. Here, the first thing you want to do is partition your disk. To get the device path, type 'lsblk' (stands for 'list block devices'. In Linux, each physical disk is given a letter and each partition a number. So, partition 1 on disk A would be /dev/sda1. Partition 2 on disk A would be /dev/sda2. Partition 1 on disk B would be /dev/sdb1. Disk A as a whole is /dev/sda. You want to find the path to the main hard drive on your macbook pro. Generally, it will be /dev/sda but just make sure that's the case.
  29.  
  30. 11. Now, we'll partition that drive. Type 'gparted /dev/<diskpath>'. For me, this was 'gparted /dev/sda'.
  31.  
  32. 12. You're now in GNU Parted (gparted). This program allows you to partition your drive and write the partition table to the disk. It does NOT format the partitions. What we want to do here is to work *only* with the free space. That is, DO NOT TOUCH THE OSX PARTITIONS. Generally, there will be 2 or 3 OSX partitions already on the disk (even if you only see one in OSX's disk utility). The first one is called the ESP partition. This is where the bootloaders are installed. The second one is usually your main OSX partition. The third is usually the OSX recovery partition. The order will vary.
  33.  
  34. Create the following partitions:
  35. 1. SWAP Size: roughly twice the size of ram in your computer (for instance, 16G (note the lack of a B, this means gigibyte which is measured in powers of 2 rather than powers of 10 like gigabytes) for a computer with 4GB of ram). Note that you'll want to use code 8200 for the swap.
  36. 2. ARCHVOL Size: (whatever's left)
  37. When you're creating these partitions, type +128M when it asks you for the start of the first sector. This leaves 128 Mebibytes of free space between partitions. For some reason, OSX likes this (you're not required to leave these spaces but for some people this fixes a variety of issues). This will be code 8300 (linux partition).
  38.  
  39. 13. Now that you've written the partition table to the disk, we'll want to create a LUKS volume on the disk. Here's the 'big picture' setup. Let's say /dev/sda4 is your ARCHVOL partition. We'll create a LUKS device on it. Once you mount this LUKS device, we'll create a btrfs volume on the LUKS device. That btrfs volume will have two subvolumes: homevol and rootvol. The great thing about this setup is that you don't have to decide ahead of time how big root and home need to be. This gives you a ton of flexibility and prevents headaches in the future.
  40.  
  41. So... to create a luks device we use a tool called cryptsetup (part of Dm-crypt). We'll want to use some settings that are better than the defaults. Let me explain what those are.
  42.  
  43. Cipher: I suggest using AES-XTS with a 512bit key. It's MUCH faster than the alternatives and secure enough to approved for use on top secret/secret government documents. Only slightly slower (read: not noticeable).
  44.  
  45. Hash: Until SHA3 (Keccak) is supported by the kernel, SHA512 (aka 512bit SHA2) is pretty much the only real choice.
  46.  
  47. Random generation: For the key, you might as well use /dev/random (better quality pseudorandom-number-generation (PNG) than /dev/urandom). For cleaning the partition, you'll want to use /dev/urandom because /dev/random will quickly run out of random data (the entropy pool) and it's slow to refill. urandom boostraps already used random numbers and hashes them to create entropy.
  48.  
  49. So... to create our LUKS device on /dev/sda4 with these settings:
  50.  
  51. 14. Write random numbers to the partition:
  52. dd if='/dev/urandom' of='/dev/sda4' bs=1M
  53.  
  54. 15. Create the LUKS device:
  55. cryptsetup --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random --verify-passphrase luksFormat /dev/sda4
  56. (type in your password twice to verify).
  57.  
  58. 16. Mount the created LUKS device (using sda4 as an example and ARCHCRYPT as the name I give it):
  59. cryptsetup open /dev/sda4 ARCHCRYPT
  60.  
  61. 17. Now, you can access the LUKS device on /dev/mapper/ARCHCRYPT (or whatever you called it). It's just like a disk (though not formatted yet).
  62.  
  63. 18. Now, we format it (very important, use the path to the mounted LUKS device, NOT the path to the partition it's on):
  64. mkfs.btrfs /dev/mapper/ARCHCRYPT (or whatever you called it)
  65.  
  66. 19. Now, we want to mount it so we can create subvolumes:
  67. mount /dev/mapper/ARCHCRYPT /mnt
  68. cd /mnt
  69. btrfs subvolume create rootvol
  70. btrfs subvolume create homevol
  71. cd ~
  72. umount /mnt
  73.  
  74. 20. The cool thing about btrfs is that if you mount the first subvolume, it will pull in the other ones (or at least it should). So let's mount rootvol and use it as our root for the installation.
  75. mount -o subvol=rootvol /dev/mapper/ARCHROOT /mnt
  76.  
  77. 21. Let's get the swap disk ready so that Arch will recognize it. In my case, it was /dev/sda5 I think. Just type 'lsblk' and check to make sure. I use /dev/sda5 here as an example.
  78. mkswap /dev/sda5
  79. swapon /dev/sda5
  80.  
  81. 22. Let's mount the ESP (EFI System Partition) (usually /dev/sda1) to /mnt/boot. We want to share one with OSX so we can use the macbook pro's boot screen.
  82. mkdir /mnt/boot
  83. mount /dev/sda1 /mnt/boot
  84.  
  85. 23. Now, let's get the internet sorted out. If you're connected via ethernet you should already be online. To test:
  86. ping -c 5 www.google.com
  87.  
  88. You should get replies. If you get errors then you're not online. Try unplugging and plugging your ethernet cable in again.
  89. If this still doesn't work, follow the instructions no the Arch beginner's guide for setting up a wireless network with a static IP.
  90.  
  91. If you're using wifi (THE BUILT IN WIFI WILL NOT WORK YET) via a USB key see if it's recognized by typing 'wifi-menu'. It will bring up a screen hopefully allowing you to connect to a network. It will ask you for a profile name. This name CANNOT contain spaces or special characters.
  92.  
  93. 24. Install the arch base and base-devel packages:
  94. pacstrap /mnt base base-devel
  95.  
  96. 25. Let's generate an fstab (filesystem table) that will tell arch what the disks are and where to find them.
  97. genfstab -U -p /mnt >> /mnt/etc/fstab
  98.  
  99. Take a look at the generated fstab. You can use vi (vim isn't installed at this point) or nano. If you're a total beginner, use nano.
  100. Using nano:
  101. nano /mnt/etc/fstab
  102. Using vi:
  103. vi /mnt/etc/fstab
  104.  
  105. You want to make sure that there's an entry for the LUKS device (it'll say /dev/mapper/archcrypt (or whatever you called it)). It should have something saying subvol=rootvol. If not, restart, remount the disks and generate the fstab again. There should be two numbers. They should be 0 0 for the LUKS entry.
  106.  
  107. There should also be an entry for the ESP. It'll probably say LABEL=EFI and have /dev/sda1 somewhere. The two numbers for this should read 0 2.
  108.  
  109. Finally, there should be an entry for the swap disk. The two numbers for this should be 0 0.
  110.  
  111. 26. Ok now we're going to chroot into the installed system:
  112. arch-chroot /mnt /bin/bash
  113.  
  114. 27. Ok now some easier stuff. Install components so you still have wifi when you reboot (note: you still won't be able to use the built in wifi until later but you should still install these things):
  115. pacman -S dialog iw wpa_supplicant
  116.  
  117. 28. Install the text editor of your choice and go ahead and install firefox:
  118. pacman -S firefox vim emacs
  119.  
  120. 29. Install some other useful tools:
  121. pacman -S git wget curl libzip
  122.  
  123. 30. Now, we're going to set the locale options. Again, use vim or nano or emacs or whatever. Uncomment the lines corresponding to the languages you need. For US users it'll be:
  124. en_US.UTF-8 UTF-8
  125.  
  126. 31. Generate the locales:
  127. locale-gen
  128.  
  129. 32. Add the languages you choose to your locale.conf (example using en_US.UTF-8):
  130. echo LANG=en_US.UTF-8 > /etc/locale.conf
  131. export LANG=en_US.UTF-8
  132.  
  133. 33. Add whatever keymaps you need for foreign languages. Refer to the arch beginner's guide for more info.
  134.  
  135. 34. Set your timezone. Look at the available zones:
  136. ls /usr/share/zoneinfo
  137.  
  138. Each zone will have subzones (like .../America/New_York)
  139.  
  140. Create a symlink to the zone of your choice (Using New_York as an example):
  141. ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
  142.  
  143. 35. Give your computer a name. Using 'karma' as an example:
  144. echo karma > /etc/hostname
  145.  
  146. 36. Determine whether you need intel or NVIDIA drivers:
  147. lspci | grep VGA
  148.  
  149. If it returns something containing 'intel' you need to install the intel graphics driver:
  150. pacman -S xf86-video-intel
  151.  
  152. If it returns NVIDIA then install the nvidia driver (go ahead and use the beta driver):
  153. pacman -S nvidia-beta
  154.  
  155. 37. Install other drivers so you can actually use your macbook:
  156. pacman -S xf86-input-synaptics alsa-utils hfsprogs
  157.  
  158. 38. Set a root password:
  159. passwd
  160.  
  161. 39. Add a user (using fx101 as an example and kittycat as the password):
  162. useradd -m -g users -G wheel -s /bin/bash fx101 && passwd kittycat
  163.  
  164. 40. Install sudo (so users in the wheel group can run commands as root):
  165. pacman -S sudo
  166.  
  167. 41. Give the users in the wheel group sudo priveleges. You'll need to use the visudo editor for this (I've provided what to type in case you're not familiar with vi... but if you fuck up, type ESC q! ENTER to quit without saving changes and then try again).
  168.  
  169. visudo
  170. (once inside visudo type this:)
  171. /#\ %wheel ALL <--this selects the line you need
  172. x <--this deletes the comment character
  173. :wq <--saves and closes the file
  174.  
  175. 42. Ok now it's time for the hard part. We need to create an initial ramdisk environment for linux to boot from. The configuration file is located at /etc/mkinitcpio.conf
  176.  
  177. Open that file with the text editor of your choice (remember, nano if you're a beginner).
  178.  
  179. You should see the line MODULES=
  180. Make it MODULES="crc32-intel" (this enables special CPU accelerations for CRC hashes used with btrfs)
  181.  
  182. Ok, now go to the line that says HOOKS="base udev ..." (will have a bunch of stuff).
  183.  
  184. Move 'keyboard' to right after autodetect. Add encrypt right after block but before filesystems. My line looks like:
  185. HOOKS="base udev autodetect keyboard modconf block encrypt filesystems fsck"
  186.  
  187. 43. Ok now let's generate the ramdisk environment:
  188. mkinitcpio -p linux
  189. It will probably complain about fcsk.btrfs not existing or whatever and hence the image potentially being incomplete. This is fine, it will work perfectly.
  190.  
  191. 44. Install the partitioning utilities (in case you fuck up big time and need to run cgdisk):
  192. pacman -S gptfdisk btrfs-progs
  193.  
  194. Now it's the part that's a real pain in the ass. Installing the bootloader. Your macbook pro boots EFI kernels so you want a very lightweight bootloader like gummiboot (what I *highly* recommend). With this setup you shouldn't need refind or refit.
  195.  
  196. 45. Install gummiboot:
  197. mount -t efivarfs efivarfs /sys/firmware/efi/efivars (this might give you an error that they're already mounted... ignore it)
  198. pacman -S gummiboot
  199. gummiboot install
  200.  
  201. 46. Add an entry for Arch. Again, use the text editor of your choice. The file needs to be:
  202. /boot/loader/entries/arch.conf
  203.  
  204. The first 3 lines should be:
  205. title Arch Linux
  206. linux /vmlinuz-linux
  207. initrd /initramfs-linux.img
  208.  
  209. In the next line, I use archcrypt to refer to the LUKS device we created earlier and rootvol to refer to the root subvolume of the btrfs filesystem on that LUKS device. Substitute the names you used. Also, substitute the physical partition where the luks device is located. For me, it was /dev/sda4
  210.  
  211. options cryptdevice=/dev/sda4:archcrypt root=/dev/mapper/archcrypt rootfstype=btrfs rootflags=subvol=rootvol rw
  212.  
  213. Save and close the file.
  214.  
  215. 47. Type 'exit' to exit the chroot environment.
  216. 48. Unmount all disks:
  217. umount -R /mnt
  218. 49. Type 'reboot' to reboot. Make sure to unplug the USB drive as soon as it shuts down. Also, hold the option key as soon as it boots up.
  219. 50. Ideally, you should now have an entry that says EFI boot. Highlight it and you should now boot into arch. It should ask you for the encryption passphrase after a second or two.
  220.  
  221. Now, we're going to install the desktop manager. I really like how gnome works on macbooks so I'll provide those instructions.
  222.  
  223. 51. Install the X Window System:
  224. pacman -S xorg-server xorg-server-utils xorg-xinit mesa
  225.  
  226. 52. Install some fonts:
  227. pacman -S ttf-dejavu
  228.  
  229. 53. Install SSH support (for logging into remote machines/servers).
  230. pacman -S openssh
  231.  
  232. 53. Install gnome. I recommend just going ahead and installing gnome-extra as well. You can remove the games you don't need later.
  233.  
  234. pacman -S gnome gnome-extra networkmanager networkmanager-openconnect network-manager-openvpn networkmanager-pptp networkmanager-vpnc
  235.  
  236. This will take a while.
  237.  
  238. 54. Enable the gnome desktop manager (so you have a nice login window that will load a gnome session for you):
  239. systemctl enable gdm
  240.  
  241. 55. Restart your computer and boot into arch. Now you should be able to log into gnome and you'll be in your desktop!
  242.  
  243. 56. Now, let's install an AUR package manager so you can install the broadcom wireless drivers. I really like aura. First, we need to install the dependencies:
  244. sudo pacman -S ghc haskell-regex-base haskell-parsec haskell-syb haskell-transformers haskell-mtl haskell-json haskell-temporary
  245.  
  246. 57. Add the haskell-core repository to pacman. To do this, edit /etc/pacman.conf (make sure to use sudo so you have write priveleges). You'll need to add these two lines:
  247.  
  248. [haskell-core]
  249. Server = http://xsounds.org/~haskell/core/$arch
  250.  
  251. Make sure to put it above [extra].
  252.  
  253. 58. You'll need to sign the keys for the repo:
  254. sudo pacman-key -r 4209170B
  255. sudo pacman-key --lsign-key 4209170B
  256.  
  257. 59. Now, update pacman's list and upgrade all the installed packages:
  258. sudo pacman -Syy && sudo pacman -Syu
  259.  
  260. 60. Install two more dependencies:
  261. sudo pacman -S haskell-curl haskell-regex-pcre
  262.  
  263. 61. Clone the aura repo into your downloads folder:
  264. cd ~/Downloads
  265. git clone https://github.com/fosskers/aura.git
  266.  
  267. 62. Move into the folder it created.
  268. 63. Build the package (DO NOT RUN THIS COMMAND AS SUDO/ROOT unless it asks you to):
  269. makepkg -s
  270. 64. This will create a .tar.xz file. Install it using pacman:
  271. sudo pacman -U <filename>.tar.xz
  272.  
  273. 65. Now you have aura installed. Let's get some wireless drivers working. First, we want to check if the proprietary drivers will do the job. To do this, install the broadcom-wl-dkms package:
  274. aura -A -x broadcom-wl-dkms
  275. 66. Restart your computer (unplug ethernet and USB wifi).
  276. 67. Once you're logged in, see if wifi is working. If it's not, it's possible that the module wasn't registered correctly. Try doing:
  277. dmks add -m broadcom-wl -v 6.30.223.141 (grab the version number from https://aur.archlinux.org/packages/broadcom-wl-dkms/ but ignore the -2 or whatever at the end)
  278. systemctl restart dkms.service
  279. 68. If wifi works, you're done!
  280. 69. If not, uninstall the package:
  281. aura -R broadcom-wl-dkms
  282. And follow the instructions on the arch wiki for getting the b43 driver with b43fwcutter
  283.  
  284. That's it! Stuff should work for you now.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement