Multiple boot images on one SD card?


19 posts
by Kushan » Mon Apr 30, 2012 8:26 am
Hi everyone,

I'm not brilliantly familliar with Linux, so apologies if this is a really obvious yet stupid question but I was wondering if its possible to load multiple OS/Distributions onto one SD card?

I have a Pi and I've been playing around with debian and openelec but I only have one SD card. It's a 16Gb card though, so plenty of space and it'd be cool to fill it with the various distributions that are lying around rather than having to format it each time.

However, I'm wondering how plausible this is and what limitations there may be?

I know on most windows machines, you can only have 4 partitions per drive due to limitations mainly with BIOS (I believe). I also believe that UEFI can have more partitions and thus presumably more OS's. However, it's my understanding that most linux distributions require a couple of partitions (there seems to be a lot that use a FAT32 and an EXT combination) and I'm not really sure where the Pi falls in all of this (Does it even have a  "BIOS" or something similar?).

In any case, can anyone suggest what is possible and point to a guide on it? The dream is to have this little credit card sized device with about 10 different OSs on it, for giggles and lols (And easier switching to XBMC when I'm not playing with it =P).
User avatar
Posts: 26
Joined: Tue Apr 17, 2012 7:49 pm
by Techmeology » Mon Apr 30, 2012 9:08 am
To do this properly, you'd need some kind of bootloader that presents a menu on start up. However, you could use cmdline.txt to change the root partition. So you could have one distribution on partition 2, and another on partition 3, and use the root=/dev/mmcblk0p2 or root=root=/dev/mmcblk0p3 to switch between them.
Check out cool stuff I'm doing, e.g my PIC Programmer for the Raspberry Pi: http://www.techmeology.co.uk/rpipic/
Posts: 30
Joined: Wed Mar 28, 2012 8:52 pm
by Kushan » Mon Apr 30, 2012 11:48 am
Yeah, I figured we'd have to use GRUB or something to do it properly.
User avatar
Posts: 26
Joined: Tue Apr 17, 2012 7:49 pm
by plugwash » Mon Apr 30, 2012 11:56 am
Some settings which you will likely want to change between images (e.g. the memory map) will require a reboot to clear.

If I was doing a menu system for the Pi I think i'd have the SD card set up to boot into the menu system most of them time. When you select an entry from the menu it would setup the boot files for that entry and then reboot the Pi.

A script would then be added to each OS to reset the boot files back to the menu as early as possible in the boot process (what i'd be tempted to do is launch the script with init= on the kernel command line and then have it exec the normal init process when it finishes).

As for number of partitions PC style partition tables support 4 primary partitions. Of those four primary partitions one can be an "extended partition". The extended partition in turn contains partitions known as "logical drives". Afaict the partition table structure itself imposes no limit on the number of logical drives but I think linux does have a limit on the number of partitions it can see.
Forum Moderator
Forum Moderator
Posts: 2284
Joined: Wed Dec 28, 2011 11:45 pm
by mahjongg » Mon Apr 30, 2012 12:14 pm
booting multiple partitions was one reason I proposed a "boot menu" was needed for the R-PI (the other reason being the need to boot a distro with a memory split of the users choice). See:

http://www.raspberrypi.org/for.....-of-choice
User avatar
Forum Moderator
Forum Moderator
Posts: 5561
Joined: Sun Mar 11, 2012 12:19 am
by Kushan » Mon Apr 30, 2012 6:00 pm
Yeah, I wasn't thinking anything massively fancy, just a menu when you boot the pi that maybe has a "default" selection after 30s - you know, just your standard boot menu.

I just don't know how to go about doing that, particularly as SD cards tend to be loaded up in advance whereas on a PC the bootloader stuff tends to be taken care of during OS installation. I presume that, ultimately, it's just a case of getting the partitions right and editing some config files but I'm really not sure where to begin.

Once that's done, I guess there's a way to extract the necessary files from a .img file?
User avatar
Posts: 26
Joined: Tue Apr 17, 2012 7:49 pm
by Techmeology » Mon Apr 30, 2012 9:25 pm
Although the RPi distros are generally distributed as images, it's possible to extract the partitions, and shuffle them around as you see fit. I expect it would also be possible to create installers (that either expand them selves onto the SD card, or that read from a memory stick, create and write a custom image, or something of this nature).

The maximum number of installed distros, it should be possible to use logical partitions.

As for a menu system, the easiest approach is probably as plugwash suggested.
Check out cool stuff I'm doing, e.g my PIC Programmer for the Raspberry Pi: http://www.techmeology.co.uk/rpipic/
Posts: 30
Joined: Wed Mar 28, 2012 8:52 pm
by Gert van Loo » Mon Apr 30, 2012 9:43 pm
As the GPU always boots first a really nice boot selector would run on the GPU and select the image you want. I don't think it is that difficult so I assume in due time  a Broadcom SW engineer will spend an evening on adding that to the GPU boot code.

You can always ask and offer some incentive <a beer or two>.
User avatar
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2060
Joined: Tue Aug 02, 2011 7:27 am
by Kushan » Tue May 01, 2012 8:05 am
I would happily donate a beer or two! Although I'm a programmer myself, I don't have any experience with low-level hardware stuff to be able to do something like this myself (although I'd love to learn), so if guilting some engineer into writing some code (using wonderful, wonderful beer!) that we can all benefit from is a way I can help out, I'd be glad to!

Just point me to a donation page or something and I'm there!
User avatar
Posts: 26
Joined: Tue Apr 17, 2012 7:49 pm
by dom » Tue May 01, 2012 9:16 am
@gert while displaying a loader menu from start.elf is straightforward, we have no USB driver until Linux loads, so can"t act on key presses.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4034
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by nick.mccloud » Tue May 01, 2012 9:29 am
Could we have another setting or another setting file to point to the desired boot partition - at least then we can change it from the Pi even if we boot in to another distro to do so?
User avatar
Posts: 795
Joined: Sat Feb 04, 2012 4:18 pm
by Techmeology » Tue May 01, 2012 9:51 am
That's already possible by changing cmdline.txt's root option (and optionally changing the kernel image).
Check out cool stuff I'm doing, e.g my PIC Programmer for the Raspberry Pi: http://www.techmeology.co.uk/rpipic/
Posts: 30
Joined: Wed Mar 28, 2012 8:52 pm
by markb » Tue May 01, 2012 10:31 am
Would it be possible to load a small linux image (such as puppy) and from there re-load another image? That way keyobards/mice etc would be supported.
User avatar
Posts: 124
Joined: Thu Nov 17, 2011 8:09 am
by nick.mccloud » Tue May 01, 2012 11:37 am
Techmeology said:


That's already possible by changing cmdline.txt's root option (and optionally changing the kernel image).


Cool - I've obviously not being paying attention - when I get my hands on a Pi I have a fortnights long playing session planned - shame real work will interrupt - but at least I'll have a whole summer of fun on tap!
User avatar
Posts: 795
Joined: Sat Feb 04, 2012 4:18 pm
by the_dude » Fri Jun 01, 2012 11:35 pm
hi wondering if Gerts hypothetical 'incentive' had been forthcomming yet?

my setup:

boot from sdcard, run from external hdd on relevant hdd partition, I have one partition for xmbc;one for debian squeeze, currently I'm swapping sd cards, each with pointers to one of the the two distros in cmdline.txt. Some form of boot menu at the initial load ( similar to grub) would be very handy, currently I'm switching sd cards at each boot to run the system from the relevent patition on my hard drive/or editing cmdline.txt prior to rebooting for the alternate distro.

if beer is required I'm willing to provide... ;)

LLJ&P

Rob
Posts: 14
Joined: Sun Mar 04, 2012 12:01 am
by AndrewS » Sun Jun 03, 2012 10:50 am
Rather than swapping SD cards or editing cmdline.txt you could adapt my runemu script from viewtopic.php?p=88027#p88027 to copy either cmdline_debian.txt or cmdline_xbmc.txt to cmdline.txt :)
I guess you'd want rundebian on the xbmc partition, and runxbmc on the debian partition.
User avatar
Posts: 3626
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by MVC » Mon Jun 04, 2012 7:23 am
I was hoping to be abe to boot to different flavours of linux but as the img files negate this possibilty the low cost of sd cards really makes this point moot i think. It is nice and easy to swap a card out to start Debian one time then Arch the next so i will be using that method when my new shiny pi arrives in 5 weeks! It is coming with Debian but i have downloaded Arch to play with on sd card 2.
Posts: 3
Joined: Mon Jun 04, 2012 7:11 am
by confiture » Fri Dec 07, 2012 8:55 pm
Hello,

I read in a magazine few weeks ago
that there was in a single iso available with multiple distro in multiboot.
Shame I did not write the reference, and no luck with google.

Anybody please know the name of that iso/"distro"

Thanks
Posts: 2
Joined: Fri Dec 07, 2012 8:50 pm
by confiture » Fri Dec 07, 2012 9:02 pm
ok after further searches it was BerryBoot
not an iso as such
maybe there is a ready iso as well...
Posts: 2
Joined: Fri Dec 07, 2012 8:50 pm