3 usage="Usage: $0 disk1|disk2"
12 if [ $# -eq 1 ] ; then
13 if [ "$1" = "disk1" ] ; then
14 mtch="/dev/sdb1 /share/hdd/data ext3 rw 0 0"
17 elif [ "$1" = "disk2" ] ; then
18 mtch="/dev/sda1 /share/flash/data ext3 rw 0 0"
19 targ=/share/flash/data
30 # Check it's a real mount point
32 echo "Waiting for $targ"
36 if grep "$mtch" /proc/mounts >/dev/null 2>&1 ; then
37 echo "Target disk is $targ"
45 if [ $CNT -eq 0 ] ; then
46 echo "Error: $targ is not a mounted disk"
50 # Start at the root directory
54 # Save the existing ipkg database.
56 rm -rf $targ/usr/lib/ipkg.old
57 if [ -f $targ/usr/lib/ipkg/status ] ; then
58 mv $targ/usr/lib/ipkg $targ/usr/lib/ipkg.old
61 # Copy the complete rootfs to the target.
63 echo "Copying the complete rootfs from / to $targ."
64 /usr/bin/find / -print0 -mount | /usr/bin/cpio -p -0 -d -m -u $targ
65 rm -rf $targ/dev ; mv $targ/dev.state $targ/dev
66 rm -rf $targ/var ; mv $targ/var.state $targ/var
68 # Copy over the existing ipkg database.
70 if [ -f $targ/usr/lib/ipkg.old/status ] ; then
71 echo "Preserving existing ipkg database on target disk."
72 ( cd $targ/usr/lib/ipkg.old ; tar cf - . ) | ( cd $targ/usr/lib/ipkg ; tar xf - )
75 echo "Linking /usr/bin/ipkg executable on target disk."
76 rm -f $targ/usr/bin/ipkg ; ln -s /usr/bin/ipkg-cl $targ/usr/bin/ipkg
78 # Create the boot flag file.
80 rm -f /.sd??root $targ/.sd??root
82 echo "Creating /$flag to direct switchbox to boot from $targ."