Boot Xandros from USB for Dummies

Now you don't need to be a seasoned Linux user to build default Xandros (Eeepc Linux) on USB for your Eeepc. I have made use of the Asus EeePC System Recovery USB disk, rewriting its boot script to automate the whole process. So, now it is as simple as download 2 files: easybootusb.tgz and the usual eeepc-bootusb.tgz and unzip them to the root folder of the System Recovery USB disk. Then on reboot, instead of wiping out the SSD with a system restore, the boot script will look for another USB flash disk or SD (not the one with the Eee PC p701L.gz rescue image) and build default Xandros (Eeepc Linux) there that can boot from USB. [NB. 900 or later model users with 2 SSD please read section 7) Caveats before you reboot.]

UPDATE: I have built more packages for variations with no unionfs, and with the xepc.org recovery disk. See Downloads section for details.


DETAILED EXPLANATION

1) Introduction
2) What you will need
3) Build Asus EeePC Recovery USB disk
4) Downloads
5) The Build Process Explained (with Screenshots
6) Using default Xandros (EeePC Linux) booted from USB
7) Caveats
8) Bugs
9) Future Possibilities
Appendix I - rcS bootscript


1) INTRODUCTION

This is based on the Boot Xandros from USB method I have developed together with members of the EeeUser Forum (in particular tuxpocket who have worked out the Boot from USB volume label method) and the later "rewrite for Window users", but using the Asus EeePC System Recovery USB disk instead of Pupeee.

It is basically the same process as the steps in "A Rewrite for Window Users", but with the rewriting of the boot script of the EeePC System Recovery USB disk, I have completely automated this process so that every Eeeuser can easily do this.


2) WHAT YOU WILL NEED

A desktop PC running winxp that supports booting from CD
- A DVD ROM on your desktop PC
- The Asus P701L.gz image file of the stock distro (from the rescue DVD that comes with your eeepc).  [Update: Now it is possible to download the Eeepc 701 iso image for 4G model from SourceForge.net.  For other models, you can download the iso from http://downloads.k0k0.de/index.php?dir=EeePC%2F]
- 2 USB flash disk/SD: one as the System Recovery USB disk (1-2 GB depending on the iso) and the other for the target disk (at least 4 GB) where you will build Eeepc Linux.

Please note that if you plan to build this on an SDHC, it is better to use an external SD card reader as the built-in SD card reader is very slow and not very reliable in handling a large amount of data. In my experience, many times it will fail resulting in data loss and errors copying the image with the build-in card reader. 

Warning: Do not use an old fashioned multi-card reader for the System Recovery USB disk because the Asus boot image only support device name up to sde1. Those old fashioned multi-card reader need to have each card slot mapped a separate device name, so your USB storage card (whether SD or CF ... etc) may end up at say, /dev/sdg1 which is not supported.

Please note that it is important to have a good quality USB flash disk/SD for running Eeepc Linux. The higher the speed is of course better, but not critical unless you are always working with very big files. The quality, however, is more important. If you have a poor quality USB flash disk/SD, it will be like reading from a damaged CD, the system will freeze reading the same sector over and over again.


3) BUILD ASUS EEEPC RECOVERY USB DISK

I guess many EeePC users have experience working with the Asus EeePC System Recovery USB disk and it should be easy enough compared with the DIY methods (no need to learn how to use Pupeee). The steps are detailed in your Eeepc User Guide in the chapter on "System Recovery". For screenshots of the detailed steps, please read my blog: http://eeepc-albkwan.blogspot.com/2009/06/create-asus-eeepc-system-recovery-usb.html

The script for creating the Asus Recovery USB disk, however, is buggy and many people reported problem with it. So, after you have built the USB Recovery disk, be sure to compare the files one by one with the original in the DVD (in particular P701L.gz and user_start.dat which are critical to the recovery process) to confirm that they are the same.

If you found difficulty creating the recovery disk, you can also consult this wiki page: How to create an USB restore boot drive or in more details here: HOWTO Make a Standard USB Image under Linux.


4) DOWNLOADS

You will need to download 2 files: easybootusb.tgz (which contain the rewritten boot scripts for the Recovery disk) and eeepc-bootusb.tgz (which are the files necessary to boot Xandros from USB) OR THEIR VARIATIONS (See Below). The files should be unpacked to the root folder and the folder \runscripts\bootusb\ respectively of the System Recovery USB disk. The folder structure should be like this:

