Translations of this page:

Removing UnionFS/aufs

Introduction

This page describes how to remove unionfs/aufs from your EEE PC. By default the SSD (Solid State Disk) contains 4 partitions. The first one (/dev/sda1) contains the operating system as a conventional ext2 partition, mounted read-only. The second partition (/dev/sda2) is an ext3 partition. The second partition is mounted on top of the first partition through unionfs/aufs. Unionfs is used in 701; aufs is used in later EEE models like the 900. Both actually serve the same purpose. The third and fourth partitions are unused tiny FAT (Windows) partitions.

In layman's terms: The first partition is mounted read-only and the second partition is mounted “on top of it”. All changes you make are made on the second partition. This is safer but has the disadvantage that it is harder to tweak the parts of the system that are used while booting the system (e.g. the grub menu). Additionally you cannot recover space from the first partition by uninstalling packages (and actually if you update a package (e.g. skype) you have two copies on your system, the original one on the first partition and the new version on the second one (which shadows the original one)).

By working without unionfs/aufs these disadvantages are overcome. However there is an additional risk: The chance is a little bit higher that you'll corrupt your system if you do something wrong. Also the recover option in the OS will not work any more (but of course you can always restore from the original DVD).

Note that if you're using the XEPC recovery DVD you shouldn't remove unionfs because the recovery DVD uses squashfs to save space on the SSD and squashfs is a non-writeable filesystem. Without the use of unionfs it won't be possible to make any changes to the system. In addition since squashfs is a single compressed binary blob it's not possible to make any changes to it so the usual reason for removing unionfs, being able to remove packages to save space, doesn't apply for squashfs. Think of squashfs as a LiveCD, you can't update it once it's been created.

Disclaimer

If you decide to make the changes on this page, you do this fully at your own risk. Although the procedure is verified, the author(s) cannot be held responsible for whatever happens with your system. It is your own choice to make these changes. Please read the complete instructions first before attempting to make any change. If you do not completely sure you are competent to make the changes or if you do not understand the risks or not sure whether you are willing to take these risks, then do not make these changes!
You are performing the changes at your own risk!

Prerequisites

In order to get this working you need:

  1. An eeePC of course. Preferably in a virgin state. I would strongly suggest to backup all data, and restore the system from the original DVD. If restoring is not possible the chance for success is still quite high. In any circumstance make sure you backup whatever data exists on the eeePC.
  2. Some basic knowledge of an editor (e.g. vi or nano, but you can even use oowriter)
  3. patience, reading skills and accuracy in doing these changes
  4. optionally: a bootable linux system (e.g. knoppix or an ubuntu live CD, or puppy linux or faunos). For testing this puppylinux was used. (see Installing Puppy Linux for the eeePC for info on how to get a bootable puppy usb flash disk).

Getting Started

  1. If you haven't done already: back up all data on your system!
  2. If you haven't done already: first read this complete page
  3. Install Rescue mode according to this link.

Creating a new ramfs

This section describes how to create a new ramfs image. You have two options here:

If you are using model 701, you may download the ramfs image for 701 from http://www.eeepc.speedlinq.nl/initramfs-eeepc-nounionfs.img (and optionally http://www.eeepc.speedlinq.nl/initramfs-eeepc-nounionfs-ext3.img if you want to convert system partition to journalled ext3 filesystem as in next chapter.) After downloading, you can skip the rest of this section and continue from “Installing the new ramfs”. Once you have downloaded the initramfs img file then make sure you copy/move it to /boot before you proceed to the next stage. sudo cp /path/to/file /boot/

Otherwise, or if you are using model 900, proceed as follows to create new ramfs images.

  1. Boot the eeePC.
  2. Get a terminal window by typing ctrl-alt-T. In that window execute the following commands:
sudo bash
cd /boot
mkdir tmp
cd tmp
gunzip -c ../initramfs-eeepc.img | cpio -i

Now edit the file init with the editor of your choice. You need to make the following changes:

Modify line 12. This line originally reads:
mount -t ext2 -o ro $ROOT /mnt-system
And needs to be changed into:
mount -t ext2 -o rw,noatime $ROOT /mnt
(so change ro into rw,noatime and remove the -system part). Make sure, there is no space in rw,noatime. Otherwise your new system won't boot.

Add a # sign in the text between these lines (inclusive):
From the line that reads: if [ -n “$XANDROSSCAN” ]; then
To the line that reads: umount -l /mnt-user

