Move bookworm system from SSD to NVME

Jul 31, 2024 Last reply: 1 year ago 55 Replies

Apropos of not too much, I finally got around to copying my old 120GB Pi boot disk to an image file, and splatting that back onto a 2TB SSD that now has according to a GUI based disk editor shitloads of 'unused' space.

(The reason I didnt do it directly was on account of a lack of functional and accessible USB slots in the computer I used.)

All looks ok, with a bootfs and a rootfs partition on it, but I haven't actually booted it yet.

I didn't sync it, I went to the supermarket instead, and left it running, and then left it running on the second transfer while I had the evening meal.

It appears to be OK

More later... I overslept badly and it may be Monday before more gets done.

Tried to reboot the thing and it failed, although it managed to get as far as system maintenance mode.

Using that mode I then removed all the disks no longer attached, from fstab, and its now at a normal login prompt!

Next step was to partition the spare space and reattach the second drive

So dd et al work perfectly as far as I can tell. when applied to the raw disk

I don't know why it barfed on having disks mentioned in fstab that didn't exist (yet) but it is another thing to be aware of when migrating a system

T’was ever thus. Without the “nofail” mount option, the system assumes the volume absolutely has to be present for a successful boot.

Now I have the nvme installed and showing in a lsblk command. Booted from a SD-card and did a few tries to copy the system from SSD to nvme. First there was a complaint about the switch "1m". Changed it to "1b" and got a complaint about missing permission to open SDA (the SSD I want to copy from). Threw a sudo at it, and it ran for maybe half an hour, until it stopped with error "writing nvme0n1, No space left on device". The SSD and the nvme have the same size, and that seems to be a problem. Bright ideas are welcome :-)

Below I have copied in what happend in the command line: raspberrypi@raspberrypi:~ $ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 238.5G 0 disk ├─sda1 8:1 0 512M 0 part /media/raspberrypi/bootfs └─sda2 8:2 0 238G 0 part /media/raspberrypi/rootfs mmcblk0 179:0 0 58G 0 disk ├─mmcblk0p1 179:1 0 512M 0 part /boot/firmware └─mmcblk0p2 179:2 0 57.5G 0 part / nvme0n1 259:0 0 238.5G 0 disk raspberrypi@raspberrypi:~ $ dd if=/dev/sda of=/nvme0n1 bs=1m dd: invalid number: ‘1m’ raspberrypi@raspberrypi:~ $ dd if=/dev/sda of=/nvme0n1 bs=1b dd: failed to open '/dev/sda': Permission denied raspberrypi@raspberrypi:~ $ dd if=/dev/sda of=/nvme0n1 dd: failed to open '/dev/sda': Permission denied raspberrypi@raspberrypi:~ $ sudo dd if=/dev/sda of=/nvme0n1 bs=1b dd: error writing '/nvme0n1': No space left on device

107929249+0 records in 107929248+0 records out 55259774976 bytes (55 GB, 51 GiB) copied, 1476.65 s, 37.4 MB/s raspberrypi@raspberrypi:~

Best regards

WTF is '/nvme0n1' ?

It looks like you have created a file in the root directory of the device you are copying from....

Thank you for the reply.

"nvme0n1" is the "f****ng" NVME I have installed in the raspi5.

I see no trace of the new file you are referring to.

Best regards

>

Not as far as dd is concerned. What does the outpout of ls /n* and ls /dev/n* show?

Somehow that does not surprise me

raspberrypi@raspberrypi:~ $ ls /n* ls: klarte ikke å åpne '/n*': Ingen slik fil eller filkatalog It means "Could not open /n*. No such file or catalog"

raspberrypi@raspberrypi:~ $ ls /dev/n* /dev/ng0n1 /dev/null /dev/nvme0 /dev/nvme0n1

/dev/net: tun raspberrypi@raspberrypi:~ $

Should the nvme have been formatted before the copying? I did not do that because the two partitions on the SSD have different formatting, one is vfat (boot), the other ext4

Best regards

does this give you any clues: raspberrypi@raspberrypi:~ $ ls -l /dev/disk/by-uuid totalt 0 lrwxrwxrwx 1 root root 10 aug. 16 13:53 cb6f0e18-5add-4177-ab98-e9f0235e06b3 -> ../../sda2 lrwxrwxrwx 1 root root 10 aug. 16 13:53 D3E6-3F09 -> ../../sda1 lrwxrwxrwx 1 root root 10 aug. 16 13:53 F40B-6C7F -> ../../sdb1 raspberrypi@raspberrypi:~ $

Your command is missing a /dev it should be:

sudo dd if=/dev/sda of=/dev/nvme0n1 bs=1b _______________________^^^^^

The "no space on device" error comes because without the /dev dd is attempting to write a file called nvme0n1 in / but since / runs out of space before it finishes the file is never closed and thus no directory entry is written which is why yuou never see it.

Also I don't think bs=1b is likely to be a good blocksize (1 byte). If the version of dd you're using doesn't support bs=1m then try bs=1024k or be=1048576. The idea is to get it to use the largest block size (and thus writes) that the data path will support.

So there is no '/nvme0n1' to copy to is there? IT ISN'T your NVM.

Right. so the draw device ce is /dev/nvme0

So try

sudo dd if=/dev/sda of=/dev/nvme0 bs=1M

Note: /dev/nvme0 NOT /nvme0n1

1M not 1m.

No. Again 2 things wroing.

/dev/nvme0 is the RAW device.

bs=1M is correct for decent transfer rate

bs=1M is sensible.

1Mib.

No, it did not like the 'nvmeO'. Here is what it said: raspberrypi@raspberrypi:~ $ sudo dd if=/dev/sda of=/dev/nvme0 dd: skriver til '/dev/nvme0': Ugyldig argument

1+0 records in 0+0 records out 0 bytes copied, 0,000298314 s, 0,0 kB/s 'Ugyldig argument' is norwegian for 'illegal argument. But I managed at last to make the copy like this: raspberrypi@raspberrypi:~ $ sudo dd if=/dev/sda of=/dev/nvme0n1 500118192+0 records in 500118192+0 records out 256060514304 bytes (256 GB, 238 GiB) copied, 2157,41 s, 119 MB/s raspberrypi@raspberrypi:~ $

After that I shut down the raspi, removed SD-card and SSD. Applied power, and it booted from the nvme, and I am running on that while writing this.

Thanks for all patient help from you all :-)

Best regards

Arrh, that's asking to copy a single 512 byte block at a time - horribly in efficient. Try "1M" to copy in 1 MiB chunks.

Yes you need root permission to write to block devices, given how easy it is to destroy the filing system on them with an even a slightly incorrect command.

But are they? Just like with SD cards, no two models are exactly the same size. If it is even a block less dd will complain, check the sizes using:-

sudo fdisk -l

If it is smaller it can be fixed using the gparted program. Calculate the size difference in bytes and divide down to MB, then run gparted and go to source disc (/dev/sda) and resize the last partition (rootfs) to be X+1 MB smaller. Finish by apply the changes.

You can then do the dd copy again, it will still give the error, but the copy will be good as it is now only empty space which wont have been copied over.

You might be asking why don't you just use gparted on the destination disk which already has everything on it, and shrink the last partition on that. The answer is it wont like doing anything to a disc where the partition table says the partition falls off the end of the disc. It is possible to fix that, but it's easier to do it the way I've said above, and it avoids any possibility of corrupting files.

---druck

This is why rsync is so much easier.

It isn't, but my original post in this thread gave full instructions on how to do that too.

---druck

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required