Articles

[HOWTO] run multiple versions of Porteus from one partition

Many thanks to fanthom, who helped me sort this out!

This tutorial is aimed at installations on USB flash drives, done from within linux, but should be applicable in other cases as well with minor modifications. The real meat and potatoes of this HOWTO is in the porteus.cfg file, in step 7.  In the example below, 32-bit and 64-bit editions of Porteus are installed, but by following the same principles you could easily install other versions (for example, versions 1.1 and 1.2 side by side, etc.) as well as other live distributions.

1) First, you'll want to mount your device (this step is not necessary if your device is already mounted):

mkdir /mnt/sdXn
mount /dev/sdXn /mnt/sdXn

Where 'X' is the USB drive device letter and 'n' is the partition to which you're installing (in my case, this is sdb1).

2) Create three directories in the root of your device:

cd mnt/sdXn
mkdir boot
mkdir 32
mkdir 64

If you already have a /boot directory from your existing Porteus install, go ahead and leave it there, just create /32 and /64.  Note that the names of the /32 and /64 directories are arbitrary, and can be anything you like, as long as you properly reference them in your porteus.cfg file.

3)Copy the /boot and /porteus folders from each of the .iso files to their respective directories. I do this by mounting the .iso files on a loop, and then copy/pasting from my file manager (konqueror or dolphin). To mount an .iso on a loop, simply use the mloop command:

mloop /path/to/iso/isofilename.iso

From a linux distribution other than Porteus, you can use the following commands to mount an .iso on a loop:

mknod /dev/loop/142 b 7 142
#add an extra loop device, in case all of your loops are already mounted
mkdir /mnt/loop
mount -o loop /path/to/iso/isofilename.iso /mnt/loop

In both examples, you would replace the path and iso filenames with the actual file you wish to mount.

Once the .iso is mounted, you can then navigate to /mnt/loop in your file manager to copy and paste the /boot and /porteus folders.

After this step, you'll have the following directories on your drive:

/boot
/32/boot
/32/porteus
/64/boot
/64/porteus

4) If your boot directory in the root of the device (/mnt/sdXn/boot) was not already populated with files from a previous installation, copy and paste (do not cut and paste!) the contents of the boot folder from either /64/boot or /32/boot to /boot.  

5) If this drive is not already bootable from a previous porteus install, run the install script:

cd /mnt/sdXn/boot
./Porteus-installer-for-Linux.com

And follow the installation wizard's isntructions.

6) (optional) Reboot with the target USB device, to ensure it boots into the bootloader menu. At this point, however, it will not successfully get into Porteus because it has not been pointed to the proper files.

7) Boot back into a working operating system, mount the target device again, and open the following file in a text editor:

/mnt/sdXn/boot/syslinux/porteus.cfg

You will want to replace the contents of that file with the following (modified for the particulars of your installation), and save it:

PROMPT 0
TIMEOUT 90
DEFAULT /boot/syslinux/vesamenu.c32
MENU BACKGROUND /boot/syslinux/porteus.png
MENU TITLE Porteus-v2.0 64bit

MENU WIDTH 28
MENU MARGIN 2
MENU ROWS 10
MENU HELPMSGROW 17
MENU TIMEOUTROW 28
MENU TABMSGROW 15
MENU CMDLINEROW 22
MENU HSHIFT 4
MENU VSHIFT 5

   menu color screen   37;40      #00000000 #00000000 none
   menu color border   30;44      #00000000 #00000000 none
   menu color title   1;36;44    #ffA32F2F #30003f07 none
   menu color unsel   37;44      #ffBDC2D9 #00000000 none
   menu color hotkey   1;37;44    #ff8037b7 #00000000 none
   menu color sel      7;37;40    #ff111B78 #003f7fbf none
   menu color hotsel   1;7;37;40  #ffaf67f7 #003f7fbf none
   menu color scrollbar   30;44      #00000000 #00000000 none

   menu color tabmsg   31;40      #ffA32222 #00000000 none
   menu color cmdmark   1;36;40    #ffff0000 #00000000 none
   menu color cmdline   37;40      #ffffffff #ff000000 none
   menu color pwdborder   30;47      #ffff0000 #00000000 std
   menu color pwdheader   31;47      #ffff0000 #00000000 std
   menu color pwdentry   30;47      #ffff0000 #00000000 std
   menu color timeout_msg   37;40      #ff809aef #00000000 none
   menu color timeout   1;37;40    #ffb72f9f #00000000 none
   menu color help      37;40      #ff666C85 #00000000 none
   menu color msg07   37;40      #90ffffff #00000000 std


#64-bit entries