After making the changes your file should look like the sample below. (This file is copied from a EEE PC 701. Other EEE PC models may have slightly different file for their different configurations e.g. mounting extra SSDs). You are advised to perform amendment line-by-line carefully, instead of overwriting the file with this content.

#!/bin/sh
mount -t proc proc /proc

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

ROOT=`cat /proc/cmdline | sed 's/.*root=// ; s/ .*//'`
#VERSION=`cat /proc/version | cut -f3 -d" "`

mount -t ext2 -o rw,noatime $ROOT /mnt
if [ $? -ne 0 ] ; then
    echo Could not mount OS on $ROOT. Starting debugging shell....
    /bin/busybox sh
fi

#if [ -n "$XANDROSSCAN" ]; then
#    exec switch_root /mnt-system /sbin/scanuser.sh
#fi
#
#if [ -n "$XANDROSRESTORE" ]; then
#    exec switch_root /mnt-system /sbin/formatuser.sh
#fi
#
#if [ -z "`grep nosplash /proc/cmdline`" ]; then
#    echo -n ""
#    cp /mnt-system/boot/startup.fb /dev/fb/0
#fi
#
#if ! mount -t ext3 -o rw /dev/sda2 /mnt-user; then
#    echo Error mounting user partition. Must run filesystem scan!
#    exec switch_root /mnt-system /sbin/scanuser.sh
#fi
#
## Factory auto-format functionality
#if [ -f /mnt-user/.autoformat ]; then
#    umount /mnt-user
#    exec switch_root /mnt-system /sbin/formatuser.sh -- --auto
#fi
#
#insmod /mnt-system/lib/modules/$VERSION/kernel/fs/unionfs/unionfs.ko > /dev/null
#
#mount -t unionfs -o dirs=/mnt-user=rw:/mnt-system=ro unionfs /mnt
#if [ $? -ne 0 ]; then
#    echo Could not mount unionfs. Starting debugging shell....
#    /bin/busybox sh
#fi
#
#mount --move /mnt-system /mnt/mnt
#umount -l /mnt-user

umount /proc

if [ -n "$INIT" ]; then
    if [ -n "$XANDROSBOOTDEBUG" ]; then
    exec switch_root /mnt $INIT </mnt/dev/console >/mnt/dev/console
    else
    exec switch_root /mnt $INIT </mnt/dev/null >/mnt/dev/null
    fi
else
    exec switch_root /mnt /sbin/fastinit "$@" </mnt/dev/console >/mnt/dev/console
fi

echo
echo Init Failed. Starting emergency shell....
/bin/busybox sh

Finally execute the following command:

  1. find | cpio -H newc -o | gzip -9 > ../initramfs-eeepc-nounionfs.img

If you plan on converting to ext3, this is also a good moment to make a second image file, by performing the following two steps. (If not please move on the clean up).

  1. edit line 12 of the init file and change ext2 by ext3
  2. find | cpio -H newc -o | gzip -9 > ../initramfs-eeepc-nounionfs-ext3.img

Note the changed filename in the last step. Do not combine this with the previous steps, you do need initramfs-eeepc-nounionfs.img (with the ext2 line) as well!

And finally let's clean up our work by issueing the following commands:

  1. cd ..
  2. rm -rf tmp

Installing the new ramfs

Reboot into the rescue console and type:

  1. mount /dev/sda1 /mnt-system
  2. mount /dev/sda2 /mnt-user
  3. cp /mnt-user/boot/initramfs-eeepc-nounionfs*.img /mnt-system/boot/
  4. umount /mnt-system
  5. umount /mnt-user

Now wait at least 30 seconds.

The umount steps and the waiting are there to make sure all data is written to the disk and all disk caches are flushed. If you skip these steps it might be that your data gets corrupted.

Test your work

  1. Reboot your eeePC by pressing ctrl-alt-del
  2. During the boot press F9: the grub console will appear
  3. On the first item of the grub console press 'e'
  4. On the third line of the window that pops up, press 'e' ( the line starts with initrd )
  5. replace in the third line the initramfs-eeepc.img name with initramfs-eeepc-nounionfs.img (you can just do that by pressing cursor left four times, then type -nounionfs)
  6. press enter
  7. press b

If all works well you now will boot using the first partition. This is verified very easily, as you now will need to enter things like computer name, password and timezone.

