Topic: How do you manage multiple distros with grub2?
I think sometimes you can learn more from one concrete example than from an entire book, so here is how I manage things with grub2.
Following is the output of the 'fdisk -lu' command for /dev/sda ( 80GB HDD )
/dev/sda1 * 2048 39064547 19531250 83 Linux
/dev/sda2 78129150 156301311 39086081 5 Extended
/dev/sda3 39065600 78127103 19530752 83 Linux
/dev/sda5 155258880 156301311 521216 82 Linux swap / Solaris
/dev/sda6 78129152 107423743 14647296 83 Linux
/dev/sda7 107425792 130861055 11717632 83 Linux
/dev/sda8 130863104 155252735 12194816 83 Linuxused as follows:
sda1: my 'main' linux system: #! february upgraded to sid
sda3: #! february upgraded to aptosid
sda5: common swap file
sda6: #! february upgraded to testing
sda7: #! november
sda8: #! november
The differences between similar installs are customizations/installed packages.
I manage the grub2 menu from /dev/sda1.
/sudo:root@crunchie:/media/sda1/etc/grub.d:
total 76
drwxr-xr-x 2 root root 4096 Jan 4 13:34 .
drwxr-xr-x 152 root root 12288 Jan 4 13:39 ..
-rwxr-xr-x 1 root root 6711 Aug 9 02:46 00_header
-rwxr-xr-x 1 root root 5407 Jan 18 2011 05_debian_theme
-rwxr-xr-x 1 root root 5947 Aug 9 02:46 10_linux
-rw-r--r-- 1 root root 6344 Aug 9 02:46 20_linux_xen
-rw-r--r-- 1 root root 5975 Aug 9 02:46 30_os-prober
-rwxr-xr-x 1 root root 3122 Jan 4 13:34 40_custom
-rwxr-xr-x 1 root root 95 Aug 9 02:46 41_custom
-rwxr-xr-x 1 root root 2155 Dec 23 00:36 60_grub-imageboot
-rw-r--r-- 1 root root 483 Aug 9 02:46 README30_os-prober is not executable.
The rest of the files is standard, except for 40_custom, where I put the grub2 menu items for all partitions, except for /dev/sda1.
40_custom:
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Aptosid, with Linux 2.6.39-3.slh.1-aptosid-686 (on /dev/sda3)" --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos3)'
search --no-floppy --fs-uuid --set=root 8054743d-4ba9-43c2-94d9-1d94972495f7
linux /boot/vmlinuz-2.6.39-3.slh.1-aptosid-686 root=UUID=8054743d-4ba9-43c2-94d9-1d94972495f7 ro vga=793 quiet nomodeset
initrd /boot/initrd.img-2.6.39-3.slh.1-aptosid-686
}
menuentry "Crunchbang 20111125 upgraded to testing, with Linux 3.1.0-1-686-pae (on /dev/sda6)" --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos6)'
search --no-floppy --fs-uuid --set=root 74a0c02a-40a8-4345-b051-a6fe7b449cbb
linux /boot/vmlinuz-3.1.0-1-686-pae root=UUID=74a0c02a-40a8-4345-b051-a6fe7b449cbb ro quiet nomodeset vga=793
initrd /boot/initrd.img-3.1.0-1-686-pae
}
menuentry "Crunchbang 20111125 upgraded to testing, with Linux 2.6.39-bpo.2-686-pae (on /dev/sda6)" --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos6)'
search --no-floppy --fs-uuid --set=root 74a0c02a-40a8-4345-b051-a6fe7b449cbb
linux /boot/vmlinuz-2.6.39-bpo.2-686-pae root=UUID=74a0c02a-40a8-4345-b051-a6fe7b449cbb ro quiet nomodeset vga=793
initrd /boot/initrd.img-2.6.39-bpo.2-686-pae
}
menuentry 'CrunchBang 20111125-fresh, with Linux 2.6.39-bpo.2-686 (on /dev/sda7)' --class debian --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos7)'
search --no-floppy --fs-uuid --set 2987b1e7-7b8b-47f3-9f0e-093a179f71ff
linux /boot/vmlinuz-2.6.39-bpo.2-686 root=UUID=2987b1e7-7b8b-47f3-9f0e-093a179f71ff ro quiet splash nomodeset vga=793
initrd /boot/initrd.img-2.6.39-bpo.2-686
}
menuentry 'CrunchBang 20111125-fresh, with Linux 2.6.39-bpo.2-486 (on /dev/sda7)' --class debian --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos7)'
search --no-floppy --fs-uuid --set 2987b1e7-7b8b-47f3-9f0e-093a179f71ff
linux /boot/vmlinuz-2.6.39-bpo.2-486 root=UUID=2987b1e7-7b8b-47f3-9f0e-093a179f71ff ro quiet splash nomodeset vga=793
initrd /boot/initrd.img-2.6.39-bpo.2-486
}
menuentry 'CrunchBang 20111125-fresh, with Linux 2.6.39-bpo.2-486 (on /dev/sda8)' --class debian --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos8)'
search --no-floppy --fs-uuid --set 39de84dd-b68a-43e2-99ed-4b25abcf409e
linux /boot/vmlinuz-2.6.39-bpo.2-486 root=UUID=39de84dd-b68a-43e2-99ed-4b25abcf409e ro quiet splash nomodeset vga=793
initrd /boot/initrd.img-2.6.39-bpo.2-486
}• How do I install a new distro?
Lets say I want to install a fresh #! on /dev/sda8 (overwriting what is currently there)
I install from CD-ROM (my old laptop does not support booting from USB).
I always perform a non-graphic, custom install, only touching data on sda8 and the swap file on sda5 ,which
- overwrites the sda8 data
- creates a new filesystem on sda8
- installs / on sda8 -> all installs have their own root directory, no separate /home partitions
- at the end you are asked where to install grub2:
now the #! install allows you to go on, leaving the device where grub has to come blank.
- install finishes and wants you to reboot.
- when you reboot, you will be presented with the old grub menu, because the grub on the MBR is not changed by the new install.
- to be able to boot into your new system, boot into the main system first (sda1)
find out what the kernel-name and initrd-name of your newly installed system are:
sudo geany /etc/grub.d/40_custom remove the entry/entries for sda8
sudo mount /dev/sda8 /media/sda8
sudo geany /media/sda8/boot/grub/grub.cfg copy the entries for sda8 to the clipboard
paste into the geany window containing 40_custom
save 40_custom
sudo update-grub -u -k all reboot your system
you should have a grub menu that includes the new distro on sda8
select that entry
enjoy your fresh install.
Remark:
If you are installing a linux distro that does not let you skip the grub2 install, then:
let it install to the MBR
As a new grub2 is being installed to the MBR, the autoprobe will be active
When you reboot you will have a new grub2 menu, with everyting it found and your new distro in first place.
Do not boot into the new system, select sda1 (your main system)
in your main system:
1. sudo grub-install /dev/sda this will re-install grub in the MBR, so that it points again to your 'master' distro, not to the new one
2. sudo update-grub this will update the grub menu, and include an entry for the new install.
Reboot
You are presented with your old grub menu, and it allows you to boot into the new one.
I consider this as being worth helping out the crunchbang community for a whole week.
Feedback is always welcome. Good and bad.
If it was of some help to you please mention it in this thread.
Last edited by xaos52 (2012-01-06 14:23:53)