Portable SUSE

From openSUSE

Contents

Geeko PortableSUSE is a converter script which converts an existing system (the one currently running, or one on a seperate harddisk) to a system which is able to run off a USB-HDD or USB-ZIP drive.

PortableSuSE Releases

Warning
These scripts should be run from the USB! Do not run these scripts on your desktop PC. You need to install openSUSE to your USB, then when it boots to the USB for the first time, run these scripts (often you will be able to boot correctly without modification to your USB on your PC, but as hardware changes between computers, the device number for your root partition will also change; these scripts make openSUSE "detect" the location of the root drive on boot)
There is currently no script available for openSUSE 11.1. In order to install openSUSE 11.1, follow these instructions:
  • Download 11.0 Version
  • Rename the lib/mkinitrd/boot/84-mount.sh to lib/mkinitrd/boot/83-mount.sh (in the data.tar archive)
  • Run the PortableSUSE installer

Latest Release Features

  • Gives ability to use EXTLINUX instead of GRUB (better chance of boot)
  • Modifies INITRD, so that the root=???? option to the kernel is not required. Instead, the root device is auto-detected.
  • Manages NVIDIA drivers so that you can have legacy and modern drivers installed on the same system, and still have NVIDIA 3D Acceleration no matter what NVIDIA card.

Configuring GRUB

If you have one SATA internal HDD and one external USB drive installed, the /boot/grub/device.map would be:

(hd0)	/dev/sda
(hd1)	/dev/sdb
  • Notice: When booting from external drive, GRUB will regard the external drive as /dev/sda (hd0) and the internal drive as /dev/sdb (hd1), which is the exact opposite situation when booting from the internal drive.

So edit /boot/grub/menu.lst, replace all hd0 with hd1 and hd1 with hd0. (In OpenSUSE 10.3 it does not seem necessary anymore.)

In case of a future kernel update, /boot/grub/menu.lst will probably be updated by Yast: remember that the same correction (hd0 <-> hd1) will again be necessary.


Installing (for BETA version)

  • Extract the contents of the .tar.gz file to a directory.
  • Open up a console as root, and goto that directory.
  • Type ./installation and follow the prompts.

Other Way Installing

Follow the setup wizard to the configuration of GRUB

Proceed to Installation Settings

Select Expert mode in the Boot Loader Installation tab of Boot Loader Settings dialog

Select Boot from Root Partition for the Boot Loader Location option.

After the installation, SuSE will reboot automatically. Directly booting, even from the BIOS "USB Boot" will probably fail, so boot from the installation DVD again.

Proceed to Installation Mode and select Boot Installed System from Other Options, to complete the installation.

Warning

  • USB Boot of motherboards is tricky and often fails - often without notice or reason.
  • Some bioses map the USB device only on demand, so even if you have any Linux installed, you can't boot the USB key from there at the first menu level (at least with GRUB), because GRUB does't know there is a USB device there.
  • USB HDD (as opposed to USB keys) draw much power. If they are not self powered (wall plug), they sometime need to be connected to two usb sockets to have enough power. In this case they are sold with special USB cable with the necessary two plugs.

Bootable flag

Seems like even on a USB stick, a partition has to get the "bootable flag" in the USB key partition table to be bootable by GRUB or syslinux, so use any fdisk utility to verify this (it may be dangerous to trust YaST for such an unusual task.)

First option

Login as root to the new installation, run grub-install in the terminal (assuming /dev/sdb being your external USB drive):

grub-install /dev/sdb

to install GRUB on the MBR of the external drive.

  • Notice: Do not install GRUB on the MBR of the internal hard disk, otherwise GRUB will fail to boot when the external drive is removed as it cannot access /boot/grub on the external drive.

This First option may or may not work. It's possible with some bioses to be stuck with "GRUB..." written in the upper left corner of the screen and nothing more.

In fact this option should not work (this doesn't mean it doesn't :-), because there is only one "MBR", on the very first disk of your system. So you should better (also) put GRUB on the root partition (again: assuming that sdb is your external USB drive)

grub-install /dev/sdb1

For example

Second option

One can also use "syslinux", the booting system used from floppies, cd's, dvd's and now USB devices. "syslinux" is for FAT file systems and may be usefull for booting from iso images located on a key. Extlinux is for ext2/etx3 file systems, so one can use these file systems on an USB device with Linux installed.

Follow all the install procedure described here up to the end. If GRUB don't start, boot from any Linux instalation. You can probably use the very USB device install, booted through the install dvd, but you must install the package "syslinux" with YaST.

Then go root, and on the mounted USB device do the following:

cd <absolute path where the kernel is>
extlinux -i <absolute path where the kernel is>

For example, if the USB device is mounted on the /media/disk folder of a pre-installed Linux, and you have your kernel in the /boot folder of the stick:

cd /media/disk/boot/
extlinux -i /media/disk/boot/

