Blog Forum Wiki Links Contact Us
 
Translations of this page:

Hacking Xandros on the EeePC

Do you want to experiment with things on the EeePC but don't want to risk messing up your working setup? Well this might be for you.

What you will need

1) A 2GB SD card. Larger is even better. A few packages have to be removed to fit things onto the SD card. This should also work with a USB stick but I don't have a 2GB stick to test. EVERYTHING WILL BE ERASED FROM THIS AND ITS FILESYSTEM WILL BE FORMATTED TO EXT2. IT WILL NO LONGER WORK IN CAMERAS ETC. UNLESS IT IS REFORMATTED AGAIN.

2) Another disk, USB, CF, SD doesn't really matter. You will need about 3GB of free space Alternatively, another Linux box with any version of linux installed

3) No fear of the command line.

IMPORTANT. Some of the steps here are critically dependent on being done correctly to the correct device. Getting one of these steps wrong could leave your EeePC refusing to boot and the only way to recover is via the rescue DVD. If you do some of the steps on another PC then you could leave that PC in an unbootable state. If you don't understand how /dev/sda, /dev/sdb etc represent different drives in your system and how to identify which device maps to which drive then you probably don't want to try following this.

With that warning out of the way lets get started.

Open a terminal. (CTRL-ALT-T in easy mode) and switch to root sudo /bin/bash

Getting Started

First we need to get a copy of the /dev/sda1 partition. This can take a little while depending on the speed of the USB devices. (These steps are fairly safe. About the worst that can happen here is that you start to copy to the EeePC internal drive and fill it up).

If you are going to use another PC to do most of the work then:

1. Insert the SD card into the EeePC
2. Check where the SD card has been mounted. (/Media/C: ?)
3. cd to this directory.
4. If there is anything on the SD card then delete it.
5. dd if=/dev/sda1 | gzip > sda1.img.gz
wait for the command to finish (will take a while)
6. unmount the SD card (you will have to cd off the card first, just type cd
   to return to /root)
7. Mount the SD card in your PC
8. Copy the sda1.img.gz file to your PC
9. Open a terminal on your PC
10. gunzip sda1.img.gz

