3 usage="Usage: $0 disk1|disk2"
12 if [ $# -eq 1 ] ; then
13 if [ "$1" = "disk1" ] ; then
16 elif [ "$1" = "disk2" ] ; then
17 targ=/share/flash/data
19 elif [ "$1" = "hdd-data" ] ; then
22 elif [ "$1" = "hdd-conf" ] ; then
25 elif [ "$1" = "flash-data" ] ; then
26 targ=/share/flash/data
28 elif [ "$1" = "flash-conf" ] ; then
29 targ=/share/flash/conf
40 # Check it's a real mount point
42 if grep $targ /proc/mounts >/dev/null 2>&1 ; then
43 echo "Target disk is $targ"
45 echo "Error: $targ is not a mounted disk"
49 # Start at the root directory
53 # Save the existing ipkg database.
55 rm -rf $targ/usr/lib/ipkg.old
56 if [ -f $targ/usr/lib/ipkg/status ] ; then
57 mv $targ/usr/lib/ipkg $targ/usr/lib/ipkg.old
60 # Copy the complete rootfs to the target.
62 echo "Copying the complete rootfs from / to $targ."
63 /usr/bin/find / -print0 -mount | /usr/bin/cpio -p -0 -d -m -u $targ
64 rm -rf $targ/dev ; mv $targ/dev.state $targ/dev
65 rm -rf $targ/var ; mv $targ/var.state $targ/var
67 # Copy over the existing ipkg database.
69 if [ -f $targ/usr/lib/ipkg.old/status ] ; then
70 echo "Preserving existing ipkg database on target disk."
71 ( cd $targ/usr/lib/ipkg.old ; tar cf - . ) | ( cd $targ/usr/lib/ipkg ; tar xf - )
74 echo "Linking /usr/bin/ipkg executable on target disk."
75 rm -f $targ/usr/bin/ipkg ; ln -s /usr/bin/ipkg-cl $targ/usr/bin/ipkg
77 # Create the boot flag file.
79 rm -f /.sd??root $targ/.sd??root
81 echo "Creating /$flag to direct switchbox to boot from $targ."