Then create in this very same folder (/media/disk/boot/) a config file "extlinux.conf" and fill it with:

default vmlinuz
append initrd=initrd.gz

Then copy the actual USB device initrd to the new name:

cp initrd initrd.gz

This because extlinux must know the initrd is compressed by it's extension.

Then boot... and enjoy


Warning
If you run this script from your normal 11.1 desktop system hoping it'll create a bootable system on a mounted USB stick, it will damage your running 11.1 desktop system without even asking about it. At least it did for me in Mar 2009, and I had some adrenalin time cleaning up my boot-related packages. Explanations of what exactly this script does _before_ doing any damage need to be much clearer.

Configuring your hardware

Unfortunately PortableSUSE is unable to automatically detect some types of hardware, in particular displays and screens. This section contains information on how to use SCPM to maintain hardware profiles for different situations.

Script

Josef Haider made setting up the hardware on a new computer easier by writing this small script. Just save to your computer, and when you need to create a new profile, run the script and enter the information.

 #!/bin/bash
 echo "Enter profile name:"
 read pname
 echo "Creating profile..."
 scpm add $pname
 scpm switch $pname
 echo "
  title Profile $pname
  root (hd0,2)
  kernel /boot/vmlinuz splash=silent showopts vga=0x366
  initrd /boot/initrd
  " >> /boot/grub/menu.lst
 echo "Setting up SaX..."
 sax2 -r
 scpm save
 rcxdm restart

Using SCPM/Managing profiles

SCPM is a hardware profile manager, and PortableSUSE installs it so that you can manage your hardware between computers. Most often when you encounter a new computer, you'll be dropped back to the console because the X server isn't configured correctly (see below for this). To setup a new configuration for this hardware, login as root and type:

 scpm add <profile name>
 scpm switch <profile name>
 vi /boot/grub/menu.lst

You'll now be looking at a text-based editor called VIM. In this case we need to add a boot entry for our new configuration. To begin typing, press I. Move the cursor below the first entry with the arrow keys, and copy the first entry. Use the arrow keys to move to the line that begins with "title" and change the text that follows it (on the entry you just created). Now use the arrow keys to move to the line the begins with "kernel" (in the entry you just typed out), and at the end of the line, add

 PROFILE=

followed by the profile you just created. Now press ESC and type ":wq". Upon next boot, you'll have a new boot entry that allows you to boot to this configuration.

Whenever you change your hardware configuration you MUST type in a console as root

 scpm save

otherwise, when you next boot, your hardware settings will have reverted.

If you ever boot into the wrong configuration, just type in a console as root

 scpm switch <correct profile name>

You'll probably also need to restart the X server (see below).

X Server

The component of hardware that is most likely to affect the system the most is the graphics card. That's because the X server won't automatically configure itself. When you encounter a new computer, you'll almost certainly have to configure the X server from the command line. To configure the X server, save the profile and restart the X server, type the following:

 sax2 -r
 scpm save
 rcxdm restart

Changes

  • 11.0 Release Update (07/07/08)
    • Miscellaneous
      • Added failed/done detection on some script steps.
  • 11.0 Release
    • Nothing changed for the INITRD patching.
    • Bootloader installation
      • Disabled until I get a response from the SYSLINUX mailing-list.
    • NVIDIA management
      • Had to be redone because Zypper no longer provides a Ignore option.
      • The download now shows a progress (because it is done manually)
      • It will now only download the RPM if it hasn't been already downloaded
    • Miscillanious
      • Script now checks for architecture, and will warn if a 64-bit system has been installed.

Known Bugs

If you have found a bug, please add it to this list:

  • Beta download link returns 404 not found. Fixed.
  • Bootloader installation bugs. Fixed.
  • NVIDIA Management would crash if repository did not already exist (asked for verification on the fingerprint). Fixed.
  • NVIDIA GLX module does not work for new drivers. Should be fixed.
  • Major problems after NVIDIA released new drivers. Fixed.
  • Bootloader will wipe MBR in 11.0 Bootloader installation disabled.

Additional Steps to Boot Existing Windows Installation from GRUB

As stated before, GURB treat the internal drive as (hd1) and if you directly boot Windows from GRUB, it'll pause after command chainloader (hd1,0)+1 because the Windows boot loader (NTLDR) refuse to boot from a slave hard drive. To fix the problem, add two lines in the Windows entry of /boot/grub/menu.lst:

map (hd0) (hd1)
map (hd1) (hd0)

So the entire entry would be like:

###Don't change this comment - YaST2 identifier: Original name: windows###
title Microsoft Windows XP Professional
   map (hd0) (hd1)
   map (hd1) (hd0)
   rootnoverify (hd1,0)
   chainloader +1

Save changes to menu.lst and reboot, the Windows boot loader will work now.

Conclusion

Now the system can boot from SuSE's GRUB when the external drive is plugged in and the BIOS is configured to boot from external USB device. When the external drive is removed, the system will boot from the internal drive as its original state.