LABEL xconf
MENU LABEL 64-bit KDE
KERNEL /64/boot/syslinux/vmlinuz
APPEND initrd=/64/boot/syslinux/initrd.xz from=64 changes=/64/porteus
TEXT HELP
    Run 64-bit Porteus the best way we can.
    Try to autoconfigure graphics
    card and use the maximum
    allowed resolution
ENDTEXT

LABEL lxde
MENU LABEL 64-bit LXDE
KERNEL /64/boot/syslinux/vmlinuz
APPEND initrd=/64/boot/syslinux/initrd.xz from=64 changes=/64/porteus
TEXT HELP
    Run 64-bit Porteus the same as above.
    Lightweight LXDE to be
    launched as default desktop
ENDTEXT

LABEL fresh
MENU LABEL 64-bit KDE, Fresh
KERNEL /64/boot/syslinux/vmlinuz
APPEND initrd=/64/boot/syslinux/initrd.xz from=64
TEXT HELP
    Normally Porteus saves all changes
    to the /64/porteus/changes/ directory
    on the boot media (if writable)
    and restores them next boot.
    Use this option to start a fresh
    system, no changes are neither
    read nor written anywhere
ENDTEXT

LABEL text
MENU LABEL 64-bit Text mode
KERNEL /64/boot/syslinux/vmlinuz
APPEND initrd=/64/boot/syslinux/initrd.xz from=64 3
TEXT HELP
    Run 64-bit Porteus in textmode and start
    command prompt only
ENDTEXT

#32-bit entries:

LABEL xconf
MENU LABEL 32-bit KDE
KERNEL /32/boot/syslinux/vmlinuz
APPEND initrd=/32/boot/syslinux/initrd.xz from=32 changes=/32/porteus/save.dat
TEXT HELP
    Run 32-bit Porteus the best way we can.
    Try to autoconfigure graphics
    card and use the maximum
    allowed resolution
ENDTEXT

LABEL lxde
MENU LABEL 32-bit LXDE
KERNEL /32/boot/syslinux/vmlinuz
APPEND initrd=/32/boot/syslinux/initrd.xz from=32 changes=/32/porteus/save.dat
TEXT HELP
    Run 32-bit Porteus the same as above.
    Lightweight LXDE to be
    launched as default desktop
ENDTEXT

LABEL fresh
MENU LABEL 32-bit KDE, Fresh
KERNEL /32/boot/syslinux/vmlinuz
APPEND initrd=/32/boot/syslinux/initrd.xz from=32
TEXT HELP
    Normally Porteus saves all changes
    to the /32/porteus/changes/ directory
    on the boot media (if writable)
    and restores them next boot.
    Use this option to start a fresh
    system, no changes are neither
    read nor written anywhere
ENDTEXT

LABEL text
MENU LABEL 32-bit Text mode
KERNEL /32/boot/syslinux/vmlinuz
APPEND initrd=/32/boot/syslinux/initrd.xz from=32 3
TEXT HELP
    Run Porteus in textmode and start
    command prompt only
ENDTEXT

MENU SEPARATOR

LABEL plop
MENU LABEL PLoP BootManager
KERNEL /boot/plpbt
TEXT HELP
    Run the plop boot manager.
    This utility provides handy boot-USB options for
    machines with vintage/defective BIOS
ENDTEXT

LABEL memtest86
MENU LABEL Run Memtest utility
KERNEL /boot/mt86p
TEXT HELP
    Don't start Porteus at all, but
    rather run the MemTest utility
    to diagnose your computer's RAM
    for possible errors
ENDTEXT


Note that I've used a save.dat container file for my 32-bit changes file. You must use a container for your changes whenever you are installing to a FAT or NTFS filesystem. See this article for more information on save.dat containers.

I've removed the copy2ram and PXE options from this menu, as I rarely use them, but they could easily be left in if the user wants them. Just configure them in the same format.

After this, you should be able to boot into the device, and run either edition.

A final note: Using this setup, the /boot folder contains the configuration file, bootsplash, etc., for syslinux/extlinux, but the vmlinuz kernel and initrd file from this directory are not used. Syslinux/extlinux will boot the kernel and initrd from /32/boot or /64/boot. So, any changes to the boot menu (cheatcodes, boot options, booting to .iso, etc.) need to be made to the porteus.cfg file in /boot, and any changes to the kernel and/or initrd need to be made in /32/boot or /64/boot, respectively (with modifications to /boot/syslinux/porteus.cfg if you change the kernel or initrd's name).  This does get confusing with all of the folders named 'boot', but as you get familiar with how all of the pieces work together, it will make more sense.

Happy booting!


To view the conversation about this article, to ask a question or to make a suggestion, please visit this thread on our forum.