Thursday, January 16, 2014

Arch Install over Existing Linux (Mint) Installation with Windows 8 UEFI

Wow, that title sounds like fun.

Well, it wasn't bad at all.  After using Mint for a couple years I started to get frustrated with the outdated packages in APT (to name a few: scilab, hplip, freemind, bluez).  I liked Mint just fine, and keeping the system up to date is quite painless, which is a lot more than I can say for the several years I spent with Gentoo.

That being said, as I Googled for problems I was having with my Bluetooth setup, I noted that most of the hits were generated by archlinux.org.  I read a little about the distro and I decided to try it out.

For installers, there is so much information available on the Arch wiki it isn't even funny.  There's the 30,000 foot installation guide, which for experts is more of a checklist if you've done it a lot.  For everyone else but the sysadmins and hard-core experts, I recommend their beginner's guide.  This will have you going in no time.

The first thing I noticed was how small the LiveCD was -- it's only 500MB or so.  This is because Arch gives you a bare, and I mean BARE bones setup.  You won't find photo managers, a word processor, solitaire, and mine sweeper.  You won't find ANYTHING except the bare basics to boot the system and get you going.  Everything after that is what YOU add, and this can sometimes be shocking.  For example, if you think you might connect to a secure wifi network with your laptop, you might want to install wpa_supplicant.

Before installing Arch, I spent some time cleaning out my Mint system.  Not unlike moving day, you've got to pack your crap and move out.  This takes some time.

Once I thought I was ready to go, I knew I wasn't going to follow the beginner's guide to a T.  All I really needed to do was wipe my root partition, install the new kernel, set up the new environment, and reboot.

So, I didn't need to know about partitioning or formatting.  I knew I needed to start somewhere in that area of the guide.

After booting the LiveCD I quickly realized I needed to have some knowledge about the existing partitions.  I used lsblk:

$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk 
|-sda1   8:1    0   500M  0 part
|-sda2   8:2    0    40M  0 part 
|-sda3   8:3    0   128M  0 part 
|-sda4   8:4    0   500M  0 part 
|-sda5   8:5    0   232G  0 part 
|-sda6   8:6    0   7.2G  0 part 
|-sda7   8:7    0 190.8M  0 part
|-sda8   8:8    0 220.3G  0 part
`-sda9   8:9    0   4.9G  0 part

Well, I know the 200+ GB partitions are my Windows 8 drive and my Linux drive, but I wasn't sure which.  I just had to mount them and take a look around to figure out what was what.

I ended up scribbling the following down on a scrap of nearby paper:

/sda8 --> data/root
/sda9 --> swap
/sda7 --> boot/grub

I think it is obvious, but I want to note, that if you follow any instructions here you'd better be damn sure you know what you're doing.  Computer configuration can be UNFORGIVING.  If you are attached to any data on your hard drive, you'd better back everything up right now.  The computer doesn't particularly care if it blows all of your wedding pictures away.  You have been warned.

Now then -- I formatted /sda8 as ext4 (it already was formatted ext4, but I basically wanted to wipe it).  I did a "swapon /sda9", I mounted sda7 as /boot, and I chrooted into sda8.  (Okay, there was a little more to it than that but I basically followed the beginner's guide after the part about partitioning your system.)

Boom, I was in my new Linux system.  Now the tricky part was setting up GRUB.  There is a lot of info about GPT, UEFI, etc all over the Arch Wiki.  In particular see the excellent grub guide.  Most of the guides are taking you from ground zero, where you're starting with a blank drive.  In my case, I had a drive that was already populated.

In particular there are some warnings about checking for a GPT and an ESP here.


I didn't see a GPT when I tried using parted as described above.  In fact this is what I've got:

[root@marquette /]# parted /dev/sda print
Model: ATA ST500LM012 HN-M5 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name                          Flags
 1      1049kB  525MB   524MB   fat32           EFI system partition          boot
 2      525MB   567MB   41.9MB  fat32           Basic data partition          hidden
 3      567MB   701MB   134MB                   Microsoft reserved partition  msftres
 4      701MB   1226MB  524MB   ntfs            Basic data partition          hidden, diag
 5      1226MB  250GB   249GB   ntfs            Basic data partition
 7      250GB   251GB   200MB   ext4
 8      251GB   487GB   237GB   ext4
 9      487GB   492GB   5264MB  linux-swap(v1)
 6      492GB   500GB   7765MB  ntfs            Microsoft recovery partition  hidden, diag

So there's my ESP, partition 1 or /sda1.  I don't see "Partition Table: GPT" as the wiki mentions.  The article also mentions:  "An EFI System Partition (ESP) is needed on every disc you want to boot using EFI. GPT is not strictly necessary, but it is highly recommended and is the only method currently supported in this article."

Okay then, I don't think I have it, and I'm not messing around with these existing partitions lest I break my Windows 8 installation.

Check out the UEFI Alternative Method.  Here we are getting into some interesting commands.  What I noticed while I was poking around on /boot is that I already have a directory called /boot/efi.  FURTHER, I noticed while poking around the EFI parition (sda1 for me), that there was /Boot, /EFI, /Microsoft, /linuxmint directories.  Inside these I would drill down and eventually find some *.efi files.  Presumably this is where the booting magic happens.

I ended up mounting /dev/sda1 at /boot/efi:

[root@marquette /]# mount /dev/sda1 /boot/efi

Following the alternative instructions on the Arch grub wiki, I did this (modified what was on the wikipage and copied below):

# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch --boot-directory=/boot --recheck --debug

Don't forget the equal signs after the command line arguments!  You might get errors without some of them.  If all was successful, you'll see some stuff like this at the end:

grub-install: info: executing efibootmgr -c -d /dev/sda -p 1 -w -L arch -l \EFI\arch\grubx64.efi.
BootCurrent: 0008
Timeout: 0 seconds
BootOrder: 0008,0001,0002,0003,0000,0004,0005,0006,0007
Boot0000* mint
Boot0001* Realtek PXE B09 D00
Boot0002* P4: HL-DT-ST DVD+-RW GT80N    
Boot0003* P0: ST500LM012 HN-M500MBB     
Boot0004* Windows Boot Manager
Boot0005* UEFI: IP4 Realtek PCIe FE Family Controller
Boot0006* UEFI: IP6 Realtek PCIe FE Family Controller
Boot0007* linuxmint
Boot0008* arch
Installation finished. No error reported.

It turns out all of the crap above will be visible by the BIOS -- these *are* your UEFI boot options.  You'll want "arch" to be your main entry point.  (I still have to figure out how to get rid of some the old mint stuff.)

Next do: 

# grub-mkconfig -o /boot/grub/grub.cfg

[root@marquette boot]# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Found initramfs image: /boot/initramfs-linux.img
Found fallback initramfs image: /boot/initramfs-linux-fallback.img
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found linux image: /boot/vmlinuz-3.12.7-031207-generic
Found initrd image: /boot/initrd.img-3.12.7-031207-generic
Found linux image: /boot/vmlinuz-3.12.6-031206-generic
Found initrd image: /boot/initrd.img-3.12.6-031206-generic
  /dev/cdrom: open failed: No medium found
Found Windows Boot Manager on /dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
done

Now, reboot and see if it worked.  If all went well you should see the grub boot screen.

If you get a grub command line, something went wrong.  You can try following these instructions to see if you can get up and running again.

Good luck.

No comments:

Post a Comment