If it did not work, you might want to retrace your steps; especially examining if you made the correct changes in your init file. It might also be that somehow your first partition got corrupted. Best solution in that case is to start all over again by restoring the eeePC factory image from the DVD (or a USB stick, see the eeePC manual for instructions).

Finalizing

If you managed to do the previous steps and did all the initial configuration by setting your timezone etc, you need to execute the following steps:

Get a terminal window by typing ctrl-alt-T. In that window execute the following commands

  1. sudo bash
  2. fsck /dev/sda1

This is not mandatory but highly recommended. If only a few errors pop up, you can repair them, then reboot. If lots of errors pop up, you are probably better off restarting from a freshly recovered eeePC.

Next edit /boot/grub/menu.lst. Change the line:
initrd /boot/initramfs-eeepc.img
into
initrd /boot/initramfs-eeepc-nounionfs.img
(normally this is line 17).

While you are at it (and if you haven't done so already). you might want to put a # sign before the line that reads hiddenmenu (normally line 4), and change the timeout value on line 9 to 3.
This will make it easier to go into rescue mode in the future.

Optional: merging the first two partitions

For this step you need to boot your pc from an alternate linux distribution. The recipe below is for puppy linux (see Installing Puppy Linux for the eeePC for information on how to install puppylinux on an usb disk.) You may also use Gparted LiveCD from USB stick.

It might be desirable to merge the first two partitions, in order to create one bigger partition. To do so perform the following steps:

  1. make one more time sure that you do not have any data you do not want to loose on your second partition; if you still have data on your second partition probably the best way to back it up is by “sudo bash” then “mount /dev/sda2 /mnt; cd /mnt; tar cvf <dirwhereyourusbdiskismounted>/sda2.tar”)
  2. Boot a linux distribution from an external medium (usb flash disk, SD card, CD/DVD drive)
  3. start a console window
  4. run gparted
  5. in the UI you will see 4 partitions. Select the second one (the ext3 partition, for me /dev/hdc2)
  6. press the delete button.
  7. select the first partition (the ext2 partition, for me /dev/hdc1).
  8. press the resize/move button
  9. in the dialog box that pops up, enter the maximum size (shown in the first line of text) into the box: New Size (for my 4G this was 3797, but this might be different for you)
  10. press the resize/move button on the form
  11. check the apply button, confirm by pressing the apply buttion that appears in the confirmation box.
  12. you'll now see a progress indicator. The operation will take several minutes. Once completed close gparted.

If you made an sda2.tar file above you can recover it by rebooting then “sudo bash” then “cd /; tar xvf <dirwhereyourusbdiskismounted>/sda2.tar”

Optional: Converting to ext3

It is recommended to convert the filesystem to ext3. Ext3 is a journalling filesystem and more robust than ext2. The additional wear on the internal flash is neglectable.

To achieve this the following steps need to be taken. Note that if you are not using puppy it might be that you have to use a different name for your disk (e.g. /dev/sda1). If you merged the partitions in the previous step gparted will have told you the name to use.

Make sure that you have a ramdisk image with ext3 enabled. See above on how to achieve this. Then do the actual transformation:

tune2fs -j /dev/hdc1

This will turn ext2 in ext3.
Next do:

tune2fs -c 0 -i 0 /dev/hdc1

This will disable the otherwise scheduled file system checks.

