rpi-clone from NVME to USB-Stick #150
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I have a Notebook with an NVME SSD and Debian 11 64 bit.
If I install rpi-clone
$ git clone https://github.com/billw2/rpi-clone.git
$ cd rpi-clone
$ sudo cp rpi-clone /usr/local/sbin/sys-clone
$ sudo cp rpi-clone-setup /usr/local/sbin/sys-clone-setup
I get no Errors.
If I want to Clone my System from the nvme ssd I get the following error:
root@debian:~# rpi-clone
Error: Could not stat device /dev/nvme0n1p - No such file or directory.
sdc 8:32 1 28.8G 0 disk
nvme0n1 259:0 0 238.5G 0 disk
├─nvme0n1p1 259:1 0 512M 0 part /boot/efi
└─nvme0n1p2 259:2 0 237G 0 part /
Sdc is my USB Stick where I have to Clone my System
Nvme01n is the System and boot Partition.
Can anyone help me with this error?
I want with rpi-clone a bootable system if my system crash.
Thanks in advance
Please check https://github.com/billw2/rpi-clone/pull/147
Sorry don't solve my problem.
I changed in rpi-clone the Line
begin at line 1060
if [[
{chk_disk: -1} =~ ^[0-9]]]then
if [[ $dst_disk == "mmcblk" || $dst_disk == "nvme" ]] # update this line
then
SD_slot_dst=1
....
But I get the same error.
My problem is that I want to clone from nvme to USB-Stick not the other way.
Can anyone help me?
My NVME has 256 GB but I only have written 20 GB
My destination has 128 GB.
Must the destination 256 GB or larger?
As far as I know it has to have at least 20GB and some space for the boot partition.
I don't have a NVMe SSD but a CM4 with NVMe. I will check whether #147 fails for me.
OK I try to copy with this command
dd if=/dev/nvme0n1 of=/dev/sdc bs=100M status=progress
My NVME has 256 GB and my destination device 128 GB
after 128 GB I get this error
dd: error writing '/dev/sdc': No space left on device
So I think he will copy the whole source device not the used space.
This will not work. dd is a 1:1 copy and you need at least the same size of your source device for your target device.
I thought you want to use rpi-clone 😟
Yes I want to use rpi-clone but this dont work for me.
I want to explain it:
I install rpi-clone with these commands:
$ git clone https://github.com/billw2/rpi-clone.git
$ cd rpi-clone
$ sudo cp rpi-clone /usr/local/sbin/sys-clone
$ sudo cp rpi-clone-setup /usr/local/sbin/sys-clone-setup
Then I run
root@debian:~/rpi-clone# rpi-clone
Error: Could not stat device /dev/nvme0n1p - No such file or directory.
This is my problem
I can run this:
root@debian:~/rpi-clone# sudo bash -x rpi-clone sdc
++ basename rpi-clone
++ id -u
++ cat /etc/os-release
++ grep PRETTY
++ hostname
++ findmnt /boot -o source -n
++ grep /dev/
++ findmnt / -o source -n
++ grep /dev/
++ parted -m /dev/nvme0n1 unit s print
++ tr -d ';'
/dev/nvme0n1:500118192s:nvme:512:512:gpt:SAMSUNG MZVLW256HEHP-000L7:
1:2048s:1050623s:1048576s:fat32::boot, esp
2:1050624s:498116607s:497065984s:ext4::'
++ fdisk -l /dev/nvme0n1
++ grep '^/dev/'
/dev/nvme0n1p2 1050624 498116607 497065984 237G Linux filesystem'
++ df
++ grep -e '^/dev/nvme0n1' -e '^/dev/root' -e /dev/nvme0n1p2
++ tr -s ' '
/dev/nvme0n1p1 523248 5904 517344 2% /boot/efi'
++ echo '/dev/nvme0n1p2 243520884 16104488 214973364 7% /
/dev/nvme0n1p1 523248 5904 517344 2% /boot/efi'
++ sed s/root/nvme0n1p2/
/dev/nvme0n1p1 523248 5904 517344 2% /boot/efi'
++ echo 'BYT
/dev/nvme0n1:500118192s:nvme:512:512:gpt:SAMSUNG MZVLW256HEHP-000L7:
1:2048s:1050623s:1048576s:fat32::boot, esp
2:1050624s:498116607s:497065984s:ext4::'
++ tail -n 1
++ cut -d : -f 1
++ echo 'BYT
/dev/nvme0n1:500118192s:nvme:512:512:gpt:SAMSUNG MZVLW256HEHP-000L7:
1:2048s:1050623s:1048576s:fat32::boot, esp
2:1050624s:498116607s:497065984s:ext4::'
++ grep '^/dev/nvme0n1'
++ cut -d : -f 2
++ tr -d s
++ fdisk -l /dev/nvme0n1
++ grep 'Disk identifier:'
++ findmnt -o source,target -n -l
++ grep -e '^/dev/nvme0n1' -e '^/dev/nvme0n1p2'
++ tr -s ' '
/dev/nvme0n1p1 /boot/efi
/dev/nvme0n1p2[/var/log] /var/folder2ram/var/log
/dev/nvme0n1p2[/var/tmp] /var/folder2ram/var/tmp
/dev/nvme0n1p2[/var/lib/openmediavault/rrd] /var/folder2ram/var/lib/openmediavault/rrd
/dev/nvme0n1p2[/var/spool] /var/folder2ram/var/spool
/dev/nvme0n1p2[/var/lib/rrdcached] /var/folder2ram/var/lib/rrdcached
/dev/nvme0n1p2[/var/lib/monit] /var/folder2ram/var/lib/monit
/dev/nvme0n1p2[/var/cache/samba] /var/folder2ram/var/cache/samba
/dev/nvme0n1p2[/var/lib/containers/storage/overlay] /var/lib/containers/storage/overlay'
++ echo '/dev/nvme0n1p2 /
/dev/nvme0n1p1 /boot/efi
/dev/nvme0n1p2[/var/log] /var/folder2ram/var/log
/dev/nvme0n1p2[/var/tmp] /var/folder2ram/var/tmp
/dev/nvme0n1p2[/var/lib/openmediavault/rrd] /var/folder2ram/var/lib/openmediavault/rrd
/dev/nvme0n1p2[/var/spool] /var/folder2ram/var/spool
/dev/nvme0n1p2[/var/lib/rrdcached] /var/folder2ram/var/lib/rrdcached
/dev/nvme0n1p2[/var/lib/monit] /var/folder2ram/var/lib/monit
/dev/nvme0n1p2[/var/cache/samba] /var/folder2ram/var/cache/samba
/dev/nvme0n1p2[/var/lib/containers/storage/overlay] /var/lib/containers/storage/overlay'
++ wc -l
++ echo '/dev/nvme0n1p1 2048 1050623 1048576 512M EFI System
/dev/nvme0n1p2 1050624 498116607 497065984 237G Linux filesystem'
++ grep Extended
++ echo 'BYT
/dev/nvme0n1:500118192s:nvme:512:512:gpt:SAMSUNG MZVLW256HEHP-000L7:
1:2048s:1050623s:1048576s:fat32::boot, esp
2:1050624s:498116607s:497065984s:ext4::'
++ grep -e '^1:'
++ echo '1:2048s:1050623s:1048576s:fat32::boot, esp'
++ cut -d : -f 2
++ tr -d s
++ echo '1:2048s:1050623s:1048576s:fat32::boot, esp'
++ cut -d : -f 4
++ tr -d s
++ echo '1:2048s:1050623s:1048576s:fat32::boot, esp'
++ cut -d : -f 5
++ echo '/dev/nvme0n1p2 /
/dev/nvme0n1p1 /boot/efi
/dev/nvme0n1p2[/var/log] /var/folder2ram/var/log
/dev/nvme0n1p2[/var/tmp] /var/folder2ram/var/tmp
/dev/nvme0n1p2[/var/lib/openmediavault/rrd] /var/folder2ram/var/lib/openmediavault/rrd
/dev/nvme0n1p2[/var/spool] /var/folder2ram/var/spool
/dev/nvme0n1p2[/var/lib/rrdcached] /var/folder2ram/var/lib/rrdcached
/dev/nvme0n1p2[/var/lib/monit] /var/folder2ram/var/lib/monit
/dev/nvme0n1p2[/var/cache/samba] /var/folder2ram/var/cache/samba
/dev/nvme0n1p2[/var/lib/containers/storage/overlay] /var/lib/containers/storage/overlay'
++ grep -m 1 -e '^/dev/nvme0n1p1'
++ cut -d ' ' -f 2
++ echo 'BYT
/dev/nvme0n1:500118192s:nvme:512:512:gpt:SAMSUNG MZVLW256HEHP-000L7:
1:2048s:1050623s:1048576s:fat32::boot, esp
2:1050624s:498116607s:497065984s:ext4::'
++ grep -e '^2:'
++ echo 2:1050624s:498116607s:497065984s:ext4::
++ cut -d : -f 2
++ tr -d s
++ echo 2:1050624s:498116607s:497065984s:ext4::
++ cut -d : -f 4
++ tr -d s
++ echo 2:1050624s:498116607s:497065984s:ext4::
++ cut -d : -f 5
++ echo '/dev/nvme0n1p2 /
/dev/nvme0n1p1 /boot/efi
/dev/nvme0n1p2[/var/log] /var/folder2ram/var/log
/dev/nvme0n1p2[/var/tmp] /var/folder2ram/var/tmp
/dev/nvme0n1p2[/var/lib/openmediavault/rrd] /var/folder2ram/var/lib/openmediavault/rrd
/dev/nvme0n1p2[/var/spool] /var/folder2ram/var/spool
/dev/nvme0n1p2[/var/lib/rrdcached] /var/folder2ram/var/lib/rrdcached
/dev/nvme0n1p2[/var/lib/monit] /var/folder2ram/var/lib/monit
/dev/nvme0n1p2[/var/cache/samba] /var/folder2ram/var/cache/samba
/dev/nvme0n1p2[/var/lib/containers/storage/overlay] /var/lib/containers/storage/overlay'
++ grep -m 1 -e '^/dev/nvme0n1p2'
++ cut -d ' ' -f 2
++ e2label /dev/nvme0n1p2
++ expr substr sdc 1 5
++ echo '/dev/nvme0n1p2 243520884 16104488 214973364 7% /
/dev/nvme0n1p1 523248 5904 517344 2% /boot/efi'
++ grep -m 1 '^/dev/nvme0n1p1'
++ cut -d ' ' -f 3
++ echo '/dev/nvme0n1p2 243520884 16104488 214973364 7% /
/dev/nvme0n1p1 523248 5904 517344 2% /boot/efi'
++ grep -m 1 '^/dev/nvme0n1p2'
++ cut -d ' ' -f 3
++ cat /proc/partitions
++ grep -m 1 sdc
++ parted -m /dev/sdc unit s print
++ tr -d ';'
Error: Invalid argument during seek for read on /dev/sdc
Please delete the bash debug output in your previous comment and attach the contents in a file 😉
Anyhow I was just able to create a clone of my CM4 from NVMe to an USB flash drive.
That's the code I use (It's the PR from @geerlingguy merged into my fork of rpi-clone):
Please use this code and try again.
I figured out why this wasn't working and how to make it work.
A newly formatted microsd card won't work because it doesn't have partitions and file systems.
I tried using the rpi-clone command with -f and -f2 and -p 256M but that didn't work.
If the microsd card doesn't have file systems, the rpi-clone tries to dd convert and copy the entire
nvme card (128G) onto the 16G microsd card. It won't work.
To make this work I had to create two partitions on the microsd card and then create file systems on them.
Here is the procedure I used:
Using gdisk, Print the partitions and delete them if there are any.
Using gdisk, Create new partitions 1 (size 256M) and 2 (8G) and write the change to the sd card.
Using mkfs, Create new file systems on partitions 1 (FAT16) and 2 (EXT4). See captured printout below.
Create backup of nvme drive with sudo ./rpi-clone sda
Use the new PR change mentioned above. git clone https://github.com/framps/rpi-clone.git
Example of how to print and delete partitions, using gdisk.
Example of sudo ./rpi-clone that failed becasue microsd card had no file systems created.