17 # find the disk to install to
22 for f in /sys/block/[sh]d[a-z]; do
24 if [ "$bdev" = "$SRC" ]; then
27 # the first block device that's not root? take it!
38 echo "Starting installer!"
39 if [ ! -d /root/etc ]; then
40 echo "Error: /root doesn't appear to have a valid filesystem mounted!"
44 ROOT_SRC=$(grep ' /root ' /proc/mounts | cut -d' ' -f1)
45 ROOT_SRC=$(readlink -f $ROOT_SRC | sed 's/.*\/\([hs]d[a-z]\)[0-9]\+$/\1/')
47 TARGET=$(find_target "$ROOT_SRC")
49 if [ -z "$TARGET" ]; then
50 echo "Error: couldn't find drive to install to!"
54 # don't keep fs mounted while copying it
57 # wait 15s for user realize that they've made a mistake
58 echo "Copying data from [$ROOT_SRC] => [$TARGET]"
59 echo "IF THIS IS INCORRECT, REBOOT NOW OR YOU WILL LOSE DATA! (waiting 15s)"
62 echo "Too late, starting copy..."
63 # ideally, we'll resize the filesystem/partitions later..
64 dd if=/dev/$ROOT_SRC of=/dev/$TARGET bs=4k
66 echo "Done. Remove installer media."
67 while [ -d /sys/block/$ROOT_SRC ]; do
73 for x in $(cat /proc/cmdline); do