I want to install LMDE on the computer of my parents. It's a brand new shiny thing, with Windows 7 installed on it. There is a UEFI motherboard, and after a quick look at the hard drive, I see that the partition table is in the GPT format.
Note:
In all this tutorial, my hard drive is /dev/sda. The EFI partition is /dev/sda1, and the Linux partition is /dev/sda7. Change that to fit your configuration.
Problem:
I want to install LMDE. With older hardware (ie. BIOS motherboard, MBR partition table), it would be real easy. But with the UEFI and GPT things, I'm cautious. I have no idea if the LMDE installer will handle that properly. And because it's not my computer, I don't want to do things at random, and find myself with a computer that don't boot.
So, I decided to do this in two parts:
- first, LMDE installation, using the official DVD from there: http://www.linuxmint.com/download_lmde.php
- then, installing GRUB manually, so that I understand what happens.
Installing LMDE
Nothing very fancy here. I just booted the LMDE Live DVD. I used gparted to free a little bit of space on the hard drive. Then, I created two partitions, one for the system, one for the swap. After that, I choosed to install LMDE from the Menu->System Tools->Install Linux Mint. The very important thing here, is that I don't want to install the GRUB bootloader. So when the installer asks whether I want to install it, I say NO.
After that step is finished, LMDE is installed, but there is no way to boot it. If you restart your computer, it will start Windows as usual. It's because the computer still uses the Windows bootloader. This bootloader can only boot Windows. It is not aware of any other system that may be installed.
So, we want to replace it with GRUB. And that's the interesting part of this tutorial !
Look at the EFI partition
So, I assume that, at this moment, you booted LMDE via the Live DVD. And I assume that LMDE is properly installed.
Let's have a look at the partitions on the hard drive with partx. Of course, you can also have a graphical view of that using gparted.
On my config, partx gives me something like that:
Code: Select all
sudo partx -s -o NR,START,END,SIZE,NAME,SCHEME -- /dev/sda
NR START END SIZE NAME SCHEME
1 2048 206847 100M EFI system partition gpt
2 206848 468991 128M Microsoft reserved partition gpt
3 468992 163842047 77.9G Basic data partition gpt
4 163842048 266242047 48.8G Basic data partition gpt
5 266242048 368642047 48.8G Basic data partition gpt
6 368642048 894066687 250.6G Basic data partition gpt
7 894066688 960397311 31.6G gpt
8 960397312 976773119 7.8G gpt
- The 100M partition is the EFI partition (also called ESP - EFI System Partition). This is where the bootloader lives. With gparted, we can see that this partition is FAT32 and has a flag "boot".
- The 128M partition is the MSR (Microsoft Reserved Partition). gparted shows that the file system is unknown, and that it has a flag "msftres".
- The 4 following partitions are Windows and data partitions.
- The two last partitions are the ones I created to install LMDE. 31,6G is for the system, 7,8G is the swap partition.
OK. So, here we only care about the first partition (/dev/sda1). This is where we're gonna do things.
At first, let's backup this partition, in case we mess everything. I have a USB stick mounted at /media/usb for that purpose.
Code: Select all
dd if=/dev/sda1 of=/media/usb/efi.backup bs=1M
Code: Select all
sudo mount /dev/sda1 /mnt
cd /mnt/EFI
ls
Boot Microsoft
Code: Select all
# No output from diff means that files qre identical
diff Boot/bootx64.efi Microsoft/Boot/bootmgfw.efi
Install GRUB
Now, I know that the bootloader is a file on the EFI partition. And I want to replace it with GRUB.
I will do that using the method on this page:
http://www.thinkwiki.org/wiki/UEFI_Firmware
The first time I tried that, the update-grub command didn't work. It seems that you can't do that from a Live DVD without using chroot.
See http://www.linuxquestions.org/questions ... vd-878892/
So let's do that.
Code: Select all
# At first, let's umount the EFI partition.
sudo umount /mnt
# Do the chroot thing
sudo mount /dev/sda7 /mnt/
sudo mount --bind /proc /mnt/proc
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /sys /mnt/sys
chroot /mnt/ /bin/bash
Code: Select all
# Mount the fat32 partition at /boot/efi
sudo mkdir /boot/efi
sudo mount /dev/sda1 /boot/efi
# Update apt repositories, so that we get packages from the internet instead of the Live DVD
sudo apt-get update
# Install the efi version of grub. Change package name if your arch is not amd64.
sudo apt-get install grub-efi-amd64
# Now run grub-install (ignore warnings about efivars)
sudo grub-install /dev/sda
sudo update-grub
# This should have installed grub on the EFI partition
ls /boot/efi/EFI/
Boot linuxmint Microsoft
Use GRUB instead of the current bootloader
If everything went smoothly, you're almost done. However, if you restart now, your PC will still boot with Windows bootloader. I guess the proper way for the next step depends on your motherboard.
In my case, I had to replace the file in the Microsoft folder:
Code: Select all
cd /boot/efi/EFI/
cp Microsoft/Boot/bootmgfw.efi Microsoft/Boot/bootmgfw-backup.efi
cp linuxmint/grubx64.efi Microsoft/Boot/bootmgfw.efi
Configure GRUB
If I reboot at this point, the bootloader used is GRUB, which allows me to boot Linux. However, I don't see any Windows 7 entry. GRUB doesn't recognize it.
I need to add this entry manually. I did it using the method mentioned there: http://ubuntuforums.org/showpost.php?p= ... stcount=14
Find out the blkid of your EFI partition:
Code: Select all
sudo blkid /dev/sda1
/dev/sda1: UUID="1261-7FB0" TYPE="vfat"
Code: Select all
sudo vi /etc/grub.d/40_custom
Code: Select all
menuentry "Windows 7" {
insmod part_gpt
insmod fat
insmod search_fs_uuid
insmod chain
search --fs-uuid --no-floppy --set=root 1261-7FB0
chainloader (${root})/efi/Microsoft/Boot/bootmgfw-backup.efi
}
Code: Select all
sudo update-grub
Finished
I can reboot now, it works !
Hope this tutorial will help you. Other interesting documents on this subject: