Blog Forum Wiki Links Contact Us NetbookUser
RunCore Pro IV SSD Transforms your ASUS EEE PC by increasing 
performance 5-40X. Your satistfaction guaranteed RunCore Pro 70mm SATA Mini PCI-e SSD
RunCore Pro IV 70mm SATA II Mini PCI-e SSD
RunCore Pro IV 2.5 Inch SATA II SSD

You are not logged in.

#1 2009-03-20 6:34:33 am

bongo
Member
Registered: 2008-01-09
Posts: 57

Hot to remove unionfs *and* keep all you customizations.

My apologies if this is covered already but I couldn't find it anywhere so here goes...

Up until recently I have lived happily with unionfs on my eee 701, then I tried installing lighttd and got stuck because of it. I then decided to remove unionfs but soon found out that every how-to I could find on the wiki would wipe my eee clean, losing any changes I had made to the setup. Not wanting to repeat those changes for the n-th time I set out to remove unionfs *and* keep all my setting. Piecing together information from other subjects I eventually ended with a eee in good working order, booting and running from *one* etx3 partition on the internal SSD.

1: Tools and parts
-An eee in good working order, with unionfs
-A usb-thumbdrive with putty
-An external harddrive with some free space

2: Preparations
-Backup your eee, booting puppy from my thumbdrive I followed the 'mixed backup' procedure from this page: http://wiki.eeeuser.com/backup_restore

Code:

Mixed Backup
This is the most complex method, but its also the most flexible. It should also produce backups that are substantially smaller then the previous methods, which is beneficial to 8G+ owners. First open a terminal window and become a “super user” with “sudo -i”. Next we're going to create compressed tar archives of system, and user partitions. 

Create the directories for the partitions to be mounted on. 

mkdir /mnt/sda1 

mkdir /mnt/sda2 

Now mount the partitions. 

mount /dev/sda1 /mnt/sda1 

mount /dev/sda2 /mnt/sda2 

Now CD to the first directory. 

cd /mnt/sda1 

And create the archive file. 

tar -cpszf /PATH/TO/BACKUP-sda1.tar.gz . 

When finished CD to the next directory. 

cd /mnt/sda2 

Now archive here as well. 

tar -cpszf /PATH/TO/BACKUP-sda2.tar.gz . 

Ok now the majority of the files are backed up. But there's still a bit that needs to be done. Next lets backup sda3 and sda4, now I personally don't see a current use for sda3 but we are trying to create a way to make a “perfect restore” First sda3. 

dd if=/dev/sda3 | gzip -c9 > /PATH/TO/BACKUP-sda3.img.gz 

Now sda4. 

dd if=/dev/sda4 | gzip -c9 > /PATH/TO/BACKUP-sda4.img.gz 

Ok now we have all the partitions backed up. However we now need to backup the boot blocks and partition tables. First the mbr”Master Boot Record” combined with the partition table and the “protected storage” section that grub uses for its stage 1.5 

dd if=/dev/sda bs=8192 count=1 | gzip -c9 > /PATH/TO/BACKUP-boot.img.gz 

Now there shouldn't be anything on the boot blocks for sda1 and sda2 but lets back them up for good measure too. 

dd if=/dev/sda1 bs=512 count=1 | gzip -c9 > /PATH/TO/BACKUP-boot-sda1.img.gz 

dd if=/dev/sda2 bs=512 count=1 | gzip -c9 > /PATH/TO/BACKUP-boot-sda2.img.gz 

Congratulations you've now backed up your system, now onto the restoration! 

First thing we need a partition table. 

gunzip -c /PATH/TO/BACKUP-boot.img.gz | dd of=/dev/sda 

With this we should have our partition table, and boot block plus the reserved section for grub restored. Now we need to put some filesystems on those partitions. 

mkfs.ext2 -L SYSTEM /dev/sda1 

mkfs.ext3 -L USER /dev/sda2 

If it asks you if your sure just tell it yes. Now we should restore the rest of our boot blocks just in case we had something on them. 

gunzip -c /PATH/TO/BACKUP-boot-sda1.img.gz | dd of=/dev/sda1 

gunzip -c /PATH/TO/BACKUP-boot-sda2.img.gz | dd of=/dev/sda2 

Ok now on to the files, to restore those we need to mount the newly formated partitions so first lets create the mount points. 

mkdir /mnt/sda1 

mkdir /mnt/sda2 

Mount the partitions: 

mount /dev/sda1 /mnt/sda1 

mount /dev/sda2 /mnt/sda2 

Ok now on to the first directory. 

cd /mnt/sda1 

And restore its files. 

tar -xf /PATH/TO/BACKUP-sda1.tar.gz 

And to the next. 

cd /mnt/sda2 

Restore also. 

tar -xf /PATH/TO/BACKUP-sda2.tar.gz 

Ok the only pieces left are sda3 and sda4, and they are restored pretty simply. 

gunzip -c /PATH/TO/BACKUP-sda3.img.gz | dd of=/dev/sda3 

gunzip -c /PATH/TO/BACKUP-sda4.img.gz | dd of=/dev/sda4 

Now your system should be restored. If you at anytime you want to backup you user changes after this just use the “tar” method described above for user partitions.

3: Merging the partitions
-Still working from putty I mounted both partitions in unionfs-mode, just like the eee do in it's default state (except the system is running from a thumbdrive, which I believe is crucial to get the file backup to work properly). I then made a backup of the unionfs filesystem using the same method I used for the initial backup. tar -cpszf /PATH/TO/BACKUP-sda1-sda2-merged.tar.gz .

Code:

How to mount a unionfs filesystem. First you need to create 3 folders, two is for the filesystems on your SSD, the last for the actual unionfs.
mount -t ext2 -o ro $ROOT /mnt-system
mount -t ext3 -o rw /dev/sda2 /mnt-user
mount -t unionfs -o dirs=/mnt-user=rw:/mnt-system=ro unionfs /mnt
This will mount a unionfs filesystem at /mnt  ,from where you will do the file backup

4: Modifying the internal filesystem.
-Using Gparted I deleted all partitions except the first, which I just reformatted as ext3 and then extended to cover the entire drive.
-Note: sda3 and sda4 are there for BIOS-updates and the 'fastboot' option so you may want to leave those two alone. I have not tested yet if removing them will cause problems.

5: Restoring
-Using this command tar -xf /PATH/TO/BACKUP-sda1-sda2-merged.tar.gz I placed the merged files back on the internal drive.

6: Booting
-The system will probably be unable to boot until you fix the boot loader. How that is done is explained here under 'creating a new ramfs' http://wiki.eeeuser.com/howto:removeunionfs.

Code:

Boot the eeePC.
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 -iNow 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. 

Comment out the following lines, by adding a # sign as the first character of each line, 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: 

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). 

edit line 12 of the init file and change ext2 by ext3
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: 

cd ..
rm -rf tmp

I did however simplify the process a bit as I did the entire process from putty and never bothered with going into rescue mode. Just edit /boot/grub/menu.lst and change the name of the ramfs file to the one you just created yourself.



That's it. Feel free to tell me if I have forgotten something ot done something horribly wrong here.

(it worked for me but I cannot guarantee it will work for you etc.etc. REMEMBER TO MAKE A BACKUP FIRST)
Edit: Fixed some typos and added the bit about mounting unionfs. Oh, lighttpd is working now I have ext3 on my system disk. wink

Last edited by bongo (2009-03-21 6:09:54 am)


I got a black eeepc 701, currently testing any distro that might or might not work 100%

Offline

 

#2 2009-03-21 12:49:14 am

albkwan
ExtrEmE User
From: Hong Kong
Registered: 2007-11-04
Posts: 1422
Website

Re: Hot to remove unionfs *and* keep all you customizations.

bongo,

You have presented a new approach to merging the 2 unionfs partitions. In fact, there is a solution to this as suggested by samo on altern.org in this wiki: Merging changes from partition 2 into partition 1. I have tried that before merging the 2 unionfs partitions on the EeePC Linux I have installed to my desktop and it worked.

Please note that the wiki instruction for merging partitions will only work for unionfs, not aufs
-------------------

Comparing the 2 methods:

