Dual/tripple SD boot


30 posts   Page 1 of 2   1, 2
by Ed Raket » Sun Jun 10, 2012 8:28 pm
No i don't have my Pi yet... :( But i am curious if it would be possible to install multiple OS'es on a single SD, using a bootmanager... maybe you could configure to boot for debian/coding/quake3/networking and (easy) configure a bootmanager (so not grub2... :twisted: ) to make your choise at startup :)

Is this a good idea, or am i missing something?
User avatar
Posts: 164
Joined: Mon Apr 30, 2012 4:28 pm
by itimpi » Sun Jun 10, 2012 9:43 pm
It is easy enough to put multiple distributions on the same SD card (each in its own system partition). However at the moment there is no Boot Manager that runs on the Pi that can handle switching dynamically at boot time (although I think it is just a matter of time before one is developed).

I am currently handling it in a shell script that allows me to set the OS for the next boot. As the Pi boot quickly it is not too much of a pain to have to reboot if you come up in the wrong distribution.
Posts: 1034
Joined: Sun Sep 25, 2011 11:44 am
Location: Potters Bar, United Kingdom
by Ed Raket » Mon Jun 11, 2012 7:59 pm
itimpi wrote:I am currently handling it in a shell script that allows me to set the OS for the next boot. As the Pi boot quickly it is not too much of a pain to have to reboot if you come up in the wrong distribution.


That sounds like a good solution :) , could you post an example of your script so i can have a idea how that works please?
User avatar
Posts: 164
Joined: Mon Apr 30, 2012 4:28 pm
by mxcum167 » Mon Jun 11, 2012 8:16 pm
Here's what I am using.
I have not setup Fedora to use it yet as they don't share a common kernel, also Fed 14 doesn't work too great for me, so I'm waiting for Fed 17.

Simple to use.
Create a file called switch.sh on your /root fs. Copy the code into it. chmod +x /boot/switch.sh
Create a sub directory for each distro and make a copy of the config.txt and cmdline.txt in the folders with the correct paths in the etc.

Then use /boot/switch.sh <distro_name> to copy the files over. You can add a 'sync && sync && reboot' if you want to reboot immediately.

Martin

Code: Select all
#!/bin/sh

case "$1" in
        debian)
                echo "Switching to Debian Distro"
                cp /boot/debian/debian_cmdline.txt /boot/cmdline.txt
                cp /boot/debian/debian_config.txt /boot/config.txt
                echo "Reboot to switch to Debian Distro"
                ;;
        fedora)
                echo "NOT SUPPORTED YET"
                ;;
        raspbian)
                echo "Switching to Raspbian Distro"
                cp /boot/raspbian/raspbian_cmdline.txt /boot/cmdline.txt
                cp /boot/raspbian/raspbian_config.txt /boot/config.txt
                echo "Reboot to switch to Raspbian Distro"
                ;;
        *)
                echo "Usage: /boot/switch.sh {debian|fedora|raspbian}"
                exit 1
                ;;
esac

exit 0
Martin www.chez-cummings.com
User avatar
Posts: 41
Joined: Sun Mar 04, 2012 11:56 am
Location: UK
by Ed Raket » Mon Jun 11, 2012 8:41 pm
THX Martin, for your exellent and noob proof explaination! even i will be able to use this :D
User avatar
Posts: 164
Joined: Mon Apr 30, 2012 4:28 pm
by Max » Tue Jun 12, 2012 12:05 am
Created an ugly but functional boot selection menu based on squashfs+aufs+a simple "dialog" shell script.

Image

If anyone wants to give it a try, you can dowload it from: http://www.berryterminal.com/doku.php/berryboot

Currently bundles:

  • ArchLinux
  • Debian Squeeze
  • Debian Wheezy alpha
  • Berryterminal
by AndrewS » Tue Jun 12, 2012 12:29 am
Intriguing! I'll try to find time to play with this later in the week. Aren't SquashFS images read-only though? Does that mean you can't install additional packages?

The switch.sh posted earlier is very similar to something I wrote here :) viewtopic.php?p=91559#p91559
User avatar
Posts: 3626
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by Max » Tue Jun 12, 2012 12:56 am
AndrewS wrote:Intriguing! I'll try to find time to play with this later in the week. Aren't SquashFS images read-only though?


The original SquashFS images are read-only.
However that's where "aufs" magic comes into play.

On disk there is:

/images - the original (read-only) images.
/data - all writes you make go to this folder. Each operating system image has its separate folder in there.

aufs is a union file system that combines those two folders, and makes them appear as one to the operating system.


This allows some interesting things.
E.g. if you screwed up your Debian Squeeze installation, and you want to have it back to the default settings, you can go to the rescue shell (press "cancel" in the boot menu) and do:
Code: Select all
rm -rf /data/Debian_Squeeze