(You might want to save a copy of sda1.img.gz somewhere on your PC to save you having to go through these steps again because later on we're going to overwrite the copy on the SD card)

If you are using a USB drive etc then

1. cd to your drive
2. dd if=/dev/sda1 >sda1.img

You will now have a file called sda1.img that is a little over 2Gb in size.

If your SD card is greater than 2GB then you can ignore the next step

Shrinking the image to fit on the SD card.

(Note that this does not change the size of the sda1.img file)

N.B. If you are doing this work on the EeePC then you should mount this image somewhere in /tmp. There are problems with trying to mount loopback devices on a unionfs

create a directory to mount the image:

mkdir -p /tmp/sda1
mount -t ext2 -o loop sda1.img /tmp/sda1

chroot to this image

chroot /tmp/sda1 /bin/bash

Be VERY sure that this has all worked before continuing.

remove some packages. I'm removing all the chinese etc, samba, nfs, and all games. Don't worry about the errors that will appear while this is happening. They don't matter.

(Do NOT run apt-get update or apt-get upgrade at this point. If you get it to work - which requires setting up resolv.conf - then you will create extra files using up disk space)

mount -t proc proc /proc
cd /var/lib/dpkg/info
for i in $( ls *-cn*.list *-tw*.list *-zh*.list | sort -u ); do
  apt-get -y remove --purge ${i%.list}
done
for i in samba-common portmap libnfsidmap2 xandros-sambaconfig planetpenguin-racer-data libkdegames1 kdegames-card-data acroread frozen-bubble-data fb-music-high crack-attack gnome-sudoku ltris tuxmath tuxtype; do
  apt-get -y remove --purge ${i}
done
rm -fr /usr/lib/Adobe
umount /proc
exit
rm /tmp/sda1/root/.bash_history
umount /tmp/sda1
Setting up the SD card partition table.

These steps are dangerous. Be VERY sure you're writing to the correct device and be very careful about typos. I'm going to assume your SD card is /dev/sdb. Replace all instances of /dev/sdb with the correct device if this isn't the case

Make sure the card isn't mounted anywhere. You can type

mount

to see what is mounted. if you see any /dev/sdb<number> lines then you need to unmount them

umount /dev/sdb<number>

should unmount it provided nothing else is accessing it.

fdisk /dev/sdb

Now lets delete all the partitions. The following will delete all the partitions but might give some errors if certain partitions don't exist. Don't worry about the errors

d
1
d
2
d
3
d
4

Now lets create some partitions. Primary partition 1 starts at cylinder 1 and is 1840M in size. Primary partition 2 uses the rest of the disk. If you're using a card >2GB then replace the 1840 with 2353

n
p
<enter>
+1840M
n
p
2
<enter>
<enter>

Finally, write the partition table back. At this point you are committed and will wipe everything on the card. If you're not sure then type 'q' here otherwise 'w' will write the partition table and exit.

w

If you see a message something like:

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

then reboot at this point. The next steps will not work properly although they will look like they've worked.

Formatting the SD card.

Again, be very sure you've got the right device. I have typed /dev/hdb1 instead of /dev/sdb1 before and had to resort to backups to recover my system.

Check the card is not mounted then

mke2fs /dev/sdb1
mke2fs -j /dev/sdb2
Copying the image onto the SD card.

mount the SD card. You might just be able to eject the SD card and then plug it in again. I've disabled the automount on my system

mount /dev/sdb1 /mnt/sdb1

mount the image

mkdir -p /tmp/sda1
mount -t ext2 -o loop sda1.img /tmp/sda1

If you've allowed the automounter to mount the SD card then check where it's been mounted and replace /mnt/sdb1 in the commands below

cp -dpR /tmp/sda1/* /mnt/sdb1/

unmount things again

umount /tmp/sda1
umount /mnt/sdb1

This command might take a bit of time to run because it will be flushing all the buffers to the SD card.

Installing grub.

More very dangerous steps.

grub --no-config-file

This will take you to the grub prompt.

device (hd0) /dev/sdb
root (hd0,0)
setup (hd0)
quit

If you get any errors with any of these lines then stop and quit. Either you're looking at the wrong device or one of the steps above hasn't been done properly.

Testing the SD card will boot.

We are not yet done but we'll test what we've got so far. If we're correct to here then we should be able to boot the EeePC from this SD card (but the EeePC will continue to use the internal disk once it's booted)

Reboot the EeePC. At the <press F2> startup screen press Esc. You should then get a boot menu something like:

HDD:SM-SILICONMOTION SM223AC
USB:USB2.0 CardReader SD0

Select the USB CardReader option and see if the EeePC still boots. If it doesn't then don't worry. Just power off the EeePC (If necessary take the battery out) and then reboot without pressing Esc and go back to the top of these steps and start again.

If the EeePC does boot up it should look exactly the same as it usually does.

IMPORTANT: If, by any chance, you do get dropped into the Factory Reset option, do NOT say yes. This will NOT reset the SD card to factory default. It will reset the internal hard disk.

Changing the SD card so that the EeePC boots and uses the SD card for it's disk.

We have to do a few things here to get the EeePC booting to the SD card.

1. Fix menu.lst 2. (optional) fix scanuser.sh and formatuser.sh. 3. Fix the initramfs

Mount the SD card.

On the SD card you will find a file called boot/grub/menu.lst (Do not edit /boot/grub/menu.lst on the main disk. It won't do any harm but it won't do any good either and will just confuse you in the future)

Open it in your favourite editor.

These first two steps are not essential but make it easy to tell you are using the SD card and not the internal disk.

Comment out hiddenmenu

#hiddenmenu

Change Timeout to 10

timeout=10

Change root=/dev/sda1 to root=/dev/sdb1 user=/dev/sdb2 throuought the file.

kernel /boot/vmlinuz-2.6.21.4-eeepc quiet rw vga=785 irqpoll root=/dev/sdb1 user=/dev/sdb2
kernel /boot/vmlinuz-2.6.21.4-eeepc quiet rw vga=785 irqpoll root=/dev/sdb1 user=/dev/sdb2 XANDROSSCAN=y
kernel /boot/vmlinuz-2.6.21.4-eeepc quiet rw vga=normal nosplash=y irqpoll root=/dev/sdb1 user=/dev/sdb2 XANDROSRESTORE=y

Save your changes.

(You might need to use something different to sdb here if you're using a USB drive)

scanuser.sh and formatuser.sh have /dev/sda1 hard coded. This makes them dangerous on the SD card because selecting the Factory Reset option will format the internal disk.

Option1: delete sbin/scanuser.sh and sbin/formatuser.sh from the SD card. This will just stop them working.

rm sbin/scanuser.sh
rm sbin/formatuser.sh

Option2: Change sbin/scanuser.sh and sbin/formatuser.sh to use the correct drive: At the top of each file (after the #!/bin/sh line) add

USER=$1
shift

And everywhere in the file where there is /dev/sda2 replace it with $USER (On my system there are two occurrences in each file that need fixing)

Save these changes.

Now the tricky bit. We need to change the initramfs.img. This is done off the SD card.

copy the boot/initramfs-eeepc.img to a working directory (e.g. somewhere in your home directory) create a directory for us to work in.

mkdir initramfs

Expand the initramfs image into this directory

cd initramfs
gunzip -c ../initramfs-eeepc.img | cpio -i

In your favourite editor open the init file that you will now find in this directory.

We need to load the correct modules to access the SD card when we are booting

After the line mount -t proc proc /proc add the following four lines

insmod /modules/usbcore.ko
insmod /modules/ehci-hcd.ko
insmod /modules/libusual.ko
insmod /modules/usb-storage.ko

Get the correct device for the user partition and have a short delay to allow the modules to load.

After the ROOT=`cat /proc/cmdline | sed 's/.*root= ; s/ .*'` line add the following four lines

USER=`cat /proc/cmdline | sed 's/.*user=// ; s/ .*//'`
echo "Sleep 10"
sleep 10
echo "Done sleep"

Change the two exec switch_root /mnt-system /sbin/scanuser.sh lines to

exec switch_root /mnt-system /sbin/scanuser.sh -- $USER

Change the exec switch_root /mnt-system /sbin/formatuser.sh line to

exec switch_root /mnt-system /sbin/formatuser.sh -- $USER

and the exec switch_root /mnt-system /sbin/formatuser.sh – –auto to

exec switch_root /mnt-system /sbin/formatuser.sh -- $USER --auto

Finally change if ! mount -t ext3 -o rw /dev/sda2 /mnt-user; then to

if ! mount -t ext3 -o rw $USER /mnt-user; then

Save this file.

Next copy in the four modules we need. These files can be found on the SD card and need copying to the modules/ directory in initramfs

cp /mnt/sdb1/lib/modules/2.6.21.4-eeepc/kernel/drivers/usb/core/usbcore.ko modules
cp /mnt/sdb1/lib/modules/2.6.21.4-eeepc/kernel/drivers/usb/host/ehci-hcd.ko modules
cp /mnt/sdb1/lib/modules/2.6.21.4-eeepc/kernel/drivers/usb/storage/libusual.ko modules
cp /mnt/sdb1/lib/modules/2.6.21.4-eeepc/kernel/drivers/usb/storage/usb-storage.ko modules

You might find these in a different directory. try

find /mnt/sdb1/lib/modules -name usbcore.ko

to find usbcore.ko. Similarly for the other three.

Add the sdb1, sdb2 devices to dev/

We'll just copy these from the SD dev directory.

cp -dp /mnt/sdb1/dev/sdb1 dev/
cp -dp /mnt/sdb1/dev/sdb2 dev/

Now we need to turn this back into the initramfs.img. Make sure you're still in the initramfs directory then do

find . | cpio -H newc -o | gzip >../newinitramfs.img

Finally, copy this back onto the SD card

cp ../newinitramfs.img /mnt/sdb1/boot/initramfs-eeepc.img

Unmount the SD card and we're done!

You should now be able to boot from the sd card. One the EeePC has booted you should find that /dev/sdb2 is mounted instead of /dev/sda2. Additionally the Factory Restore on the sd card should reset the SD card to “factory default”. (Make sure you've definitely booted from the SD card before you do this!!! And if you've done anything wrong above - e.g. not changed sbin/formatuser.sh correctly - then you'll reset your internal disk instead)

 
howto/xandrosonsd.txt · Last modified: 2009/03/10 13:39 by albkwan
 
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki