You are not logged in.
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 Linux
used 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 README
30_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)
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
Very helpful. Thanks. I've bookmarked this thread and will return to it as I configure my test machine.
Be eggsalad to each other.
Offline
looks good xaos! i'm sure this will prove useful to me in the future.
just a few pointers, stuff that would give me troubles when i'd read this as a complete noob (instead of the advanced noob i am now.. and some stuff i still don't know how to do ) :
1. one of the problems i faced when first building a dual-boot is how partitions work. you gloss over your 'Extended' partition, which is the key to having more than 2 (from the top of my head, or was it more?) partitions on the same disk. now i don't expect you to explain that stuff but maybe you could at least devote a small line to it, and have a link to a page that explains this stuff in more detail?
2. what happened to sda4? just wondering...
3. this:
find out what the kernel-name and initrd-name of your newly installed system are:
how do i do that? consider including the actual command you need to type to find out this info. this is where your very clear and precise how-to suddenly becomes blurry.
Offline
This is exactly the right way to do it, as expected, since it's coming from you. I wish all those guys plugging their ludicrous setups with grub1 on a separate and belonging to no OS /boot partition and similar would come here and take a look.
Last edited by el_koraco (2012-01-06 23:21:56)
Offline
What I have been doing with grub2 is similar. At least I think it is, you confused me a bit with the 40_custom file.
I pick one partition and anytime I do an install on that partition I let it install grub to the mbr. That is the only time I install grub at all is when I do an install on that one partition. When I install to any other partition I do not install grub at all. I then boot into the one partition that has grub and run update-grub.
If an install does install grub then I boot into my main partition and reinstall grub and run update-grub. Then I boot into the misbehaving system and uninstall/purge grub completely.
Doing so seems to keep everything sane and stops the duplicated entry craziness that can occur.
Last edited by AnInkedSoul (2012-01-07 01:12:02)
Offline
@Rhowald: Thanks for your input.
In fact, I did not mean to publish it yet. It is a draft version really that I posted by accident.
When I get to cleaning it up I will try to take your suggestions to heart.
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
@AninkedInSoul:
Using 40_custom like I do allows you to heavily edit the labels for your partitions, and keeps those labels unchanged when you run update-grub. Using os-prober on the other hand destroys your custom edits.
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
Thanks, el_k.
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
xaos52,
If you take advantage of the symlinks that are created for vmlinuz and initrd.img that are created when a kernel is upgraded for each of your distros and use those in your custom menu (rather than the long version that includes the version number) then you don't have to worry about the step rowaldt is asking about. Your menu doesn't need to be amended with new kernel version numbers after an upgrade of any of your multi distros because the symlinks are created automagically with the kernel upgrade.
I know since it is you doing this I don't need to spell it out any more than that. Just remember that those symlinks are in the root of each filesystem not in /boot so your menu will have to be set that way.
Offline
@AninkedInSoul:
Using 40_custom like I do allows you to heavily edit the labels for your partitions, and keeps those labels unchanged when you run update-grub. Using os-prober on the other hand destroys your custom edits.
I see! Good info. I guess I have gotten lazy anymore as os-prober is fine and dandy as long as I do not let it run for every install and start listing all my installs multiple times. Aggravating!
Offline
Thank you, Thorny.
I had tried this with manually created symlinks in /boot, but it did not work: grub2 immediately returned to the menu. This was on my todo-list.
I will add this to the howto when I get to update it.
Last edited by xaos52 (2012-01-07 17:00:18)
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
I will add this to the howto when I get to update it.
Using those symlinks is oldschool, something we used to use with grub-legacy too, I imagine that's why their creation was included in the kernel install in the first place. I am not sure that all current distros available include that automagic but all the ones I have tried do and it could be done manually if required but that wouldn't be much different from your first draft.
You expend a lot of energy around here and it is very positive, don't try to do so much that you burn out, this forum would be much less effective without the core of knowledgeable and experienced helpers.
Offline
OK. Thanks for your concern, Thorny.
I am a retired sysadmin. I have nothing else to do, and I am enjoying it.
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
... and I am enjoying it.
That is what matters!
Offline
Thanks for the how to xaos52,
Is bkmarked in case ... Am still too lazy to break away from legacy atm. Adding summin that's kind of related, as you ( others) might like the info. Your PC doesn't support boot from bios ( neither does mine come to think of it and am soooo not going to mess w upgrading bios.) Anyway ... might check out PLop. I've never bothered with it. But looked interesting for folks who want to boot from usb but have bios limitations.
Last edited by CBizgreat! (2012-01-14 14:56:40)
Some common cbiz abbreviations. This will save me time and yet @ same time tell folks what the babble is supposed to mean.
Vll ! = ( Viva la gnu/Linux !) Vl#!! = ( Viva la #! !) Last but not least, UD ... OD ! = ( Use Debian ... or die !)
Offline
Just writing in to say thanks for posting this thread. I recently created a small partition for testing new distros, and this was perfect for getting grub2 to act nice with all of my OS's.
mikhou
Offline
Thanks for the feedback
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
Hi Doc,
Just been looking at your how to but not sure if I am reading it correctly. I assume that this is a way of getting grub to put things in the order that you want them to appear in the grub menu screen that you you see when it first boots up. If that is the case my custom_40 is empty. Does that mean if I copy your code
menuentry "Aptosid, with Linux 2.6.39-3.slh.1-aptosid-686 (on /dev/sda3)"
and change the name to
menuentry "Crunchbang, with Linux (latest version testing) (on /dev/sdb1)"
it will work for me
Cheers
Gordon
Using Janice Testing at present also sid and systemd and VSIDO
A7N8X delux motherboard, 1 GB ram, AMD ATHLON XP 2800+ ( 2255 Mhz ), Nvidia Geforce PNY 62000 graphics card
Offline
Awesome thread, I wish I had found it some time ago!
I have two multi-boot set-ups, using grub2, on two different computers, but I used two approaches that are different than the OP's (not better, just different, and I am not suggesting that anyone do things this way -- I like the OP's approach better!).
On the first computer, my 30_os-prober script is not executable, but intead of the nice, neat set-up with the 40_custom file, I created custom files for each distro (except, of course, for the one on sda1). So, in /etc/grub.d, I have:
-rwxr-xr-x 1 root root 6728 Sep 25 2012 00_header
-rwxr-xr-x 1 root root 5407 Sep 25 2012 05_debian_theme
-rwxr-xr-x 1 root root 5977 Jan 20 2013 10_linux
-rwxr-xr-x 1 root root 141 Mar 22 2013 11_3_opensuse_sda9_custom_grub
-rwxr-xr-x 1 root root 467 Sep 29 19:41 11_ubuntu_sda5_custom
-rwxr-xr-x 1 root root 375 Sep 16 14:44 12_chakra_sda7_custom
-rwxr-xr-x 1 root root 698 Jul 29 18:19 14_sabayon_sda11_custom
-rwxr-xr-x 1 root root 434 Aug 26 08:23 15_bridge_sda13_custom
-rwxr-xr-x 1 root root 6335 Sep 25 2012 20_linux_xen
-rwxr-xr-x 1 root root 1570 Oct 24 2011 20_memtest86+
-rw-r--r-- 1 root root 6522 Apr 28 21:21 30_os-prober
-rwxr-xr-x 1 root root 214 Sep 25 2012 40_custom
-rwxr-xr-x 1 root root 95 Sep 25 2012 41_custom
Left out some of the files there, but you get the picture. Kind of a weird set-up, but anyway, my grub menu shows the following distros:
Debian GNU/Linux, with Linux 3.2.0-4-686-pae
openSUSE 12.3 on /dev/sda9
Ubuntu, with Linux 3.2.0-54-generic-pae (on /dev/sda5)
Chakra Linux (2013.02.07) (on /dev/sda7)
Sabayon GNU/Linux (on /dev/sda11)
Arch GNU/Linux, with Linux core repo kernel (on /dev/sda13)
Plus a recovery mode entry, a MEMTEST entry, that kind of thing. The Arch entry is actually for Bridge Linux, an Arch derivative.
I have so many partitions because I actually have separate /home partitions for each distro. sda2 is the swap partition and sda4 is the extended partition. Again, I am not recommending this approach, but the cool thing is that there are different ways to do all of this and one approach might work better for some people, another one better for others.
I don't think this set-up is any easier or any more difficult than putting all of the entries into 40_custom. I think it kinda amounts to the same thing, but it does make my /etc/grub.d directory look more messy than the OP's; his is definitely a more elegant approach, I think. The point is, you can also set things up with separate custom scripts if you want to, naming them higher than 10_ and lower than 20_, I guess. I also have some other custom scripts in there that I didn't list, they are non-executable ones that I've played around with or used in the past, but am not using now. I simply made them non-executable and left them in there for future reference. Like I said, kinda messy, but it actually works.
On the second computer, my 30_os-prober script is executable and I am not using custom entries. But my grub.cfg isn't too cluttered -- I only have Kubuntu 12.04, Debian Wheezy, and ArchBang on this computer -- so I've decided to just leavve the grub menu as it is, and it's working out fine for me.
You don't see CrunchBang above because I have CrunchBang installed alone on another computer.
I hope I'm not messing up by posting this here, or throwing stuff out there that's gonna cause confusion for anyone. If so, the post can be deleted (or moved), no hard feelings. Just trying to give people something else to look at; I think grub2 is pretty cool, once you get into it.
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat