#!/bin/sh -e # # Script to swap from a FreeBSD system to a Debian GNU/kFreeBSD # # Originally written by Robert Millan # Modified by Guillem Jover # # $Id: swap 14 2004-05-23 18:41:12Z rmh $ # VERSION=0.1.1 OLDROOT=/old NEWROOT=$1 if ! test "$#" = "1" ; then echo Swaps root filesystem contents with a given directory, use with care !!! echo !!! This script may trash your system and destroy your data !!! echo echo Usage: `basename $0` directory exit fi if ! test "`mount | grep -v ' on / ' | grep -v ' on /dev ' | wc -l | rev | cut -c 1`" = "0" ; then echo There are mounted filesystems other than / and /dev, exiting exit fi test -e /bin/mkdir || { echo Needed /bin/mkdir does not exist; exit 1; } test -e /bin/mv || { echo Needed /bin/mv does not exist; exit 1; } test -e $NEWROOT || { echo Directory $NEWROOT does not exist; exit 1; } test ! -e $OLDROOT || { echo Directory $OLDROOT already exist; exit 1; } move_list="" for i in /* ; do case i in /dev|/boot|/lib/ld*) ;; *) move_list="$move_list $i" ;; esac done echo Going to move: $move_list echo Verify it and press [Enter] to continue or [Ctrl-C] to cancel. read KEY rm -rf $NEWROOT/dev rm -rf $NEWROOT/boot # we want to know what happens here.. set -x mkdir -p /lib cp /$NEWROOT/lib/ld.so.1 /lib/ mkdir $OLDROOT echo "$move_list" | xargs -J % mv % $OLDROOT/ LD_LIBRARY_PATH=$OLDROOT/$NEWROOT/lib \ $OLDROOT/$NEWROOT/bin/mv $OLDROOT/$NEWROOT/lib/* /lib/ $OLDROOT/$NEWROOT/bin/mv $OLDROOT/$NEWROOT/* / set +x # using native commands now #echo "Working around NFS support" #mkdir /var/db #cp -f $OLDROOT/etc/netconfig /etc/ #echo "Setting up root passwd" #dpkg-reconfigure passwd rmdir $OLDROOT/$NEWROOT echo Seems it went ok echo Now running native-install ... press [Enter] read KEY chroot / /native-install