\

       
  boot\ boot\ initrd.usb
    initrd.gz     initrd.gz
  runscripts\ runscripts\ runscripts\
     bootusb\    bootusb-nounionfs\    bootusb-xepc\
       formatuser.sh       formatuser-xepc.sh
        initramfs-usb-eeepc.img       initramfs-usb-nounionfs-eeepc.img       initramfs-usb-xepc-eeepc.img
        menu.lst       menu.lst       menu.lst
        scanuser.sh       scanuser-xepc.sh
     bootusb.sh    bootusb-nounionfs.sh    bootusb-xepc.sh
  runtasks.sh runtasks.sh runtasks.sh

If you want to retain the possibility to use the Asus EeePC System Recovery disk for restoring SSD in the future, then you should backup the original boot image \boot\initrd.gz file, e.g. rename it to initrd.gz.orig.

VARIATIONS

  Select Menu for run tasks Boot Script USB Boot files EeePC model / DVD iso Remark
 1 Build default Xandros (EeePC Linux) on USB easybootusb.tgz eeepc-bootusb.tgz EeePC Recovery DVD (all models) / p701L.gz  
 2 Build default Xandros (EeePC Linux) on USB without unionfs easybootusb-nounionfs.tgz eeepc-bootusb-nounionfs.tgz EeePC Recovery DVD (all models) / p701L.gz  
 3          
 4 Build XEPC.org Recovery disc on USB easybootusb-xepc.tgz  eeepc-bootusb-xepc.tgz xepc recovery disk See this thread


5) THE BUILD PROCESS EXPLAINED (WITH SCREENSHOTS)

The build process is automatic. First, the boot script (1) will mount the System Recovery USB disk in /xan and run the script "runtasks.sh" which will offer you a select menu for run tasks. Right now, there is only 1 operation to choose. So just type "1" and press [Enter].

Then the install script "bootusb.sh" will run. It will check for another USB drive, prompt you to insert an USB drive if not found, and ask you to confirm duplicating the image onto the target drive. Depending on the speed of your USB drive and the size of the image, it will take from 5 to 20 minutes.

If there is more than 1 target USB drives found, the script will ask you to enter the target drive of your choice. You will have to judge from their sizes and whether they are SD or USB flash disks. This will most likely be the case for 900 and later models because the 2nd SSD is also USB.

After this, the script will proceed to run fdisk to create the 2nd partition (USER partition) on the target USB drive, change their volume labels to SYSTEM_USB and USER_USB, and copy the files necessary to boot Xandros from USB including:
- /boot/initramfs-usb-eeepc.img
- /boot/grub/menu.lst
- /sbin/scanuser.sh
and
- /sbin/formatuser.sh

If no error is reported (except the "Couldn't umount /xan" error), then you should be able to happily reboot (press [ESC] at the Asus splash screen and select your USB drive as first boot device) into your new Xandros on USB (Refer to your Eeepc User Guide for details).


6) USING XANDROS BOOTED FROM USB

Now you can play with Eeepc Linux booted from USB. This Boot Xandros from USB method has been proven to work with the default Simple Desktop of the Eeepc. However, many people have reported problem working with the Advanced Desktop causing USB disk failure. So, do not activate the Advanced Desktop unless you are a seasoned Linux user.

From the discussion so far, it seems that the problem is caused by the way the Advanced Desktop shut down the Eeepc and one solution I can think of is to configure the Advanced Desktop to shut down with the script /sbin/fastshutdown.sh. But since I never work with the Advanced Desktop, I have not tested on this.


7) CAVEATS

I have found some caveats for 900 and later model users with 2 SSD. If you are still using default Xandros in your 1st SSD and have /home mounted in the 2nd SSD (i.e. sdb1). At 1st boot of this Xandros on USB, it will find and mount the /home partition and will use the old settings instead of running the firstrunwizard for this new installation. Thus, if your old setting requires password for log in, you will be stuck at the login screen because the password for your new installation has not yet been set.

To avoid this situation, before you boot your new Xandros on USB, you should first delete the file /home/user/.firstrundone from your normal default Xandros. Then when your new Xandros on USB boots up, it will run the firstrunwizard just like when you first buy your EeePC - It will ask you to set timezone, password, etc.

As all these will be written to the user partition in the new USB installation, it has nothing to do with your normal default Xandros. However, sharing the same /home partition. They will share some common features, e.g. firefox settings ... Also, the same file /home/user/.AsusLauncher/requireLogin will set both installation to ask for a password to login.

UPDATE: If you prefer not to share the same HOME between the default Xandros on your SSD and the Xandros on USB. You can edit the file /sbin/fastinit in your Xandros on USB to remove the line for mounting HOME. See my post here for details.


8) BUGS

