Migrating Raspberry Pi OS from micro SD card to SSD with existing partitions

Moving the installation of your Raspberry Pi from the micro SD card to an external SSD can boost performance.

In case the SSD  planned to move the installation to already has data which should be kept, the following steps can be followed.

Create partitions for RPi on the SSD

All the following partition operations can be done inGParted.

First, two partitions corresponding to the micro SD card need to be created on the SSD: bootfs and rootfs. If necessary the existing partition on the SSD should be resized on the left side to allow for the new partitions. The size of these two partitions should be the same as those on the micro SD card.

Clone micro SD partitions into the two partitions on SSD

The following commands can be used to clone the partitions:

sudo dd bs=512M  if=/dev/your_microSD_boot_partition of=/dev/your_ssd_boot_partition
sudo dd bs=512M  if=/dev/your_microSD_root_partition of=/dev/your_ssd_root_partition

The cloned partitions should be checked in GParted to check no errors are given.

UUID settings

Partition UUIDs  need to be adjusted to point to these on the SSD. This includes two parts: /cmdline.txt in bootfs

and /etc/fstab in rootfs. They can be changed by mounting partitions on another Linux machine.

How to check partition PARTUUID and UUID

The PARTUUID and UUID of a partition can be checked by the blow command:

sudo blkid /dev/partition_to_check

cmdline.txt in bootfs partition

Change xxxxxxxx below to the PARTUUID of rootfs partition on the SSD.

root=PARTUUID=xxxxxxxx

/etc/fstab in rootfs partition

Change yyyyyyyy below to the UUID of bootfs partition on the SSD.

Change zzzzzzzz below to the UUID of rootfs partition on the SSD.

proc            /proc           proc    defaults          0       0
UUID=yyyyyyyy /boot/firmware  vfat    defaults          0       2
UUID=zzzzzzzz /               ext4    defaults,noatime  0       1

Now, plug your SSD to the Raspberry Pi without your micro SD card plugged. Start the RPi and enjoy!