Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #123: Errors with NVMe on Compute Module 4. #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

geerlingguy
Copy link

Fixes #123. Allows users to work with NVMe drives on the CM4.

Copy link

@mike-pisman mike-pisman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you!

@@ -573,7 +573,7 @@ get_src_disk()
partition=${1#/dev/}
disk=${partition:: -1}
num="${partition: -1}"
if [[ $disk == *"mmcblk"* ]]
if [[ $disk == *"mmcblk"* || $disk == *"nvme"* ]]
then
SD_slot_boot=1
disk=${disk:0:7}
Copy link

@framps framps Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment: I first thought this line will fail for nvme but it works fine 👍 . It works for nvme only as long as for /dev/nvme<x>n<y> x and y has only one digit. But that's a restriction also on the previous code which extracts the partition number.

@geerlingguy
Copy link
Author

Testing it on one of my Pis with eMMC boot and an NVMe drive:

pi@dvr:~/rpi-clone $ lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0      179:0    0 14.6G  0 disk 
├─mmcblk0p1  179:1    0  256M  0 part /boot
└─mmcblk0p2  179:2    0 14.3G  0 part /
mmcblk0boot0 179:32   0    4M  1 disk 
mmcblk0boot1 179:64   0    4M  1 disk 
nvme0n1      259:0    0  7.3T  0 disk 
├─nvme0n1p1  259:1    0  600M  0 part 
├─nvme0n1p2  259:2    0    1G  0 part 
└─nvme0n1p3  259:3    0  7.3T  0 part 

pi@dvr:~/rpi-clone $ sudo rpi-clone nvme0n1
Error: /dev/nvme0n1: unrecognised disk label

Booted disk: mmcblk0 15.6GB                Destination disk: nvme0n1 8.0TB
---------------------------------------------------------------------------
Part      Size    FS     Label           Part   Size  FS  Label  
1 /boot   256.0M  fat32  --                                      
2 root     14.3G  ext4   rootfs                                  
---------------------------------------------------------------------------
== Initialize: IMAGE partition table - partition number mismatch: 2 -> 0 ==
1 /boot               (31.5M used)   : MKFS  SYNC to nvme0n1p1
2 root                (1.4G used)    : RESIZE  MKFS  SYNC to nvme0n1p2
---------------------------------------------------------------------------
Run setup script       : no.
Verbose mode           : no.
-----------------------:
** WARNING **          : All destination disk nvme0n1 data will be overwritten!
-----------------------:

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

Initializing
  Imaging past partition 1 start.
  => dd if=/dev/mmcblk0 of=/dev/nvme0n1 bs=1M count=8 ...
  Resizing destination disk last partition ...
    Resize success.
  Changing destination Disk ID ...The size of this disk is 7.3 TiB (8001563222016 bytes). DOS partition table format cannot be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).

  => mkfs -t vfat -F 32  /dev/nvme0n1p1 ...
  => mkfs -t ext4  /dev/nvme0n1p2 ...

Syncing file systems (can take a long time)
Syncing mounted partitions:
  Mounting /dev/nvme0n1p2 on /mnt/clone
  => rsync // /mnt/clone with-root-excludes ...
  Mounting /dev/nvme0n1p1 on /mnt/clone/boot
  => rsync /boot/ /mnt/clone/boot  ...

Editing /mnt/clone/boot/cmdline.txt PARTUUID to use db6793cc
Editing /mnt/clone/etc/fstab PARTUUID to use db6793cc
===============================
Done with clone to /dev/nvme0n1
   Start - 16:36:11    End - 16:36:54    Elapsed Time - 0:43

Cloned partitions are mounted on /mnt/clone for inspection or customizing. 

Hit Enter when ready to unmount the /dev/nvme0n1 partitions ...
  unmounting /mnt/clone/boot
  unmounting /mnt/clone
===============================

pi@dvr:~/rpi-clone $ lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0      179:0    0 14.6G  0 disk 
├─mmcblk0p1  179:1    0  256M  0 part /boot
└─mmcblk0p2  179:2    0 14.3G  0 part /
mmcblk0boot0 179:32   0    4M  1 disk 
mmcblk0boot1 179:64   0    4M  1 disk 
nvme0n1      259:0    0  7.3T  0 disk 
├─nvme0n1p1  259:1    0  256M  0 part 
└─nvme0n1p2  259:2    0    2T  0 part 

Note that I was testing with an 8 TB NVMe drive, and it was only sized to 2 TB...

@framps
Copy link

framps commented Oct 12, 2022

I just tested the PR on my CM4 with the 04-04 lite image. Boot from the cloned nvme works perfect 👍

Unfortunately my CM4 doesn't boot any more from nvme with later images. I created an issue on this.

@notenoughtech
Copy link

notenoughtech commented Oct 27, 2022

I'm trying this on CM4 with eMMC storage and /dev/nvme0n1 and it fails despite the manual changes made to the rpi-clone file. I changed the 576 and 1060 line with the same OR condition, but without much luck. Pointers appreciated

