6

I would like to have dual boot of two Linux distributions on my laptop. One stable (Mint 18 that I found to work well with Yoga 3 Pro) and one that would be probably changing often; I want to try different distributions like Fedora or OpenSuse, without destroying my stable working environment.

I wonder how I should do partitioning of boot partitions here. I would like to do it in the easiest possible way that would allow removing the second Linux installation easily.

I was thinking about having two boot partitions, one for each Linux. During installation of the main Linux, I could choose to put the boot loader into the MBR, and for second one into the proper partition. But then I would have to update Mint's grub every time I install a new test distribution; would that be a good solution? Also, I am not sure if I can have two EFI partitions.

What would be the most stable and safe option here?


Update 1

First of all, I did more research and realized that I was confused about a few things. I didn't know that Device for boot loader installation [1] option during Mint installation is completely ignored during installation in UEFI mode [2] (1). Also poor naming in Ubuntu installer (2) made me believe that ESP is doing the job of /boot partition, not the MBR.

Knowing that I am thinking of following partition scheme (256GB SSD drive):

Scheme:

/dev/sda1   EFI System Partition   fat32    /boot/efi    512MB    (ESP partition)
/dev/sda2                          ext2     /boot        512MB    (boot for Mint)
/dev/sda3                          ext2                  512MB    (boot for other)
/dev/sda4                          lvm2    ( / for each Linux, shared home, swap )

And then during installation of each Linux I would make 4 mounting points of correct partitions:

  • /boot/efi
  • /boot
  • /
  • swap

Is that reasonable? And do I understand correctly that option for choosing Device for boot loader installation during Mint installation is redundant in EFI mode and I should not worry about it anymore? And do I understand correctly that now shared ESP will just have a config to start loading GRUB from a boot partition it got set up as default?


Update 2

I am going with a scheme I proposed above. However, creating partitions /dev/sda1 - /dev/sda3 through GParted resulted in some errors in the Mint installer. I repeated the process by destroying these partitions and creating them again from a Mint installer and it went smoothly. /dev/sda4 I created before running Mint installer in GParted and created local volumes from terminal. This tutorial on LVM was very helpful on that [4].


Update 3

After installing Mint, I proceeded with installing Fedora (3); after that, the system by default booted into Fedora, but in the BIOS I was able to choose Ubuntu or Fedora and each of them worked well.

I change the BIOS to boot first from Mint, and then from Mint I executed:

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

which allows me basically to boot both Linuxes now.

Because I made the assumption that the other Linux is for testing purpose I more or less achieved what I wanted. If I remove Fedora and install in its place for example OpenSuse I could probably simply execute the above command again to obtain the stable boot system.


Comments

(0) I am keeping that question updated all the time just in case someone may find it useful in the future.

(1) I did installation on a different computer some time ago that had two hard drives (separate devices). /dev/sda was fully meant for Windows 10 and I wanted to install Mint on /dev/sdb. Despite the fact that I selected Device for boot loader installation as /dev/sdb it found ESP on the other drive and used that partition for booting.

(2) EFI System Partition (ESP) is named in Mint (Ubuntu) installer as EFI boot partition [3].

(3) I had to be super careful with choosing mount points and partitioning her.


Links:

[1] http://i.stack.imgur.com/Pj1wt.png

[2] https://ubuntuforums.org/showthread.php?t=2309806&p=13422658#post13422658

[3] https://askubuntu.com/a/501360

[4] https://www.howtoforge.com/linux_lvm

  • You don't want to do MBR+ESP as every different boot will most likely require a trip to firmware and boot settings change. – Michael Shigorin Aug 18 '16 at 7:55
  • Yes, now I know that. I didn't know that EFI doesn't use MBR. – Rafal Skolasinski Aug 18 '16 at 11:15
  • I think that your major issue is that you are trying to use mint installer (a tool none of us here have deep knowledge of and that changes often) together with a hand made installation path. A distro installer does not cover all possibilities a user may want to install a linux in, if it did it would be almost impossible to maintain. You are more likely after making the partitions and GRUB/mounts yourself and then completely disregard (turn off) the installers bootloader/UEFI config. Trying to use two installer's botloader/UEFI config is asking for trouble. – grochmal Aug 19 '16 at 0:40
  • Could be, I am experimenting right now with it and update will come with all my observations. But yes Mint (Ubuntu) installer is sometimes doing weird things. As my friend said, who has much more experience than I (custom Gentoo builds every half a year), graphical installers often do things i don't expect them to do. But anyway, that question (and its updates) taught me a lot of things. I hope that my updates (and solution posted in the end) will be helpful to some folks out there. – Rafal Skolasinski Aug 19 '16 at 1:14
  • I really do like grub-mkconfig, it is much simpler than playing around with UEFI. Good luck with your testing machine. – grochmal Aug 20 '16 at 0:34
