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

RPi 3B+ 'clone by initialization' failure #108

Open LiamFry opened 3 years ago

LiamFry commented 3 years ago

Noob to rpi-clone. Desperate to get off SD card; I've burnt through three in a year!

I'm on a RPi 3B+ running Raspbian GNU/Linux 10 (buster) (as reported by cat /etc/os-release) This was not a fresh buster install; I upgraded from stretch. I have a JOIOT USB-C SSD (120GB) that I'm using for the external drive.

I ran sudo rpi-clone -f -p 256M sda and got the following:

---------------------------------------------------------------------------
Part      Size    FS     Label           Part   Size    FS     Label
1          63.0M  fat16  --              1       37.5M  fat32  --
2          29.7G  EXT    --              2       14.9G  fat32  --

5          31.5M  ext4   SETTINGS
6 /boot    66.0M  fat32  --
7 root     29.6G  ext4   root
---------------------------------------------------------------------------
== Initialize: IMAGE partition table - forced by option ==
1                                    : RESIZE  MKFS  SYNC to sda1
5                                    : IMAGE to sda5
6 /boot               (55.0M used)   : MKFS  SYNC to sda6
7 root                (2.1G used)    : RESIZE  MKFS  SYNC to sda7
---------------------------------------------------------------------------
-p 256M                : resize /boot to 524288 blocks of 512 Bytes.
Run setup script       : no.
Verbose mode           : no.
-----------------------:
** WARNING **          : All destination disk sda data will be overwritten!
-----------------------:

Initialize and clone to the destination disk sda?  (yes/no): yes
Optional destination ext type file system label (16 chars max): kore0-USB

Initializing
  Imaging past partition 1 start.
  => dd if=/dev/mmcblk0 of=/dev/sda bs=1M count=8 ...
./rpi-clone: line 1435: 129024
65534
135168: syntax error in expression (error token is "65534
135168")
Ignoring extra data in partition table 5.
Ignoring extra data in partition table 5.
Ignoring extra data in partition table 5.
Destination disk has same Disk ID as source, changing it.
Ignoring extra data in partition table 5.
Ignoring extra data in partition table 5.
Ignoring extra data in partition table 5.
Disk identifier changed from 0x409d06da to 0xe5436c1c.
Error: Can't have a partition outside the disk!
Ignoring extra data in partition table 5.
Ignoring extra data in partition table 5.
Ignoring extra data in partition table 5.

Syncing file systems (can take a long time)
Syncing mounted partitions:
     e2label /dev/sda7  kore0-USB
e2label: No such file or directory while trying to open /dev/sda7
Couldn't find valid filesystem superblock.
  Mounting /dev/sda7 on /mnt/clone
mount: /mnt/clone: special device /dev/sda7 does not exist.
    Mount failure of /dev/sda7 on /mnt/clone.
Aborting!

This whole process took less than 3 seconds to execute and fail.

And this is what it did to my (120G) SSD:

$ sudo fdisk -l /dev/sda
Ignoring extra data in partition table 5.
Ignoring extra data in partition table 5.
Ignoring extra data in partition table 5.
Disk /dev/sda: 119.2 GiB, 127951437824 bytes, 31238144 sectors
Disk model: Tech
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xe5436c1c

Device     Boot     Start        End    Sectors   Size Id Type
/dev/sda1            8192     137215     129024   504M  e W95 FAT16 (LBA)
/dev/sda2          137216   62333951   62196736 237.3G  5 Extended
/dev/sda5       849250247 4251203106 3401952860  12.7T 26 unknown

Note how I now have over 12TB of storage in partition 5. (Clearly wrong.)

I was under the impression that the -f option would essentially repartition and rewrite the destination drive (/dev/sda), so I went into this processes believing that the initial structure of /dev/sda was irrelevant. Do I need to pre-partition/pre-format my external SSD? This still doesn't explain the syntax error in rpi-clone ...

As I said, I'm desperate to get off the SD card. I'm happy (actually, prefer) to keep it for R/O booting; I just want the bulk of the OS (i.e. all the writing) to be done on the SSD. Anyone have an idea what I could do?