pi@ant1:~ $ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT mmcblk0 179:0 0 29.1G 0 disk ├─mmcblk0p1 179:1 0 256M 0 part /boot └─mmcblk0p2 179:2 0 28.9G 0 part / mmcblk0boot0 179:32 0 4M 1 disk mmcblk0boot1 179:64 0 4M 1 disk nvme0n1 259:0 0 232.9G 0 disk ├─nvme0n1p1 259:1 0 256M 0 part └─nvme0n1p2 259:2 0 232.6G 0 part

Syncing file systems (can take a long time) Syncing mounted partitions: Mounting /dev/nvme0n12 on /mnt/clone mount: /mnt/clone: special device /dev/nvme0n12 does not exist. Mount failure of /dev/nvme0n12 on /mnt/clone. Aborting!

@framps
Copy link

framps commented Oct 27, 2022

I changed the 576 and 1060 line with the same OR condition,

Why didn't you grab the file from @geerlingguy s PR instead of updating the file? I suggest to compare your modified rpi-clone version with the one in the PR or grab the file from the PR and test again. Just to make sure you use the PR code 😉 .

I have exactly the same config other than a smaller NVMe disk and it works for me.

pi@raspberrypi:~ $ lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
mmcblk0      179:0    0  29.1G  0 disk 
|-mmcblk0p1  179:1    0   256M  0 part 
`-mmcblk0p2  179:2    0  28.9G  0 part 
mmcblk0boot0 179:32   0     4M  1 disk 
mmcblk0boot1 179:64   0     4M  1 disk 
nvme0n1      259:0    0 119.2G  0 disk 
|-nvme0n1p1  259:1    0   256M  0 part /boot
`-nvme0n1p2  259:2    0   119G  0 part /

@notenoughtech
Copy link

Why didn't you grab the file from @geerlingguy s PR instead of updating the file? I suggest to compare your modified rpi-clone version with the one in the PR or grab the file from the PR and test again. Just to make sure you use the PR code 😉 .

Both methods the file from PR and manually editing the script produce the same error.

@framps
Copy link

framps commented Oct 28, 2022

😢 Well, then a bash debug log may help. Just invoke the script with sudo bash -x rpi-clone <your args> and attach the debug log.

@notenoughtech
Copy link

Plot thickens:
CM4 Lite 4GB RAM + WiFi = clone successful
CM4 4GB RAM + eMMC + WiFi = clone fails. I'll get the logs in a sec

@framps
Copy link

framps commented Oct 28, 2022

attach the debug log

I suggest to invoke the script command first, then lsblk then invoke sudo bash -x rpi-clone nvme0n1 and finally exit. You now have created a file transcript which is the debug log I'm asking for.

@notenoughtech
Copy link

Right, I'm even more confused.
sudo bash -x rpi-clone -l nvme0n1 works on both types of CM4 modules, while
sudo rpi-clone -l nvme0n1 did not work. Getting late so I'll collect the logs tomorrow and share my findings.

@framps
Copy link

framps commented Nov 2, 2022

Right, I'm even more confused.

@notenoughtech Any updates on your issue?

@notenoughtech
Copy link

notenoughtech commented Nov 3, 2022

Hi, @framps
I'm sorry for the late response. Here is the log as requested:

@notenoughtech
Copy link

notenoughtech commented Nov 3, 2022

Right.
Even more confused now as this all worked well and I finally have the boot from NVMe.
log.txt

@framps
Copy link

framps commented Nov 3, 2022

Oh good 😳 ... you can attach a file in a comment - just use drag and drop 😉

Please clean up your huge comment ... nobody will ever read this 😢

@framps
Copy link

framps commented Nov 3, 2022

all worked well

So there is no need any more for the debug log 😄

@notenoughtech
Copy link

I thought the code would auto collapse or something. I cleaned it up. Now let's see if this works with non eMMC CM4s

@notenoughtech
Copy link

No matter how many times I try, the CM4 Lite is not liking the boot from nvme. rpi-clone worked on CM4 and change of boot from eMMC to NVMe was easy enough. Same EEPROM firmware on CM4 Lite and boot sequence on CM4 Lite and no dice after rpi-clone.
While cloning appears to be working, I don't think the boot partition is able to boot. Without SD card it hangs but hot swapping sd card, proves that boot sequence is working as the CM4 Lite boots from card a moment later without a reboot.

Anyone had this much problems?

I can also confirm that I still have the issue of sudo rpi-clone -l nvme0n1 not working while sudo bash -x rpi-clone nvme0n1 works fine

@framps
Copy link

framps commented Nov 4, 2022

I don't have a CM4 lite to test rpi-clone in this environment.

Not sure why you actually use rpi-clone. If you just clone the SD card image to NVMe to be able to boot from NVMe why don't you install the OS directly on NVMe instead to the SD card first and then clone the SD to NVMe? See this page how I install RaspbianOS directly on NVMe.

@notenoughtech
Copy link

notenoughtech commented Nov 4, 2022 via email

@framps
Copy link

framps commented Nov 4, 2022

What I don't understand why executing rpi-clone via bash works on CM4 but failed when same file runs from the command line.

This requires further debugging I'm not able to assist. @billw2 may be able to help. But given his last commit is 2.5 years ago I doubt he will.

@geerlingguy
Copy link
Author

This patch is now maintained in my fork: https://github.com/geerlingguy/rpi-clone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error with NVME on RPi Compute Module 4
4 participants