I have Hassbian installation on pi3b+.
First, created a backup on a larger flash drive. Then used Etcher on PC to flash it to the SSD.
To create a backup I followed these: https://pimylifeup.com/backup-raspberry-pi/
https://superuser.com/questions/1097210/clone-only-space-in-use-from-hard-disk
My steps:
- Flash Hassbian on a new ssd using Etcher and boot rPI from it.
- Mount your SSD and old SD card on rPI. Use an External Hard Drive Enclosure and a USB card reader, these commands are useful:
dmesg - system log about drives, you need to find your flash drive.
lsusb
sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL
sudo blkid
E.g. sda1 is your SSD.
sudo mkdir /mnt/bak
sudo mount /dev/sda1 /mnt/bak
ls /mnt/PIHDD
- Create the backup. Be careful with disks’ and partitions’ names! Yours may be different, and I may have a mistake here.
E.g. mmcblk0 is your old SD card
sudo mkdir /mnt/bak/ha_backup
cd /mnt/bak/ha_backup
sudo dd if=/dev/mmcblk0 of=backup.img bs=64K conv=noerror,sync status=progress
- If you plan to flash on the PC then dismount the backup disk now. If on rPI - then after the flashing.
lsof /mnt/bak - check that it is not used.
sudo rmdir /mnt/bak
- Flash the image from the flash drive to SSD using Etcher on a PC. You can also restore the backup right on the rPI (do step 4 later then):
sudo dd if=/mnt/bak/ha_backup/backup.img of=/dev/mmcblk1 bs=64K
- Plug SSD to rPI and check its health. You may need to reset the readonly bit if SD card was not functional. Options depend on the file system.
sudo fsck -v -p /dev/sda1
- Turn off rPI. Remove new SD card and unplug USB card reader from rPI. Only plug the SSD and boot from it.