1) With samo's method, I only need USB free disk space of about 1.4 GB to backup sda2 whereas I will need plenty of free disk space to backup the whole SSD in your method.

2) Samo's method is potentially dangerous - any mistake during the process will leave you a system not recoverable.

3) However, I see the potential to convert samo's method into a script (which can certainly help beginners):
- boot from USB, say Puppy Linux, and run the script
- mount sda1 and sda2 (hdc1 and hdc2 in Puppy Linux)
- take care of all those .wh files in sda2 and their corresponding files/folders in sda1
- backup files from sda2 to USB (xxx.tar.gz)
- use fdisk and resize2fs to combine the sda1 and sda2,
- restore xxx.tar.gz onto sda1
- remove all .wh.* placeholders in sda1

-------------------

Finally, just a few comments to your method:
1) sda3 is for BIOS update and sda4 is for boot booster, some people may want to keep them.
2) You don't need to backup and restore /proc /sys /tmp, just a waste of disk space.
3) For 900 and later models with 2 SSD, we don't need to backup /home either because it is mounted to /dev/sdb1.
4) Now that you have changed the initramfs to mount sda1 as ext3, you should have also modified the filesystem in sda1 to ext3 with "tune2fs -j". Apparently you have forgotten to write down this step in your instruction.

albkwan

Last edited by albkwan (2009-04-17 11:54:36 pm)


EeePC 4G white,
Default Xandros (Easy Mode + icewm start menu) on 1st SSD/2nd 16GB SSD added/SD/USB/
http://eeepc.fire.prohosting.com/
http://eeepc-albkwan.blogspot.com/

Offline

 

#3 2009-03-21 6:06:03 am

bongo
Member
Registered: 2008-01-09
Posts: 57

Re: Hot to remove unionfs *and* keep all you customizations.

Thank you for your comments. smile

1) I didn't know the purpose of sda3 and 4 when I started so I just deleted them (my system didn't even have sda4 for some reason...), I'll add it to my list. smile

2) I am dimly aware that some folders don't need to be backed up but as I had plenty of disk space to waste I just ignored that bit. wink   I did however play with the -exclude option a bit but that was because my first try on doing a full file backup was when running xandros and I was worried it would try to do a recursive backup of the destination backup file... yikes Oh well, never got the -exclude bit to work properly so I defaulted to the 'safe and simple' method described here. Besides, the resulting file was only 1.3GB but that figure will of course vary depending on your use ( I mostly use SD-cards for user files )

3) I have only tested this on my 701, maybe you need to do an extra bit of cleaning up afterwards to get the /home folder sorted on other models?

4) I never bothered with converting sda1, as I was going to do a full file restore to that partition later I simply reformatted it as ext3. If I had converted it I would have to deal with all the files left there, a 'rm * -rf' would have solved that I guess but reformatting seemed like the better option.


I got a black eeepc 701, currently testing any distro that might or might not work 100%

Offline

 

#4 2009-03-22 10:34:51 pm

Freshmeadow
Senior Member
From: Guelph, Ontario, Canada
Registered: 2008-05-23
Posts: 149

Re: Hot to remove unionfs *and* keep all you customizations.

I have followed the instructions by jpmcc in the following thread and I can testify it works perfectly. I am typing this from a xandros with no unionfs right now>>>
http://forum.eeeuser.com/viewtopic.php?id=2650&p=8
Follow post 7 on this page. smile


EeePC 701 4G Galaxy Black with Xandros on the SSD drive wtih unionfs removed and OpenSuse 11.1 on external 8G USB pen drive.
OpenSuse11.1 and Ubuntu Jaunty Jackalope on desktop.

Offline

 

#5 2009-03-23 12:52:12 am

albkwan
ExtrEmE User
From: Hong Kong
Registered: 2007-11-04
Posts: 1422
Website

Re: Hot to remove unionfs *and* keep all you customizations.

Freshmeadow wrote:

I have followed the instructions by jpmcc in the following thread and I can testify it works perfectly. I am typing this from a xandros with no unionfs right now>>>
http://forum.eeeuser.com/viewtopic.php?id=2650&p=8
Follow post 7 on this page. smile

