Wednesday, June 24, 2009

Conclusion: Restore from USB to minimal EeePC Linux system

(cont'd from: Part V: Yet another test with 1.6 French iso)

My Last Tests with 900 and 1000H iso

In the past 2 weeks, I have been testing out the different scenarios, including with the 1000H iso and 900 iso. Now, all known bugs have been fixed and all conditions tested and verified working.

I have also broken down the "" script into separate scripts (extra*.sh) for each extra job. This would allow the user to easily delete scripts he don't need and add new scripts. Just like the "remove*.list" files, the main script will run the extra scripts one by one after removing programs according to the "remove*.list" you specified, and before resizing.

The 900 iso testing went very smooth, but the testing with the 1000H iso is particularly troublesome. I ran into all kinds of different errors, e.g. udev not working (cannot detect USB drives), asus-launcher not launching the Easy Mode desktop, power button not working ... Only after many many trials, I tracked this down to the extra scripts I have written trying to deactivate Asus update and install wireless and LAN drivers for my 4G as per Howto: Fix network problem using 1000H iso on a 4G. I didn't solve this problem - very strange. So in the end, I removed these 2 extra scripts. [EDIT 2009/6/29: I have finally worked this out and put these extra scripts back into my script package. Just a silly mistake: forget to give the scripts exec permission after editing them.]

I have also tested with different extra% and found that with 2% or 3% extra in one case and another, I have achieved 100% disk usage in sda1 after shrinking. With 1%, resize2fs (and e2fsck) will report failure. So I think the original 5% extra should be a safe and economical choice which will result in around 97% used.

So if you have an EeePC other than the 701 series, even if you are just uninstalling 1 or 2 packages, with this script, you will be able to squeeze some extra disk space (up to 300~500 MB depending on your model) because many models start with something like 87% (even 76%) used in sda1. [NB. If you don't uninstall anything, the script will NOT shrink the partition sda1.]

The time to do this ranges from 17 mins with a 701 4G iso to 25 mins with a 1000H iso, provided that you have a fast USB device. With a slow one, it may take longer to dump the Linux recovery image from the USB device which normally only takes 5 minutes.

Summary of Errors Encountered

1) Couldn't umount after removing staroffice from the 1000H iso (SOLVED)
Umount: Couldn't umount /mnt: Inappropriate ioctl for device
I don't quite understand this error which has troubled me for a few days. After carefully tracking it down, I found that this comes after uninstalling staroffice* (regardless of removal of other programs and has nothing to do with total file size removed).

Finally, I have been able to sort this out with a lazy umount (umount -l) and wait for 15 seconds immediately after uninstalling staroffice. So I have to add a series of umount and mount commands after each apt-get operation of package removal.

2) Couldn't move some symbolic links in sda1 (SOLVED)
Moving /usr/lib/[b-l] ...
mv: unable to rename '/mnt/usr/lib/': No such file or directory
mv: unable to rename '/mnt/usr/lib/': No such file or directory
mv: unable to rename '/mnt/usr/lib/': No such file or directory
mv: unable to rename '/mnt/usr/lib/': No such file or directory
mv: unable to rename '/mnt/usr/lib/': No such file or directory
mv: unable to rename '/mnt/usr/lib/': No such file or directory
I had these errors moving symbolic links since the beginning. Although they do not seem to cause any problem, to play safe, I want to eliminate them. So I log the error messages and process them to extract the link name and link target filename, then delete the original symbolic links and re-create them.

I have also logged the "ls -l" output for all these links before and after the operation so that the user can check and verify afterwards. [NB. The timestamp for these files will become different after this operation.]

3) With the 701 4G iso, after restoring to minimal system, there is a hissing sound from the speaker as reported many times by others in EeeUser forum (both Linux and winxp). This will not affect music playing, and will go off if you mute the speakers. Since this occur to both Linux and winxp, I am inclined to think it is hardware related (perhaps BIOS?). I have not looked into this yet.

Overview of Script Operation

As an overview, here is what the script will do:
1) Delete all partitions in sda1. Then create one primary partition, and format it. [Note: This is for to correct any errors in the partition table and filesystem. The original script from Asus will fail in such cases.]
2) Dump the Linux system image to the 1st SSD (MBR and sda1).
3) Create the user partition (sda2) and other partitions, format and label them.
4) For those models with a 2nd SSD, create, format and label the HOME partition (sdb1).
5) Uninstall programs from the system partition (sda1) as per the remove*.list files.
6) Run extra jobs as per the extra*.sh scripts.
7) Defragment the filesystem in sda1 by moving files to sda2 and back.
8) Calculate available and used disk space, and shrink sda1, allowing 5% extra.
9) Reboot.

Steps of Procedure

1) Prepare an Asus EeePC USB Recovery Disk. Read your EeePC User Manual or my other blog: Create an Asus EeePC System Recovery USB disk.
[NB. You will need a 1 GB USB disk for the EeePC System Recovery USB disk working with the 701 and 900 iso, but 2 GB for the 1000H and version 1.6 iso.]

2) Download my script package restore-minimal-701-4G.tgz or restore-minimal-1.6-701-fr.tgz and extract the files to your System Recovery USB disk. [NB. Some people have reported problem extracting the files in Microsoft Windows with winzip and pkunzip.]

3) Edit the "remove*.list" files in the folder "removes/" according to the factory installed package list in your EeePC Linux version. You can run the command "dpkg -l" in a terminal to see what packages are currently installed. Be sure not to uninstall any system package or else you won't be able to boot.
[NB. Do not use Windows Notepad to edit the files. Use Notepad2 instead if you want to do it in Windows. The files should be saved with UNIX style "End of Line" instead of MSDOS text format.]

If you are using an EeePC Linux version I have tested, you can download and start from my "remove list" files:

ModelVersionLanguagesRemove File List
701 4G1.0.1en tw cnremove_files-701_4G.tgz
900 tw cn
700 en

4) Delete the extra*.sh scripts you don't need. Please note that there are different sets of extra*.sh scripts in restore-minimal-701-4G.tgz and restore-minimal-1.6-701-fr.tgz. Some extra scripts in the latter are only for 1.6 version, e.g. disable auto update. There are description of what each extra script does in the SUMMARY file in the extra/ folder.

5) Boot up from the USB Recovery disk - Press [ESC] at boot up and select the USB disk as 1st boot device, and let the script run.

You will be prompted during the process by apt-get to confirm removal of programs, and also for dumping the Linux system recovery image and shrinking sda1.

For details, please refer to my previous tests on this:
Part II: Success - Restoring my EeePC from USB to a Minimal System
Part IV: 2nd Test restoring to minimal with a 1.6.1 701 en iso
Part V: Yet another test with 1.6 French iso


1) Booting up and dumping the Linux recovery system image to sda1

2) Removing programs as per remove*.list

3) Defragment sda1 by moving files from sda1 to sda2 and back

4) Fixing mv problem with symbolic links

5) Final disk space in system and user partitions

What's Next?

While working on this restoring to minimal system, I have been thinking with the same method, it should also be possible to uninstall applications from the read only partition of the union filesystem (i.e. sda1).

The difference between the two approaches will be:
  1. No need to dump the Linux recovery image to sda1.
  2. Back up the user partition (i.e. sda2), if necessary. [NB. Since the read-only system partition sda1 can be easily restored from the Linux recovery image, I think there is no need to back it up.]
  3. Instead of uninstalling programs in the busybox chroot environment booting from USB, we should boot into a read-write union filesystem to implement the changes, so that dpkg and apt-get running under the union filesystem will be fully aware of the changes. [NB. In a read-write union filesystem, if you upgrade a package, old files in sda1 will be deleted and new files will always be written to sda2.]
  4. Need to back up all files in the user partition (i.e. sda2) to the USB device before shrinking sda1, and restoring them after operation completed.
So, it should not be possible to do this automatically with a script as in this restore to minimal approach. Instead, I think I need to split the main script into separate scripts including:
The user will need to boot into the read-write union filesystem and run synaptic to uninstall packages he don't need. And if he want to retain the F9 restore function, better not to upgrade packages that will upgrade system libraries, only uninstall programs he don't need and/or upgrade applications like openoffice that is not loaded at system boot up.

Also, the user will need to make sure there is enough free disk space in sda2 for upgrading some big packages, e.g. openoffice, because all new files will be written to sda2 before you can shrink sda1 to reclaim the free space from the old files deleted from sda1.

This also applies to force re-installing factory installed packages. The original files will be deleted from sda1 and write to sda2, so effectively moved from the read-only sda1 to the read-write sda2. So you can do whatever you like with it later.

This will be my next project.

Part I : My 1st Trial
Part II: Success - Restoring my EeePC from USB to a Minimal System
Part III: Re-installing Removed Packages to my minimal EeePC Linux 701 4G
Part IV: 2nd Test restoring to minimal with a 1.6.1 701 en iso
Part V: Yet another test with 1.6 French iso
Conclusion: Restore from USB to minimal system

1 comment:

  1. I have been reading and looking for some information and it is amazing and disturbing how many blogs related to Buy Viagra, Viagra, Generic Viagra are in the web. I know that they are products that many people use and need, but it is funny to watch so many information about those products. Anyway your inputs for this subject are very interesting.