There is one bug I have not been able to fix: The System Recovery USB mounted on /xan cannot be umounted. I am not sure if this is a busybox bug or is this caused by the way I change from one shell script to another. Yet this does not seem to cause any problem (no filesystem error), so I think this is acceptable for the moment.


9) FUTURE POSSIBILITIES

While doing this, I have modified the initrd.gz in the Eeepc Recovery USB disk separating the boot script and the part for imaging the P701L.gz image, etc. into another script. Now the boot script will only load the required USB and filesystem drivers and mount the Recovery USB disk in /xan, then hand over to another script "runtasks.sh" which will offer a menu for choosing operations to run. For the moment, there is only 1 operation - "Build Xandros on USB". In the future, we can add other scripts for performing operations which can normally only be done in rescue mode, e.g. mount SD part of the unionfs, install RAM mode, change login password, uninstall program from factory OS and much more ...

Also, right now the "bootusb.sh" script can only build Eeepc Linux on 1 whole USB disk/SD (and with unionfs). In the future, we can further modify the script to build Eeepc Linux in USB without unionfs or even on selected partition(s) in the built-in 16 GB SSD (sdb). Then 900 and 901 users can share the 16 GB SSD with winxp, with Eeepc Linux installed in, say, sdb2 and sdb3.


APPENDIX I - The rcS boot script I have modified

Here is the boot script /etc/init.d/rcS inside /boot/initrd.gz, which I have modified. I started with the original bootscript from Asus. But in the process, I found that it is not reliable in seeking volume label "EEEPC..." to mount itself in /xan, so I have rewritten the codes for this.

Code:

#!/bin/sh

/bin/busybox mount -t proc proc /proc
/bin/busybox --install -s
mount -t sysfs sysfs /sys

echo "0 0 0 0" > /proc/sys/kernel/printk

insmod /modules/usbcore.ko
insmod /modules/cdrom.ko
insmod /modules/sr_mod.ko
insmod /modules/usbhid.ko
insmod /modules/uhci-hcd.ko
insmod /modules/ehci-hcd.ko
insmod /modules/libusual.ko
insmod /modules/usb-storage.ko
insmod /modules/zlib_inflate.ko
insmod /modules/isofs.ko
insmod /modules/fat.ko
insmod /modules/vfat.ko
insmod /modules/nls_cp850.ko
insmod /modules/nls_iso8859-1.ko

echo "Waiting 15 sec for USB subsystem..."
sleep 5
sleep 5
sleep 5

if [ -n "$XANDROSCDBOOTDEBUG" ]; then
   /bin/sh
   set -x
fi

DRIVE=
LABEL=
k=1
while [ -z $DRIVE ] && [ "$k" -lt "15" ]; do 
   DRIVES=`cat /proc/partitions | grep sd[b-z] | grep -v sd[b-z][1-9] | sed -n 's/.*sd/sd/p'`
   for  i in $DRIVES ; do
   TEST=`dd if=/dev/${i}1 bs=1 count=11 skip=43 2>/dev/null | grep "EEEPC"`
   if [ -n "$TEST" ] ; then
      DRIVE=$i
      LABEL=`dd if=/dev/${DRIVE}1 skip=43 count=11 bs=1 2>/dev/null`
   fi
   done
   sleep 1
   k=`expr "$k" + 1`
done

if [ -n "$LABEL" ]; then
        echo "Found $LABEL System Recovery Disk on `cat /sys/block/$DRIVE/device/model` [/dev/$DRIVE]..."

   mount -o ro /dev/${DRIVE}1 /xan -t vfat
   if [ $? -ne 0 ]; then
      mount -o ro /dev/${DRIVE}1 /xan -t vfat
   fi
   if [ -n "$XANDROSCDBOOTDEBUG" ]; then
      /bin/sh
   fi
   echo "$LABEL" > /etc/LABEL
   echo "$DRIVE" > /etc/DRIVE
   sh /xan/runtasks.sh

else
   echo "Could not find an Eee PC System Recovery Disk in USB/SD devices."
   echo "Please create the EEEPC USB or SD-Card image and retry."
   echo " Press ENTER to reboot..."
   read REPLY
   echo "Rebooting..."
   echo
   if [ -n "$XANDROSCDBOOTDEBUG" ]; then
      /bin/sh
   fi
   reboot

fi

For those who are interested: To edit this boot script, you need to gunzip the initrd.gz image and loop mount it as follows:

Code:

gunzip initrd.gz
mkdir temp
mount -o loop initrd temp
kwrite temp/etc/init.d/rcS

BACK