4

If you are using MBR, GRUB can call os-prober to scan all partitions for bootable systems. os-prober (and its cousin, linux-boot-prober, which is called by os-prober) will search all known disks and their partitions for bootable systems. For linux systems it will search for partitions that contain ./vmlinuz* and ./initrd*/./initramfs* or partitions containing a directory called /boot and the former files.

grub-mkconfig will attempt to use os-prober if it can find it and will print a grub.cfg including all systems it found.

Personally, I find this to be less work than using UEFI but keep reading.


For UEFI, first of all you definitely can have several EFI partitions. Yet, it is not a good idea to have several EFI partitions in a multiboot system. This SU answer goes into a lot of detail why, mostly because you can have subdirectories inside a single EFI partition and have a different systems in each subdirectory. You simply make a bind mount to a different place of the EFI partition to be the /boot directory on each system.

For example you can create two different loaders, say:

\loader\entries\mint.conf

title    Mint Linux
linux    \mint\vmlinuz
initrd   \mint\initrd.img
options  root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 rw

\loader\entries\centos.conf

title    CentOS
linux    \centos\vmlinuz-linux
initrd   \centos\initramfs-linux.img
options  root=PARTUUID=14420948-2cea-4de7-b042-40f67c618661 rw

You need the UUID for the bootloader to know which root filesystem to use. Now you can place the kernel and initial ramfs of each install into their own directory on the EFI partition (one in mint and another on centos).

On each system you then make an /etc/fstab with a bind mount to use the right part of the EFI partition as the /boot directory. For example:

<EFI part> /efi vfat defaults 0 0
/efi/EFI/mint /boot none defaults,bind 0 0

and

<EFI part> /efi vfat defaults 0 0
/efi/EFI/centos /boot none defaults,bind 0 0

Each system will now be able to place its kernel in the right place on upgrade, and the boot happens through UEFI.

Links:

  • 1
    A separate ESP for an often-changed testbed is quite reasonable as the risk of accidentally formatting it (attention glitch or software bug) is way lower this way; an ESP backup that Rod Smith recommends in his advice at the last link is a good thing too. – Michael Shigorin Aug 18 '16 at 7:53
  • @grochmal Nice explanation. I updated my question about the things that are still not clear to me. – Rafal Skolasinski Aug 18 '16 at 11:16
  • 1
    @MichaelShigorin - Interesting, I have always used directories in my ESP. I need to try building two separate ESPs one of these days. – grochmal Aug 19 '16 at 0:43
  • I have installed Ubuntu and Kali in order. But Kali fstab was having Ubuntu's swap too. I commented one from fstab but still Ubuntu and Kali both uses two Swap partition. I want to correct that and use each separate swap I have created for Ubuntu and Kali. How to do that? – Satya Prakash Sep 10 '17 at 7:03
  • @SatyaPrakash - The only reason I would worry about two systems that are never booted at the same time using the same swap would be security (one system reading what is left on swap by the other). The best solution for that would be to encrypt swap, on each system with a key generated at boot time. Otherwise just generate a new swap (possibly a swap file) and point one of the systems to is (in its fstab). – grochmal Sep 11 '17 at 13:20
2

If you make a separate /boot partition and install Grub to the MBR, you do not need to update Mint's grub every time you switch OSes. I have this exact setup on my laptop with a partition for Mint, a /boot partition, and another partition I use to try out different distros. Whenever I install a new distro, I simply install os-prober and run grub-mkconfig -o /boot/grub/grub.cfg (with the /boot partition mounted, obviously) and it works fine. The only thing you need to be careful of is getting rid of old kernels and initramfs images on the boot partition when you install a new distro.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.