When USB booting fails

Some PCs are not capable of booting from an external USB drive, no matter which BIOS setting you use or what you put into GRUB menu.lst. There are alternative solutions available.

Using internal drive

Another solution is to prepare a small partition in the internal hard drive, format as ext3 and mount /boot at that partition, install GRUB directly to the MBR and configure the BIOS to boot from the internal drive. Remember to plugin the external drive while booting to SuSE. (Remove the external drive won't affect GRUB using this methoed)

Using CD-image of your kernel

It is possible to prepare a bootable CD based on your installed system. The boot-CD will load the kernel and switch over to root-partition on the external USB-drive. However, there is a big gotcha. Default SuSE kernels have USB-drivers as modules making the root-partition unaccessible. To remedy this you need to do one of these:

  • You need to compile your own kernel and include USB-drivers in the kernel.
  • Include USB-modules in the init RAM-disk
    1. Modify /etc/sysconfig/kernel, section INITRD_MODULES to contain usb-storage and ohci-hcd/uhci-hcd/ehci-hcd depending on your system setup. Use lsmod and check which one you're running.
    2. Execute command mkinitrd to make previous change effective.
    3. Now your initrd has required modules in it. Go create the boot-image.

RedHat Linux has a script capable of creating a boot image. Make sure you have mkisofs and syslinux packages installed. Download and save a modified (SuSEfied) version of the bash-script. Check your kernel version (cat /proc/version or ls -l /boot/vmlinuz*) and execute the script:

./mkbootdisk.from.rh5-modified --device boot.iso -v --iso 2.6.18.2-34-default

boot.iso is the filename of ISO image to be created.
2.6.18.2-34-default is the kernel version to be put into the image.

Now burn the ISO-file into a CD and boot from it.

Xen

If you're running Xen, the above boot image will not work. The command line for Xen-kernels is:

./mkbootdisk.from.rh5-modified --device boot.iso -v --iso --xen 2.6.18.8-0.5-xenpae

boot.iso is the filename of ISO image to be created.
2.6.18.8-0.5-xenpae is the kernel version to be put into the image.

Using the Linux Volume Manager (LVM) for root on the USB disk

If your USB disk uses the Linux Volume Manager (LVM) to contain the root filesystem, the built-in /init script won't find it and will drop to a shell in the initrd environment. To work around this, apply the following patch to /sbin/mkinitrd and re-run it:

--- /root/mkinitrd-orig	2007-03-24 20:54:03.000000000 -0700
+++ mkinitrd	2007-03-24 21:22:26.000000000 -0700
@@ -2445,6 +2445,16 @@
 	|		break;
 	|	    fi
 	|	    sleep 1
+	EOF
+
+    if [ -n "$root_lvm2" ]; then
+    cat_linuxrc <<-'EOF'
+	|           /sbin/lvm vgscan
+	|           /sbin/lvm vgchange -ay
+	EOF
+    fi
+
+    cat_linuxrc <<-'EOF'
 	|	    echo -n "."
 	|	    timeout=$(( $timeout - 1 ))
 	|	done


Suggestions

Have a suggestion? Add it here.

  • GUI version. Possibly in the future. I've tried using Kommander (in the first release), but the results weren't as good as what the console version provides. If I was to rewrite it in GUI version, I would do it in Qt, but unfortunately, these days I really don't have the time to rewrite this script in Qt. (Although if someone wants to do it, the source is there, and you are free to convert it to a GUI.)
  • Ability to use this from a Windows Desktop and using the OpenSuse CD - in other words: users don't have to install Linux on the computer... it would copy the system directly from the CD into the PenDrive. Unfortunately, this software is more of a patch than an install. It would require the script to be rewritten in a format that Windows can run, as well as performing all the tasks that the YaST installer normally does.
  • Ability to do installations on Pen/Flash drives. There is a nice walkthrough on how to install PortableSUSE to a USB flash drive which can be found at http://www.pendrivelinux.com/2008/03/28/usb-suse-flash-drive-install/.

Release Log

  • Alpha Release on 27/08/07
  • Beta Release on 05/10/07
  • Beta Re-release on 06/10/07 due to major script bugs
  • Beta Re-release on 07/10/07 due to bootloader installation bugs
  • Beta Re-release on 14/11/07 due to NVIDIA problems.
  • Beta 2 release on 28/01/08 after upgrading my NVIDIA card to a modern card and found major problems with the script. So I updated it and it should work correctly now. It is recommended you download the new installation program and run it (it will automatically remove existing versions before installation).
  • Release for 11.0 on 05/07/08. Bootloader installation disabled until further notice.
  • Release Update for 11.0 on 07/07/08. Bootloader installation still disabled.

Authors

James Rhodes (Contact me at jrhodes@roket-enterprises.com with the subject PortableSUSE)

Reference