Dual Boot openSUSE USB Stick Installer

In the latest round of upgrades and new installs of openSUSE around here
I decided to take a different approach and use the network install and
install from a USB stick rather than a DVD.
While I was at it I decided that I'd try to make a dual boot installer
that would allow me to install either the 32-bit or 64-bit version
of the latest openSUSE (version 11.3) from the same USB stick.

Both of the openSUSE installers above are already bootable,
but the idea here is to be able to run either one, so we want to boot the USB stick
independent of either installer and be shown a menu that allows us to select
the installer to run.
To do this we'll use syslinux, which you'll probably need to install.
Assuming you're using openSUSE to build the installer, install syslinux
with the following command:

$ zypper in syslinux

Plug in your USB stick if you haven't already done so and find
out what its device file is, you can do this by looking at the
messages at the end of /var/log/messages or by mounting the stick
and typing the mount command to view what's mounted and where.
The device file should have the form /dev/sdX, where the X will
be different depending on how many drives your system has.
Once you know the device file you should unmount the drive if it's mounted.

The first step is to create a number of partitions on the drive.
I use fdisk for this but any partitioning tool should work.
Create the following partitions:

Partion 1: Size: 20MB, Type: FAT16 (type code: 4)

Partion 2: Size: 200MB, Type: FAT32 (type code: c)

Partion 3: Size: 200MB, Type: FAT32 (type code: c)

The first partition is used to hold our menu for selecting the
installer to boot.
The 2nd and 3rd partions are used to hold the individual openSUSE installers.

Now format the partitions:

$ mkfs.msdos /dev/sdX1
$ mkfs.vfat /dev/sdX2
$ mkfs.vfat /dev/sdX3

Now we need to mount each of the openSUSE installer images and
create bootable disks using the mkbootdisk script that's
included with the installer.

The mkbootdisk command expects a --32 or --64 option to
specify the bitness of things, the --partition option to tell
where the bootable image is going to be created, and the source directory
for the files that are to be copied to the bootable image (in our case /mnt).

Now that we've got the openSUSE installers on the USB stick
we install our menu by installing syslinux on the first partition.
Then we have to mount the partition and copy the syslinux
menu program, chain loader program, and our configuration files to it (see below and the attachments).

The above tells syslinux that the default (and only) boot option is "opensuse"
and that we don't want syslinux to display its boot: prompt.
The opensuse option boots the "com32" program "menu.c32" which we copied to
the USB stick above.
So here, rather than booting Linux, we're booting a helper program that comes
with syslinux. This helper program, as you've probably already guessed since it's named menu,
displays a menu. The append/menu.cfg option here adds the name of the menu configuration
file to the end of the command line that executes the menu program.
The menu configuration file contains our menu:

Here we can see our boot options, one to boot from the harddisk,
which is the default and happens after the timeout of 60.0 seonds.
The other options are to boot the 32-bit openSUSE installer
and to boot the 64-bit openSUSE installer.

When booting one of the openSUSE installers the boot is done by
executing another syslinux helper program: chain.c32
(which we also copied to the USB stick above).
This helper program boots another boot loader by loading the
MBR of another disk or partition.
The append options to each of the chain loaded installers specifies
what partition to boot use: appendboot2 boots the 64-bit installer
on partition 2 and appendboot3 does the 32-bit installer on partition 3.

At this point your new dual boot openSUSE installer should be ready to run,
except for one possible caveat: if the MBR on your USB stick isn't valid you'll
need to install a new MBR.
Test it, if it doesn't boot, then try copying a new MBR to the USB stick with the following command:

$ dd if=usr/share/syslinux/mbr.bin of=/dev/sdX bs=440 count=1

If all goes well you should see the following when you boot the USB stick:

If you have a big enough USB stick you could also create full installers
by using the DVD installers instead of the NET installers.

Note that most of the above commands will need to be run as root, so be careful.
Also note that if you are not using openSUSE to create the installers the
path to the syslinux files may be different.

Try forcing the partition to be FAT16 when you create it by passing '-F 16' to mkfs.vfat (or mkdosfs). Although that may not work with a 5GB partition (I'm not sure if the 2GB limit for FAT16 is still valid or not).

Note that as I look back at the article it could be that I misspoke when I said you could do this with the DVD installer. Could be that only the CD installer will work. There may be a way around this but since I haven't tested it I can't be sure.

Great job. I was looking for a explanation like that for some time. The only thing is that it don't want to boot from hard drive. Even from inside NET installers. I just triggers loader from USB. Any ideas what may be causing that?

One more thing I would like to ask. Its about partitioning. The thing is I want to add more features on my 8 GB USB. One is DVD installer you mentioned in your article. The thing is that maximum amount of main partitions is 4. How to set it up so I could use extended partitions and get total amount of 5 partitions.

As far as partitions go it should be pretty simple: according to the syslinux wiki page on using the chain loader you should be able to create normal extended partitions and use numbers of 5 and up to reference them when booting.

Yes that system. :] Although it worked I still have problems running Crapdows from NTLDR. I was hoping that this boot loader will be able to boot any operating system without so called New Technology Loader help. It was actually just curiosity I can always reboot machine from loader stage.

Very nice suggestion for a dual boot installer. As a side note, I never warmed up to SUsE, starting back in the days when they still used the silly capitalization for their name. One of our clusters at work was built with Suse, and it just seems funky; nothing was where it was in other distros that I had worked with. Part of my dislike of Suse is no doubt that you like what you are used to, Mint 9 being my current favorite. Suse certainly has a following though, so it must be pretty solid.

There's an important point in what you say: "what you are used to". A friend of mine who some years ago worked for Sun Microsystems used to say how people would beat them up over why Solaris was so much harder to use than Windows. Yet, when he tried to do anything with a Windows machine it was a constant struggle compared to Solaris because it wasn't what he knew.

On the one hand a consistent Linux would be nice, a version where everything is where it is everywhere else, a version that always works the same even when it works incorrectly, a version where nobody innovated... and we could call it Windows.

I agree that competition is a good thing, Mitch. All the Linux distros out there contending with each other have a general strengthening effect.

There is one disadvantage to having this proliferation of Linux offerings to choose from, however: it makes it confusing for new users to select one. They might talk to a Fedora fan who claims that Fedora is the best thing since sliced bread. And then get the very same story (repurposed) from a K/Ubuntu fanboi.

The Linux competition has even benefited M$ And Mac users -- there can be no slacking off when the competition is just around the corner waiting to gobble up market share. I credit a little bit of Windows 7's polish -- as compared to Vista, anyhow -- with the pressure that Redmond perceives from that "Linux cancer".

Trending Topics

Webinar: 8 Signs You’re Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
11am CDT, April 29th

Join Linux Journal and Pat Cameron, Director of Automation Technology at HelpSystems, as they discuss the eight primary advantages of moving beyond cron job scheduling. In this webinar, you’ll learn about integrating cron with an enterprise scheduler.