And finally edit /boot/grub/menu.lst to use the new image file (initramfs-eeepc-nounionfs-ext3.img if you followed the instructions above.

Reboot and you are done.

Optional: backing up your work

This is still untested and needs work. Below this is a more complicated method which is more of a failsafe, using puppy linux.

It is a good plan to make a backup of your work. The most convenient way to me seems to start your eeePC, attach an external storage medium with sufficient space then start a terminal window, type sudo bash, then dd if=/dev/sda1 bs=1M | gzip > /media/whatever/backup_file
backup_file of course should be on an external USB drive.

Not sure if it is better to do this under another OS. Make sure backup_file is on a different medium, with at least 2GB of free space. After a fresh install making a backup took 23 minutes and gave a file of about 1.37 GB. (if you do not mind the space you can skip the gzip part and it will be much faster but your file will be 4GB). For restoring you definitely will need to use another OS.

Alternately if you want to save some time and have sufficient storage you can just type dd if=/dev/sda1 bs=1M > /media/whatever/backup_file

If desired of course you can make a few other changes first (e.g. install the debian feeds). If you are afraid of loosing your work you probably want to make a backup first.

And should you ever want to restore you backup, boot puppy or some other linux and issue a command like:
gunzip /media/whatever/backup_file | dd of=/dev/sda bs=1M (or if you omitted the gzip step above it would be dd if=/media/whatever/backup_file of=/dev/sda bs=1M)

Backing up both partitions (full backup) using puppy linux flash drive

This, though slightly more complex, is a more complete and perhaps more safe way to backup your EEE. It is necessary to have a bootable USB flash disk with puppy linux installed, see Installing Puppy Linux for the eeePC for a walkthrough of this. Also required is some way (preferably USB Hard Drive - this is what I used) of externally saving the backup files you create. Now, lets go!

1. Insert your puppy flash drive into the EEE and turn it on. Start tapping the escape key straight away and continue until you see a blue box asking you to select a boot device (doesnt take long).

2. Choose to boot from your flash drive. Beware that the internal SD card reader on the EEE identifies itself as 'USB2.0 CardReader SD0' - this is not the one you want.

3. Puppy Linux will start up, and take you to a screen inviting you to specify some advanced optins. Ignore this and let it load until it asks for your keyboard layout.

4. Select the layout for you and press enter.

5. Next is the video wizard! press enter to choose Xorg, then enter again shortly after to select LCD Panel 640×480 (EEE resolution is actually 800×480 but we wont worry about that!)

6. On the next screen press down to choose 640x480x24, and enter to accept. Puppy linux linux will then load its desktop-style environment.

7. Click the drives shortcut on the desktop to open Pmount drive mounter. This will automatically detect all storage attached to your EEE. What you want to do here is mount whatever it is you are going to save your backup file to - I used a USB hard disk which was at the bottom of the list. You need to click the little picture of a disk drive to the right of your drive, and it will mount it for you. Puppy placed mine at /mnt/sdc1 , and I will be using this reference for the rest of these instructions. If yours is different then change what I have written below as necessary!

8. Still on the Pmount program, look at the section which represents your EEE's internal storage. This should have 3 partitions on it, 2 of a vaguely equal size (each very roughly half your total storage space) and a third small partition - mine was 7mb - on which the BIOS is stored. Note the paths for the two larger partitions. Mine were /dev/hdc1 and dev/hdc2. Again, I will write referring to these, change as appropriate if your EEE is different.

9. Close Pmount and open a terminal by clicking console from the desktop. If necessary, create a directory in which to place your backup files on your external storage. Example:

mkdir /mnt/sdc1/eeebackup

10. We will use the dd command in its simplest form here, no compression for a faster copy. Perhaps later someone could add in here a way to compress the output file, I did not do this myself. What I typed next was:

dd if=/dev/hdc1 of=/mnt/sdc1/eeebackup/hdc1

This creates a file called hdc1 in the eeebackup folder of your external storage, which will be the exact same size as your hdc1 partition - including empty space.

11. Once that is done (I think it took me 10-20 minutes, writing to a USB Hard Disk), backup the other partition. Commands are:

dd if=/dev/hdc2 of=/mnt/sdc1/eeebackup/hdc2

This creates a file called hdc2 in the eeebackup folder of your external storage, which will be the exact same size as your hdc2 partition - including empty space.

You now have the files hdc1 and hdc2 saved externally for an easy restore using puppy in the future, if things go wrong. All thats left to do is reopen pmount ('drive' shortcut on the desktop) and click the disk icon for your external storage to unmount it, then shutdown and unplug everything. You have finished!

Process to restore from these files

::EDIT:: I'm not sure about the following! I had quite a lot of difficulty writing my second partition back on top of my first one. What I ended up doing was extracting the dd image onto my SD card then using the file manager in puppy to copy it all onto the internal ssd. For some reason the cp command didnt work for me, just skipped all the folders. Someone please sort this section out with a proper method!

This is very similar to what is described above, except parts 9, 10 and 11. 9 is uneccessary, and 10 and 11 should swap the if and of parts, e.g. step 10 for restore would be:

dd if=/mnt/sdc1/eeebackup/hdc1 of=/dev/hdc1

and step 11:

dd if=/mnt/sdc1/eeebackup/hdc2 of=/dev/hdc2

I feel this method is superior to backing up only the user partition in the context of this page because it can be used for a successful restore if merging the two partitions after removing unionfs goes wrong. Perhaps someone could add a section on recreating the two partitions (in the event of a failed merge) and restoring the unionfs?

Guide based on experience of richardkemp and information in this forum thread http://forum.eeeuser.com/viewtopic.php?id=6544

Acknowledgements

This work is based upon several articles in forum.eeeuser.com, especially the work of Kibobo and Gadgetguy.
Links to the related forum threads:
http://forum.eeeuser.com/viewtopic.php?id=1891
http://forum.eeeuser.com/viewtopic.php?id=2650

Merging changes from partition 2 into partition 1

samo on altern.org jan-2008: it is possible to do the above even after heavy changes are done to the original filesystem - i.e. lots of work, package additions/removals etc (not at all virgin state) - and still get everything right (and keep the original partition/filesystem instead of making all new). Roughly the steps are as follows (requires some unix skills. Read this entire section before starting and ensure you know what you're doing):

  • from above, get to the point of not really needing unionfs anymore
  • boot from external usb drive or similar, so /dev/sda1 /dev/sda2 are not used
  • mount them somewhere, i.e. /media/sda1 /media/sda2
  • as said above, all on /media/sda1 is original untouched filesystem, all on /media/sda2 is only your changes:
    • new files are as plain files, changed files are copies of original files
    • removed files/dirs are represented as .wh.thefilenamehere 0-sized files
    • new hard-links (ln -f) are represented as a copy of the file + a hard-link to it
  • step DEL-OPAQUE: find all .wh.__dir_opaque files on sda2 and delete the corresponding dir on sda1
    • Example code to do this would be
    • cd /media/sda2
      find . -name .wh.__dir_opaque -exec sh -c 'F="{}";echo rm -rf /media/sda1/${F%/*}' \;
      
    • this only shows what it will do. Remove the “echo” to actually do it
  • step DEL: find all things matching .wh.* on sda2, and remove the original file/dir they denote (same name less the .wh. prefix, in same dir in /media/sda1)
    • Example code to do this would be
    • cd /media/sda2
      find . -name .wh.\* ! -name .wh.__dir_opaque -exec sh -c 'F="{}";echo rm -rf /media/sda1/${F/\/.wh./\/}' \;
      
    • this only shows what it will do. Remove the “echo” to actually do it
  • step COPY:
    • cd /media/sda2
      cp -a sbin etc bin usr home lib var opt dev   /media/sda1/
    • put in the above all real dirs, e.g. avoid /proc /sys and similar pseudo-filesystems. Note /dev IS there. This can be also done one by one. Another way is to remove rm -rf sys/ proc/ from the /media/sda2 and then copy -a /media/sda2/* /media/sda1
    • make sure you have enough space on sda1 for all the files on sda2 before you do this. If you've added more than ~230Mb of files, you won't. If not, tar them onto an external drive, resize sda1 to use all the drive space, then untar them onto it.
  • be very careful… This procedure *can* delete your /media/sda1/*
  • backup your whole drive first
  • once you are sure the actual files are gone, you can remove the .wh.* placeholders in /media/sda1
find /media/sda1 -name .wh.\* -exec rm -f {} \; ''

Thanks to VZ for some of these notes

Note on merging partitions 1 and 2: Attempting to resize the /dev/sda1 using parted over original filesystem will fail. The /dev/sda1 ext2 filesystem has some optimization features turned on, which parted does not want to handle. The manual workaround is to resize the partition via fdisk then resize the filesystem via resize2fs:

  • umount /dev/sda1 /dev/sda2
  • fdisk /dev/sda
    • p #to see what it is like
    • d 2 #remove partition 2
    • d 1 #remove partition 1
    • n #new partition 1, use all space as it suggests - something like 1-484
    • t #set its type to 83 (linux)
    • a #make it bootable
    • w #write
  • resize2fs /dev/sda1
  • e2fsck -f /dev/sda1 #force check

Note: This sentence is being put in here to make it easier for those who want to remove default programs from Easy Mode free up space to find this article; should they decide to search the wiki before posting.

 
howto/removeunionfs.txt · Last modified: 2008/06/15 12:45 by stevelawuk
 
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
This website is no longer under a Creative Commons license.
All rights are reserved by Eeeuser.com and each individual author
If you want to reproduce content, all individual contributers must be identified and you must seek permission from Eeeuser.com