Pages

Tuesday, August 28, 2012

How to install System Rescue CD + rEFInd in an USB Stick for EFI systems (Macboot, UEFI PC/Laptops)

update: with further reading of rEFInd website, I could find a better way to specify more options with only one menu entry. The configuration section was subsequently updated.

This blogpost comes in handy mostly if you have an EFI system (Apple Macbook, but also some Intel based desktops and laptops), and you need a portable USB stick for emergency booting.
I've been using System Rescue CD for a long time now, it's probably one of the best  rescue tools around.
It's a live Linux distribution that can help restoring not only Linux installations, but Windows and OSX too, has gparted as a partitioning tool, can restore bootloaders (such as grub), has network support and ssh server (so you can use rsync to copy filesystem, control it remotely, browse the web to search for help if you panic) but being a live linux distro it may be used in almost every way you like. You may give a look to their homepage to see details.
It can also be installed in an USB stick, which comes quite in handy as you don't have to carry a relatively big support as a CDRom; nowadays usb sticks are cheap, small and fairly reliable, I always carry with me a SystemRescue usb stick for emergency repairs.

It might however be problematic using it if you have an EFI/UEFI based system, since SystemRescue CD doesn't actively support it.
For instance, in a macbook you can boot a system rescue cd, but not from usb stick, as the EFI system can boot usb sticks only if they contains an EFI bootloader.
Which is just annoying if you have a macbook pro, but becomes a real problem if you have a Macbook Air, as they don't have a CDROM Reader.

Another tool I've recently discovered is rEFInd Boot Manager, which is an EFI bootloader capable of discovering other EFI bootloaders. Beside being an excellent bootloader it can also be used as a rescue tool, since it might boot your system if your installed bootloader has been misconfigured.

Since rEFInd can directly boot Linux kernels too, if they're compiled using EFISTUB option (version >= 3.4), and since System Rescue CD does itself contain a 3.4 kernel, can this help us, combining both of these tools in a single USB Stick?

Of course the answer is yes!

Let's see how.

First, download System Rescue CD, and install it on the USB Stick using these  instructions.
Now download rEFInd too, just choose the CD-R Image File on their download page.
Extract rEFInd CD-R Image copying all the files into the USB Stick.
Open /EFI/boot/refind.conf and modify it as follows:

  • find the "scanfor" commented out line, and add this one (uncommented, of course):
    scanfor manual,internal,external,optical,hdbios,biosexternal,cd
  • At the end of the file, add the following lines (you may replace "it" with your favourite keymap):
menuentry "System Rescue CD x64" {
        icon /EFI/boot/icons/os_linux.icns
        loader /syslinux/altker64
        initrd /syslinux/initram.igz
        options "scandelay=5"
        submenuentry "IT Keyboard, cache" {
          add_options "setkmap=it docache add_efi_memmap"
        }
        submenuentry "IT Keyboard, cache, noapic" {
          add_options "setkmap=it docache noapic add_efi_memmap irqpoll acpi=force"
        }
        submenuentry "IT Keyboard, nocache" {
          add_options "setkmap=it"
        }
        submenuentry "IT Keyboard, nocache, noapic" {
          add_options "setkmap=it  noapic add_efi_memmap irqpoll acpi=force"
        }
        submenuentry "No EFI" {
          add_options "noefi"
        }
        submenuentry "VGA" {
          add_options "vga=791"
        }
}


And... that's it! We're done! Just try it out, rEFInd will show you the three System Rescue CD options, and the other installed operating systems.
You may of course customize kernel boot arguments with the options supported by System Recue CD.

As an optional step, since EFI is supported manily on x64 machines (that's why I've only added x64 kernel boot options) you may safetly remove the various "*ia32*" files you may see around, which should be "shellia32.efi", "refind/drivers_ia32", "refind/refind_ia32.efi", "EFI/boot/drivers_ia32", "EFI/boot/bootia32.efi".

Note: if you have one of the awful new Macbook pro/retina/air, which have serious problems booting linux, you may want to add the options "add_efi_memmap noapic" to properly boot System Rescue CD with EFI. I have already included it in one of the submenus.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.