The script mentioned on that page is exactly what I meant. However, that eeepc.sh script will only work on a 4G AND if there is less than 100 MB stuff in sda2 because that is the free disk space available in sda1.

For a complete solution, the files in sda2 should first be backup to USB before fdisk and resize sda1, then restore the files back onto sda1. Also, that script does not take care of the .wh. files which will just be a waste of inodes and disk space after you have removed unionfs.

For example, if you have installed a new version of a certain library libxyz.so.2. You don't need the old file libxyz.so.1 any more. But with this script, you just copy libxyz.so.2 to sda1 without deleting libxyz.so.1. The 2 methods discussed in this thread takes care of this.


EeePC 4G white,
Default Xandros (Easy Mode + icewm start menu) on 1st SSD/2nd 16GB SSD added/SD/USB/
http://eeepc.fire.prohosting.com/
http://eeepc-albkwan.blogspot.com/

Offline

 

#6 2009-03-23 10:21:10 pm

Freshmeadow
Senior Member
From: Guelph, Ontario, Canada
Registered: 2008-05-23
Posts: 149

Re: Hot to remove unionfs *and* keep all you customizations.

Thank you albkwan. I did not realize that...
And, I did not know it would only work on the 4G...
But, for me on my 4G, it is working so far with only 69% disk usage. smile


EeePC 701 4G Galaxy Black with Xandros on the SSD drive wtih unionfs removed and OpenSuse 11.1 on external 8G USB pen drive.
OpenSuse11.1 and Ubuntu Jaunty Jackalope on desktop.

Offline

 

#7 2009-05-04 5:24:29 am

RonCam
Member
Registered: 2009-01-28
Posts: 20

Re: Hot to remove unionfs *and* keep all you customizations.

bongo wrote:

1: Tools and parts
-An eee in good working order, with unionfs
-A usb-thumbdrive with putty
-An external harddrive with some free space

I am ready to change my file system, but am new to GNU/Linux and want to make sure I understand all of the directions completely before starting.  So, beginning with the above quote:

May I assume all references to putty in the above documentation refer not to puTTY but to Puppy?  If I am mistaken, please clarify. 

If I have the terminology right, it will be easier to figure out what is "going on."


L701 - stock Xandros

Offline

 

#8 2009-05-19 5:45:26 pm

avoura
Member
Registered: 2009-04-21
Posts: 19

Re: Hot to remove unionfs *and* keep all you customizations.

I too am interested in removing the unionfs setup, and merge the /ro and /rw partitions into 1 to make things work better.

I am wondering as well what this "putty" is, as no description of its purpose was given.

Some of us are beginners when it comes to more serious linux stuff like this, but I have been using Linux for over a year on a regular basis and have now been using my Eee PC for a few weeks. I have also used Xandros on a normal PC as well (versions 1, 3 and 4). But the lack of space on /rw leads me to believe that the way the first SSD inside the 901 is setup is a design fault, and now that Asus are basically not providing Linux on their new range of Eee PCs, I doubt if they will ever give us a better setup on the 901. Getting a 901 was hard enough as it was, but for me it is the ideal size (physically, with its 226 mm screen, and with its 20 GB storage capacity), with the smaller screen of the 701 being too small, and the newer larger models being too big to be as portable as I would like.

I just want to get the sda1 and sda2 partitions merged into one rewriteable system partition so I can run Xandros more sanely.


Asus Eee PC 901 Linux 20 GB
Using Eee PC since 17 April 2009
Using Linux since 1998, Xandros 1, 3, 4; Ubuntu 7.10, 8.04; plus many other distros. Dumped Windows in 2007.

Offline

 

#9 2009-05-19 5:50:58 pm

winotree
ExtrEmE User
From: Texas
Registered: 2007-11-11
Posts: 2742

Re: Hot to remove unionfs *and* keep all you customizations.

I believe it means puppy linux http://www.puppylinux.org/


2007 ASUS EeePC 701(B) - 4GB SSD - Original 0401 BIOS - 1GB RAM - Xubuntu 9.10 - Shiretoko 3.5.6pre

Offline

 

Board footer

Powered by PunBB 1.2.15
© Copyright 2002–2005 Rickard Andersson