Skip to content

Commit 2d8412d

Browse files
committed
Bugfix: did not set SRC_ROOT when using -s option
1 parent 8b1a659 commit 2d8412d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

rpi-clone

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22

3-
VERSION=1.7
3+
VERSION=1.7.1
4+
# Version 1.7.1 2017/08/19
5+
# * Bugfix: did not set SRC_ROOT when using -s option
46
# Version 1.7 2017/08/19
57
# * For cloning from USB boots, source disk is booted disk from mtab instead
68
# of hardwiring mmcblk0. Add -s option to override the auto source disk.
@@ -84,6 +86,7 @@ usage()
8486
echo " -f - force initialize the destination partitions"
8587
echo " -s sdS - specify sdS is the booted source disk to clone from."
8688
echo " Use this if the boot source auto detect from /etc/mtab fails."
89+
echo " Use with caution, be sure sdS is really the booted disk."
8790
echo " -c - cross filesystem boundaries (include mounted drives)"
8891
echo " -x - use set -x for very verbose bash shell script debugging"
8992
echo ""
@@ -92,7 +95,7 @@ usage()
9295
echo " The booted disk is automatically determined from /etc/mtab."
9396
echo " Example: $PGM -s sda sdb"
9497
echo " Use sda as the booted source disk to clone from."
95-
echo " Use this if the auto detect of the booted sda disk fails"
98+
echo " Use this if the auto detect of the booted sda disk fails."
9699
echo ""
97100
echo " Clone (rsync) a running Raspberry Pi file system to a destination"
98101
echo " SD card (in a USB card reader) or USB disk 'sdN' plugged into a"
@@ -150,6 +153,12 @@ do
150153
-s|--src-disk)
151154
shift
152155
SRC_DISK=$1
156+
if [ "$SRC_DISK" == "mmcblk0" ]
157+
then
158+
SRC_ROOT=${SRC_DISK}p2
159+
else
160+
SRC_ROOT=${SRC_DISK}2
161+
fi
153162
;;
154163
-x)
155164
set -x
@@ -172,7 +181,7 @@ done
172181
SRC_BOOT_PARTITION_TYPE=`parted /dev/$SRC_DISK -ms p | grep "^1" | cut -f 5 -d:`
173182
SRC_ROOT_PARTITION_TYPE=`parted /dev/$SRC_DISK -ms p | grep "^2" | cut -f 5 -d:`
174183

175-
#echo $SRC_DISK to $DST_DISK
184+
#echo $SRC_DISK to $DST_DISK SRC_ROOT: $SRC_ROOT
176185
#echo $SRC_BOOT_PARTITION_TYPE
177186
#echo $SRC_ROOT_PARTITION_TYPE
178187

0 commit comments

Comments
 (0)