billw2 / rpi-clone

A shell script to clone a booted disk.
BSD 3-Clause "New" or "Revised" License
2.49k stars 327 forks source link

Error: Can't have a partition outside the disk! #120

Open mrumel opened 3 years ago

mrumel commented 3 years ago

I am getting this error with the script when I try and run it on Ubuntu 20.04 LTS for ARM64. I know the script name is "wrong" when I copied it, I accidently used the wrong name.

ubuntu@ubuntu:~$ sudo sys-cone sda -F -x
+ shift
+ '[' '' ']'
+ (( custom_sync ))
+ (( custom_sync ))
+ [[ no == \y\e\s ]]
+ (( usage_error ))
+ (( convert_to_partuuid ))
+ live=1
+ temp=2
+ fail=3
+ (( p = 1 ))
+ (( p <= n_src_parts ))
+ (( !src_exists[p] ))
+ blocks=0
+ dst_mount_flag[p]=0
+ '[' /boot/firmware '!=' '' ']'
+ dst_mount_flag[p]=1
++ echo '/dev/mmcblk0p2 122644532 3558560 114060084 4% /
/dev/mmcblk0p1 258095 122063 136032 48% /boot/firmware'
++ grep -m 1 '^/dev/mmcblk0p1'
++ cut -d ' ' -f 3
+ blocks=122063
+ src_used_sectors[p]=244126
+ (( p++ ))
+ (( p <= n_src_parts ))
+ (( !src_exists[p] ))
+ blocks=0
+ dst_mount_flag[p]=0
+ '[' / '!=' '' ']'
+ dst_mount_flag[p]=1
++ echo '/dev/mmcblk0p2 122644532 3558560 114060084 4% /
/dev/mmcblk0p1 258095 122063 136032 48% /boot/firmware'
++ grep -m 1 '^/dev/mmcblk0p2'
++ cut -d ' ' -f 3
+ blocks=3558560
+ src_used_sectors[p]=7117120
+ (( p++ ))
+ (( p <= n_src_parts ))
+ '[' sda = '' ']'
++ cat /proc/partitions
++ grep -m 1 sda
+ chk_disk='   8        0   30868480 sda'
+ '[' '   8        0   30868480 sda' == '' ']'
+ dst_part_base=sda
+ [[ a =~ ^[0-9]$ ]]
+ '[' mmcblk0 == sda ']'
++ parted -m /dev/sda unit s print
++ tr -d ';'
Error: Can't have a partition outside the disk!

For additional debugging help, here's the output from lsblk:

ubuntu@ubuntu:~$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0         7:0    0  48.9M  1 loop /snap/core18/1949
loop1         7:1    0  48.9M  1 loop /snap/core18/2068
loop2         7:2    0  59.6M  1 loop /snap/lxd/20330
loop3         7:3    0    27M  1 loop /snap/snapd/10709
loop4         7:4    0  27.9M  1 loop /snap/snapd/11843
loop5         7:5    0  61.6M  1 loop /snap/lxd/19040
sda           8:0    1  29.4G  0 disk
├─sda1        8:1    1   256M  0 part
└─sda2        8:2    1  29.2G  0 part
mmcblk0     179:0    0 119.1G  0 disk
├─mmcblk0p1 179:1    0   256M  0 part /boot/firmware
└─mmcblk0p2 179:2    0 118.9G  0 part /
scargill commented 2 years ago

Strangely, for the first time ever (I use rpi-clone on a daily basis with up to date Raspbian on RPi4) I have just had that exact same error cloning to a second SSD from the main SSD. I do this cloning regularly as I'm constantly experimenting with and writing about various RPi4-based projects. "Can't have a partition outside the disk".

So you know what I'm talking about - here are my standard functions in /ryc/bash.bashrc below (user PI can use them without any prefix or parameters)- been using for a LONG time on a daily basis before experimenting. The functions starting with CCLONE are clean clones - including partitioning - the others assume pre-used SSDs or SDs.

SO I am at a loss as to why even a CCLONE is failing now from the main SSD to the backup SSD when it has always worked. Any pointers appreciated. If I find out why this happened I will of course report back.

#optional hostnames in 4 functions below
clone () { 
printf "${LIGHTBLUE}Creating a quick clone on SDA${NC}\n"
touch /home/pi/clone-date
bashCmd=(sudo rpi-clone -U sda)
if [ -n "$1" ];  then
bashCmd+=(-s "$1")
fi
"${bashCmd[@]}"
}

cclone () { 
printf "${LIGHTRED}Creating a full clone on SDA${NC}\n"
touch /home/pi/clone-date
bashCmd=(sudo rpi-clone -f -U sda)
if [ -n "$1" ];  then
bashCmd+=(-s "$1")
fi
"${bashCmd[@]}"
}

cloneb () { 
printf "${LIGHTBLUE}Creating a quick clone on SDB${NC}\n"
touch /home/pi/clone-date
bashCmd=(sudo rpi-clone -U sdb)
if [ -n "$1" ];  then
bashCmd+=(-s "$1")
fi
"${bashCmd[@]}"
}

clonem () { 
printf "${LIGHTBLUE}Creating a quick clone on MMCBLK0${NC}\n"
touch /home/pi/clone-date
bashCmd=(sudo rpi-clone -U mmcblk0)
if [ -n "$1" ];  then
bashCmd+=(-s "$1")
fi
"${bashCmd[@]}"
}

ccloneb () { 
printf "${LIGHTRED}Creating a full clone on SDB${NC}\n"
touch /home/pi/clone-date
bashCmd=(sudo rpi-clone -f -U sdb)
if [ -n "$1" ];  then
bashCmd+=(-s "$1")
fi
"${bashCmd[@]}"
}

cclonem () { 
printf "${LIGHTRED}Creating a full clone on MMCBLK0${NC}\n"
touch /home/pi/clone-date
bashCmd=(sudo rpi-clone -f -U mmcblk0)
if [ -n "$1" ];  then
bashCmd+=(-s "$1")
fi
"${bashCmd[@]}"
}

cclonec () { 
printf "${LIGHTRED}Creating a full clone on SDC${NC}\n"
touch /home/pi/clone-date
bashCmd=(sudo rpi-clone -f -U sdc)
if [ -n "$1" ];  then
bashCmd+=(-s "$1")
fi
"${bashCmd[@]}"
}

clonec () { 
printf "${LIGHTBLUE}Creating a quick clone on SDC${NC}\n"
touch /home/pi/clone-date
bashCmd=(sudo rpi-clone -U sdc)
if [ -n "$1" ];  then
bashCmd+=(-s "$1")
fi
"${bashCmd[@]}"
}