Pre-requisite: Set up grub menu.lst to add an entry for booting into Rescue Mode as instructed in this wiki.
What can you do in rescue mode?
Bascially anything - Although you may need to copy some programs and libraries from sda1 (the 1st partition of the SSD) into the root filesystem to get some commands working.
You may want to enable hotplug in the kernel so that it will automatically create devices you need, say when you plug in an USB drive.
mount -t sysfs sysfs /sys echo /bin/mdev > /proc/sys/kernel/hotplug mdev -s
[NB. This should be done before you chroot]
Can I use an USB stick in rescue mode? I want to backup files.
This is not easy but still possible.
To do this, you will need to set up hotplug first, then mount sda1 to load USB drivers and finally mount the drives. This process is complicated, so I have created a script to make life easy.
You can copy and paste the following codes to your favorite text editor and save the file in /home/user as rescue_usb.sh. Then give it exec permission by right click on the file name and choose Properties, then Permissions and check all the Exec boxes.
[NB. If you have a 900 model, you need to mknod to create /dev/sdb1 before you can mount /home. ]
#!/bin/sh
#This script is for loading USB drivers and subsequently probing and mounting USB partitions
#It should be run in rescue mode of default Xandros of Eeepc
#Linux ext2/ext3 and vfat USB partitions are supported
mount -t proc proc /proc
mount -t sysfs sysfs /sys
echo /bin/mdev > /proc/sys/kernel/hotplug
mdev -s
echo Insert your USB stick now
echo "Press <ENTER> when ready"
read
mount /dev/sda1 /mnt-system
cd /mnt-system/lib/modules/2.6.21.4-eeepc/kernel/drivers/usb/
insmod core/usbcore.ko
insmod host/uhci-hcd.ko
insmod host/ehci-hcd.ko
insmod storage/libusual.ko
insmod storage/usb-storage.ko
cd /mnt-system/lib/modules/2.6.21.4-eeepc/kernel/fs/
insmod fat/fat.ko
insmod vfat/vfat.ko
insmod nls/nls_cp850.ko
insmod nls/nls_iso8859-1.ko
cd /
echo "Waiting 15 sec for USB subsystem..."
sleep 15
# Seek and mount all USB partitions
PARTS=`cat /proc/partitions | sed -n 's/.*sd/sd/p' | grep 'sd[b-z][1-9]'`
for i in $PARTS ; do
mkdir /mnt/$i
mount /dev/$i /mnt/$i
retval=$?
if [ $retval -ne 0 ]; then
echo
echo Mounting $i as ext2/3 has failed
echo Try mounting as vfat
echo
mount -t vfat /dev/$i /mnt/$i
if [ $? -eq 0 ] ; then
echo vfat partition /dev/$i mounted in /mnt/$i
else
echo
echo Fail to mount /dev/$i : Unknown filesystem
echo
fi
else
echo ext2/3 partition /dev/$i mounted in /mnt/$i
fi
done
echo
echo
echo The following partitions are mounted:
echo
cat /proc/mounts | grep 'sd[b-z][1-9]'
echo
Next time you boot into rescue mode and chroot into sda1, you can then mount sda2 in /mnt-user and run this script. It will prompt you to insert your USB stick and mount it. And then you can copy and backup important files to your USB drives from either sda1 or sda2. [NB. Linux ext2/ext3 and vfat USB partitions are supported.]
If your Eeepc has already failed to boot and you have not prepared the mount USB stick script in advance, don't be in despair. You can still make use of it, just typing the commands one by one.
For the lines starting from ”# Seek and mount all USB partitions” onwards, you will have to do it differently. What you need to do is to check what device name has been assigned to your USB stick, then try to mount it (or create the block device first if it is non-existing).
To check what device the kernel has mapped the USB stick, use this command:
cat /proc/partitions
Next, you create the mounting point and mount it, e.g. for sdc1:
mkdir /mnt/sdc1 mount /dev/sdc1 /mnt/sdc1
Note that if your USB stick is formated to FAT or FAT32, you will need to specify the filesystem for mounting:
mount -t vfat /dev/sdc1 /mnt/sdc1
Now you can proceed to rescue your system. To verify what partitions have been mounted, you can use this command:
cat /proc/mounts
To do this, first you need to mount sda1 in the folder /mnt-system, then create symbolic links of the two libraries required to run chroot, and then exec chroot.
mount /dev/sda1 /mnt-system mkdir /lib /lib/tls /sbin ln -s /mnt-system/lib/ld-linux.so.2 /lib ln -s /mnt-system/lib/tls/libc.so.6 /lib/tls ln -s /mnt-system/usr/sbin/chroot /sbin chroot /mnt-system export PATH
Now you will be in a working environment just like you have booted up default Xandros in single-user mode (but without union filesystem).
[Note: if you're like me, you'll be doing this quite a bit, to remove packages you don't want from the read-only partition, and to install packages you do want. If so, setting up chroot every time is going to get annoying. So the first time you do this, after mounting /dev/sda1 as /mnt-system, put a text file on /mnt-system (I used /mnt-system/usr/local/bin/setup-chroot.txt) containing the mkdir line above followed by the three symlink (“ln -s …”) lines. In busybox, you don't have chmod to make this executable, but that's good, as you never want to execute this EXCEPT before chrooting (this is why I give this a .txt suffix instead of .sh, and don't start the file with #/bin/sh – I never want to execute this after chrooting or in normal boot mode). Instead, do this at the prompt: sh < /path to file, e.g, sh < mnt-system/usr/local/bin/setup-chroot.txt. Then chroot and export PATH.]]
Multi-user mode while on rescue mission
Once you are in the chroot environment, you have access to all the initialisation routines. Using
/etc/init.d/rc.d S
initialises the system for single user mode. It is a good idea to set passwords now on sda1
passwd x!y+khz! passwd user ksju7.9*
or some other passwords which are easy to remember for you, but not so easy to break, sets passwords for “root” and for “user”.
Now use
/etc/init.d/rc.d 2
to switch to multi-user mode. The Xandros login screen appears. Now you see what you need the passwords for. Log in as root, aka “Administrator”. After that, you will see the familiar ASUS environment.
Open issues: I did not find out how to properly populate the /proc directory and to activate the network on this level.
Help! I lost my password and cannot login!
Don't panic! You can change it in rescue mode.
In the chroot environment, you can easily reset the password by running the passwd command. You will be prompted twice to enter the new password and there you go, you have a new password now
.
sh-3.1#passwd Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
Now your password has been changed. But the new password is stored in sda1. If you are still using the unionfs/aufs, you will need to copy and overwrite it to sda2 to make it effective at next boot. So, if you are still in chroot environment, you should do this:
mkdir /mnt/temp mount /dev/sda2 /mnt/temp cp /etc/shadow /mnt/temp/etc/ exit
But before you happily reboot, be sure to umount drives and wait at least 5 secs before you reboot pressing [Ctrl]-[alt]-[del].
umount -a
How can I perform disk scan on sda1?
With default Xandros of the Eeepc, there is no way to perform disk scan on the SYSTEM partition (sda1) once the system has booted up. The only way to do this is in rescue mode.
Because you can not run a filesystem check on a mounted partition and the disk scan program (e2fsck) is not available in busybox of the rescue mode. So, basically what we need to do is to mount sda1 first and copy e2fsck (and tune2fs if you have converted the filesystem to ext3) and required libraries to the temporary filesystem of the rescue mode, then umount sda1 to run the commands:
mkdir /sbin /lib /lib/tls mount /dev/sda1 /mnt-system cd /mnt-system/lib cp libext2fs.so.2 libcom_err.so.2 libblkid.so.1 libuuid.so.1 libdevmapper.so.1.02 libselinux.so.1 libsepol.so.1 ld-linux.so.2 libe2p.so.2 /lib cd tls cp libc.so.6 libdl.so.2 libpthread.so.0 /lib/tls cd / cp /mnt-system/sbin/e2fsck /sbin umount /mnt-system
Now you can run filesystem check on sda1. But be sure to wait at least 5 secs for the system to flush cache buffer to avoid corrupting the hard disk because in rescue mode. Then create a copy of /etc/mtab from /proc/mounts because e2fsck and tune2fs need to verify that sda1 is already umounted from /etc/mtab. Otherwise it will complain cannot verify … :
cat /proc/mounts > /etc/mtab e2fsck -y /dev/sda1 e2fsck -y -c /dev/sda1
[NB. The option -c for e2fsck is for checking bad blocks.]
And if you have changed the filesystem to ext3 on sda1, then additionally run tune2fs to check the journals:
tune2fs -j /dev/sda1
And when you are done, then you should umount everything, wait at least 5 sec before you press [Ctrl]-[Alt]-[Del] to reboot.
umount -a
Do I need to boot from USB to backup and restore the SSD partitions?
With the hacks here, you are completely self-sufficient to backup and restore your SSD partitions to an USB stick in rescue mode.
Just set up hot plug, and mount USB drives as above, then do the followings to set up the gzip command:
mount /dev/sda1 /mnt-system mkdir /lib /lib/tls /sbin cp /mnt-system/lib/ld-linux.so.2 /lib cp /mnt-system/lib/tls/libc.so.6 /lib/tls cp /mnt-system/bin/gzip /sbin
Alternatively you can create symlinks instead of copying the files:
mount /dev/sda1 /mnt-system mkdir /lib /lib/tls /sbin ln -s /mnt-system/lib/ld-linux.so.2 /lib ln -s /mnt-system/lib/tls/libc.so.6 /lib/tls ln -s /mnt-system/bin/gzip /sbin
Now you are ready to use the dd command to backup and restore partitions and compress the image with gzip.
dd if=/dev/sda1 | gzip > /mnt/sdx1/xxxxxx.img.gz dd if=/dev/sda | gzip > /mnt/sdx1/xxxxxx.img.gz
Replace sdx1 with where your kernel actually mapped your USB stick, e.g. sdc1. Also, if you want to backup the whole SSD instead of just sda1, then use sda instead.
Optionally, you can perform disk scan before backing up.
If you want to reduce the size of the backup image, you can write zero to empty space in the partition. If you have a lot of empty space in your SSD, it will make a huge difference. Here are the steps:
mknod /dev/zero char 1 5 mount /dev/sda1 /mnt-system cd /mnt-system dd if=/dev/zero of=/mnt-system/delete.me bs=8M rm /mnt-system/delete.me cd / umount /dev/sda1
Do also the same for sda2:
mount /dev/sda2 /mnt-user cd /mnt-user dd if=/dev/zero of=/mnt-user/delete.me bs=8M rm /mnt-user/delete.me cd / umount /dev/sda2
To restore from your backup image to SSD, the command is something like this:
gzip -dc /mnt/sdx1/xxxxxx.img.gz | dd of=/dev/sda1
Replace source USB partition sdx1, source image name xxxxxx.img.gz and destination partition sda1 as required.
For more information, please refer to this wiki: Backup and Restore.
Can I uninstall programs from the factory OS to free disk space?
People have been telling you it is not possible to uninstall programs from the factory OS to free up disk space, but nothing is impossible in the rescue mode.
To uninstall programs from sda1, first make sure your PATH is set as described above (after you chroot into sda1 in rescue mode):
export PATH
Otherwise you will receive this error message:
dpkg - error: PATH is not set.
To uninstall program is simple. You can either use the dpkg command or the more user friendly apt-get command, e.g.
dpkg -P acrobat apt-get --purge remove xandros-antivirus
[NB. The option -P and –purge removes config files in addition to removing the package. If you use dpkg -r or just apt-get remove, the config files will not be removed.]
With dpkg however, you will need to take care of package dependencies yourself. For example, if you want to remove acroread, dpkg won't let you do this before you remove acroread-cn-tw. In contrast, apt-get is more intelligent and it will check dependencies and will remove packages that depend on the package you are going to remove. So be careful!
For more information on how to use dpkg and apt-get to remove programs, you can refer to these references:
Also you will need to know the package names in order to remove them. In this page, you can find a list of all programs installed on the Eeepc here or in more details in this webpage.
The next question, of course, is what can I uninstall to gain more free space. It will of course depend on your needs, but here are some suggestions from other forum members:
Also, here is my suggestion of some packages you probably won't need:
Although this is not absolutely necessary, it would be nice to set up dpkg so that it can keep track of changes.
[On my 901, doing this causes 1) screen after screen of serious warnings, and 2) reports packages removed when they haven't actually been removed. On the other hand, if this isn't done, in regular boot mode, dpkg, apt-get, and synaptic will continue to think the removed packages are still installed, or that installed packages aren't installed. My work-around was to first do removals/installs without these symlinks (to get the packages actually removed/installed) and then again with the symlinks (to update the dpkg information used in the normal boot mode). Hopefully, there's a better way, but I don't know it. –tpdi)]
If you are still using the unionfs or aufs from default Xandros, dpkg has been keeping all its records in /var/log/dpkg.log and the folder /var/lib/dpkg which lies in the read-write partition sda2, instead of the read only partition sda1 where you are going to install or remove programs now. To make dpkg write changes to the old record files, you need to mount sda2 and create a symbolic link from your old files in sda2 to the same location in sda1.
mkdir /mnt/sda2 mount -t ext3 /dev/sda2 /mnt/sda2 cd /var/log/ mv dpkg.log dpkg.log.old ln -s /mnt/sda2/var/log/dpkg.log . cd /var/lib mv dpkg dpkg.old ln -s /mnt/sda2/var/lib/dpkg .
Now that you have uninstalled a few programs and free up some disk space in sda1, it is natural for you to think it would be best to install or upgrade some programs to fill up this partition. In fact, upgrading all those Asus update packages (including OpenOffice 2.4, Acrobat Reader 7.0.9-1xandros3, skype 2.0, …) to sda1 will only need an additional 50 MB free space but installing them in a normal bootup (unionfs or aufs) state (i.e. install upgraded packages to sda2 without deleting old packages in sda1) will cause you hundreds of extra MB disk space.
The limitation here is that we have not yet set up Internet connection. So we can only install packages that we have downloaded and saved in an USB stick.
This is the simplest case. For example, Asus has provided a package called dreye for the 1000H models which is an English Chinese electronic dictionary. To use it on your 701 models, you can download it from update.eeepc.asus.com as a single package dreye_1.1.2_i386_cht.deb and save it to an USB stick. Then after mounting the USB partition, you can change directory into the folder where you have saved this file and run the dpkg command:
dpkg -i dreye_1.1.2_i386_cht.deb
Then the package will be installed to sda1. The limitation with dpkg is that it will not handle dependencies. It will only output an error if dependency is not fulfilled. So another easier way is to use apt-get to install large packages.
It is possible to build a local repositories for deb packages you have downloaded, say in your USB stick, and install with apt-get. The advantage is that apt-get automatically takes care of dependencies and install required dependency packages together with the package you specify.
For details on how to set this up, please refer to this APT HOWTO: How to use APT locally.
However, this method is still tedious because we need to check first which package depends on which packages and need to download them all before you can proceed to build the local repository. Therefore, I prefer an easier approach which is CASE 3 that follows:
Forum member lazyfai has build a xepc-upgrade-disc with all the Asus updates and many more programs compiled for the Eeepc. It can be downloaded from SourceForge.net: xepc. The advantage with using this is that it is a complete repository, you don't need to worry about what dependency package you need to download, and there are already 465 packages, 0.97 GB in the DVD - Save us many work!
However, before you proceed, you have to make sure that you have not done this upgrades before with the Eeepc bootup in normal mode (i.e. working under unionfs/aufs). Or you can uninstall the upgrades you have done previously with “Add/Remove Softwares” or in synaptic. This is because the nature of the unionfs is that sda1 is mounted read only and all the upgrades have been written to sda2. If you upgrade now to sda1, the changes will be neglected by the unionfs, so you are just wasting your disk space.
To use this with apt-get, we need to copy all the files from the iso to your USB stick before hand. You can do this either by loop mounting the xepc-20080525.iso in a Linux box, or burn the iso into CD in your desktop first.
The next step is to back up /etc/apt/sources.list and create a new one with only this local repository. Then update cache:
mv /etc/apt/sources.list /etc/apt/sources.list.orig echo "deb file:/mnt/sdx1/ p701 main" > /etc/apt/sources.list chmod +x /etc/apt/sources.list apt-key add /mnt/sdx1/dists/p701/xepc-pubkey.txt apt-get update
[NB. Replace sdx1 with where your USB stick is actually mounted, e.g. sdc1]
Now you are ready to install or upgrade programs from the xepc-upgrade-disc. To install new programs, extra care is required to avoid dependency conflict with some other libraries you may have installed earlier with another program from another repositories (because they are now in sda2, dpkg or apt-get will not be able to know them). But upgrading programs from the factory OS is very easy because there will definitely be no dependency problem. You can either upgrade all of them once for all with this command:
apt-get upgrade
Or with this option to show you what will be upgraded:
apt-get -u upgrade
or select packages to be upgraded by yourself, e.g.
apt-get install xandros-antivirus
For a list of available packages, there is a file called Packages in the folder dists/p701/main/binary-i386 and dists/p701/dev/binary-i386 of the xepc-upgrade-disc. Take a look there. My suggestion, of course, is: openoffice, acroread, skype, pidgin, …