to delete your own changes to the image, and start using Debian again like it was a fresh installation, without having to rewrite the entire SD card.

Does that mean you can't install additional packages?


You can use the operating system like normal, and install additional packages.
Those are stored in /data on disk (transparent to the Linux distribution, it doesn't notice that).
by AndrewS » Tue Jun 12, 2012 3:38 am
Sounds groovy. IIRC this is how the SSD on my old EEEPC was setup - with a readonly "system" partition and a read/write "overlay" partition. Which worked fine until the number of changes meant the overlay partition got filled up ;)
I think there was some stupid bug where if you created a file (that wasn't in the system partition) and then deleted it, it created a hidden file in the overlay to indicate that the file has been deleted, even though it never originally existed in the system partition! Once I discovered that I knocked up a quick shell script to delete these redundant "deleted file" markers, and regained myself some space again. :D :geek:

P.S. Is it possible to create multiple (stacked) overlay filesystems, to give you "filesystem snapshots"?
User avatar
Posts: 3626
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by Max » Tue Jun 12, 2012 9:33 am
AndrewS wrote:P.S. Is it possible to create multiple (stacked) overlay filesystems, to give you "filesystem snapshots"?


aufs does indeed support multiple layers.
Currently use that trick to share the same set of kernel modules (/lib/modules) between all the distributions.

If you want to have multiple snapshots, it might be easier/faster to switch over to the BTRFS file system instead though, that has real support for snapshots, and no inode limits.
Not sure how well that works on a SD card though, as it was not designed to be used on small file systems (it used to reserve space for its metadata in gigabyte chunks, although I believe that changed in recent versions).
by AndrewS » Tue Jun 12, 2012 11:12 am
Max wrote:aufs does indeed support multiple layers.
Currently use that trick to share the same set of kernel modules (/lib/modules) between all the distributions.

Neat :) You may want to do the same trick for the /opt/vc/ directory too (it's the other place that rpi-update updates).

Is the source code to your "bootloader" available outside of the big 1GB download?
Does the overhead of SquashFS (de)compression slow down the RPi at all, or does it make things faster because less data needs to be read from the slow SD card? Does SquashFS (or something similar) support different compression methods?
User avatar
Posts: 3626
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by Max » Tue Jun 12, 2012 12:07 pm
AndrewS wrote:Neat :) You may want to do the same trick for the /opt/vc/ directory too (it's the other place that rpi-update updates).


Considered that but left it alone for now.

/lib/modules must match the running kernel, or it will throw a fit about the symbol versions not matching, so that was essential.

Not sure what /opt/vc is more closely tied to, the kernel or userspace.
E.g. Is it guaranteed that the libaries in /opt/vc remain binary compatible with programs that were compiled to a previous version?


Is the source code to your "bootloader" available outside of the big 1GB download?


Here you go: http://www.berryterminal.com/doku.php/berryboot_linuxrc

Be aware that you need a kernel that has been compiled with aufs support, and a minimal Linux sysroot (I use buildroot.org for that)

Does the overhead of SquashFS (de)compression slow down the RPi at all, or does it make things faster because less data needs to be read from the slow SD card? Does SquashFS (or something similar) support different compression methods?


Yes, it does support different compression methods.
I used LZO because it favors speed over size.
Speed varies though, sometimes it is faster, sometimes it is slower than ext.

Compression is done in blocks. If you need to read a small file, it might need to load a larger amount of data than you wanted into memory cache, in order to decompress and reach it.
So might be slower if you only wanted that single tiny file. But will be faster if you needed the data that comes after it anyway (like applications loading all configuration files inside a single directory).
by AndrewS » Tue Jun 12, 2012 1:20 pm
Max wrote:
AndrewS wrote:Neat :) You may want to do the same trick for the /opt/vc/ directory too (it's the other place that rpi-update updates).

Considered that but left it alone for now.
/lib/modules must match the running kernel, or it will throw a fit about the symbol versions not matching, so that was essential.

Not sure what /opt/vc is more closely tied to, the kernel or userspace.

Dunno, possibly a bit of both? I think the {kernel, userspace, libraries, GPU firmware, bootloader} might be all interconnected in subtle ways http://www.raspberrypi.org/archives/592
It's not something I've really looked into.

E.g. Is it guaranteed that the libaries in /opt/vc remain binary compatible with programs that were compiled to a previous version?

Pass. But you'd hope so!

Thanks for your other info too :)
User avatar
Posts: 3626
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by Ed Raket » Tue Jun 12, 2012 3:36 pm
Max wrote:Created an ugly but functional boot selection menu based on squashfs+aufs+a simple "dialog" shell script.

Image

If anyone wants to give it a try, you can dowload it from: http://www.berryterminal.com/doku.php/berryboot

Currently bundles:

  • ArchLinux
  • Debian Squeeze
  • Debian Wheezy alpha
  • Berryterminal


Really cool stuff! THX :D
User avatar
Posts: 164
Joined: Mon Apr 30, 2012 4:28 pm
by pXc » Wed Jun 20, 2012 1:17 pm
Nice Work !

The problem is that my Windows PC doesn't recognise the Image of my SD card so i can copy back my Debian files after installing the Bootloader :(

Do you think i could keep the partitions how they are (I've resized the partitions with a 128MB swap) and keep my files if there is a way to have only Raspbmc and My Debian squeeze in the bootloader?
Posts: 22
Joined: Sat Jun 16, 2012 12:49 pm
by Max » Wed Jun 20, 2012 1:59 pm
pXc wrote:Do you think i could keep the partitions how they are (I've resized the partitions with a 128MB swap) and keep my files if there is a way to have only Raspbmc and My Debian squeeze in the bootloader?


Nope, do not support Raspbmc.
Last time I had a go at that, it started to reformat my SD card upon boot, without even prompting.
by pXc » Wed Jun 20, 2012 2:32 pm
Ah :(

Maybe there is a way of doing it by creating a separate partition for the Raspbmc that the Bootloader will fetch and perhaps not in the root partition (reformatting problem).

Anyway i don't know if you can have both separate on the SD card and launch one of them by a command line.
Posts: 22
Joined: Sat Jun 16, 2012 12:49 pm
by Blackchatte » Thu Jun 28, 2012 9:34 am
Hi,

I've received ma Raspi 3 days ago.

As a lot of users, I want to use it as media center. So, I've installed last version of OpenELEC.
But I'd like to use also Debian OS.

I'm here because I dont to change SD card in order to change OS.

So i'd want to use Berryboot and make it booting to debian or OpenELEC.
Is it possible.

Also, I'm making a remote system to switch on/off the raspi:

Very simple and cheap, I use a garade door remote system switching on/off Raspi's power supply.

All of this is to let me stay on my sofa because i'm a lazy man!

Thx

PS: sorry for my english, i'm french
Posts: 3
Joined: Thu Jun 28, 2012 9:28 am
by pXc » Thu Jun 28, 2012 11:06 am
Tu as oublié de poser une question je crois ...

Apparemment c'est pas encore possible avec XMBC
Posts: 22
Joined: Sat Jun 16, 2012 12:49 pm
by Max » Thu Jun 28, 2012 12:52 pm
Blackchatte wrote:As a lot of users, I want to use it as media center. So, I've installed last version of OpenELEC. But I'd like to use also Debian OS.


Can start OpenELEC under Debian: viewtopic.php?f=35&t=9210
Downside is that it does require that you switch to the 128 MB memory split.
by Blackchatte » Fri Jun 29, 2012 7:50 am
Thank you!

I tested this yesterday evening. It worked! I was able to launch OpenELEC and Wheezy on the same SD card.

BUT

With berryboot, in Wheezy I wasn't able to split memory (128/128) with the splash screen at the first boot. It returned me an error message.


And, OpenELEC don't recognize my USB key when I launch it on the SD card with Wheezy...

So I decided to return back to my configuration: 2 SD cards, 1 with Debian and an other 1 with XBMC...

If somebody have something that works I'll be happy to try it, but for today, I've spent a lot of precious time for nothing with this Raspi... because my tv has a USB port and if the raspi hasn't an internet browser it isn't very usefull for me...

thx
Posts: 3
Joined: Thu Jun 28, 2012 9:28 am
by Max » Fri Jun 29, 2012 1:41 pm
Blackchatte wrote:And, OpenELEC don't recognize my USB key when I launch it on the SD card with Wheezy...


Should work as long as you inserted the USB stick before starting OpenELEC.
Berryboot currently does not support changing memory splits though.
by Blackchatte » Fri Jun 29, 2012 1:51 pm
Ok

So everything is normal!

Thank you!

When do you think these "problems" will be solved? And can them be solved?
Posts: 3
Joined: Thu Jun 28, 2012 9:28 am
by Max » Fri Jun 29, 2012 4:06 pm
Blackchatte wrote:When do you think these "problems" will be solved? And can them be solved?


Can be solved by a script that changes the memory split first and reboots, if the current split doesn't match what the selected operating system needs.

Don't have that much time though, so probably will have to wait to somewhere next month.
by elatllat » Wed Jul 11, 2012 3:47 am
Posts: 1101
Joined: Sat Dec 17, 2011 5:05 pm