Best practice moving from sd-card to ssd raspberry

I am running Hassio on a Raspberry pi 3B.
Now I want to move from sd-card to ssd
I want to keep as much settings as possible, now i wonder what is the best method :

  1. Install new version and restore snaphot
  2. make image of sd card and put it on ssd with etcher (ssd = larger than sd)
  3. Fresh install and copy config- folder from backup

I could try every method myself, but because copying takes lots of time I would like to hear from others who did this before.

Thanks in advance

4 Likes

As far as I know this was only possible with the previous Resin os and not yet possible with HASSOS

I tried 1) once. The full snapshot didnā€™t restore all the files and I had to keep restoring the snapshot to get it partially working. Not everything was working so I moved to 2)

I had two same size SD cards, but made by different manufacturers. I wasnā€™t able to re-image the card and eventually moved to 3)

Basically I did a full install from scratch and used my old config files. Still had to re-authorize a few components but it worked, just took several hours to complete.

I hope you have better luck than me.

Thank you for your answers. I try a fresh install.
I wrote most recent image to the ssd, but first install fails. Error says :retry count exceeded;starting again and after that nothing happens.
Reason can be a bad ssd, but i will try to install an older version first.

With the SD card issues, it would be nice to use an SSD.

I use a ssd for several weeks now with hass.io
Works fine for me.
When copying image file with Etcher you have you have to check ā€œUnsafe modeā€ in settings.

At first I did not do that resulting in errors at first boot on my RPI

3 Likes

Is there anything else to it? Do you just plug an SSD with USB into one of the USB ports on the Raspberry Pi and your off to the races? Said another way, is there any kind of setup or configuration required to tell the raspberry pi to use the SSD?

Also, what are you using for an SSD?

I use X850 mSATA SSD storage expansion board and a Vaseky V800 Mini 1.8 inch MSATA Solid State Drive.

Here you can read how to change your configuration https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md
To change this I first booted from a sd-card with jessie-lite so I could change boot-mode

3 Likes

Today I wanted to do a fresh install of Home-Assistant. I did not succeed :frowning:

So now I first installed Raspbian Lite and did a manual installation of home-assistant as described here : https://www.home-assistant.io/docs/installation/raspberry-pi/

So I if you did not succeed yet you could try this route.

My SD card died a week ago. rPi stopped booting.
I bought a new SD card and tried to reinstall everything, but realized that it is too hard.
The old SD card was not readable from the PC. But it was from rPi. It just was in a read-only mode. This is how they die.

I created a backup and restored it on 128Gb SSD. Then ran sudo fsck -v -p /dev/sda1 and it found and reset the dirty bit on the sda1 partition. sda2 partition was fine.
Then it booted from SSD without a problem. HA UI works much faster. History and Logbook load in less than one second. Home, map and cameras appear immediately.

Write speed:

$ dd if=/dev/zero of=/tmp/test1.img bs=300M count=1 oflag=dsync
1+0 records in
1+0 records out
314572800 bytes (315 MB, 300 MiB) copied, 9.20859 s, 34.2 MB/s

Latency:

$ dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync
1000+0 records in
1000+0 records out
512000 bytes (512 kB, 500 KiB) copied, 2.48363 s, 206 kB/s

So, if your SD card died and you do not have a backup, you may still be able to restore your installation.
I would recommend to switch to a cheap SSD.

3 Likes

Running home-assistant on docker on Synology Nas now. Works great.

1 Like

Hi, could you let me know how you restored backup to ssd?
IĖ‡ve tried connect my ssd to rpi usb slot but rpi did not find it :frowning:
Shall I do any additional settings?

1 Like

Honestly the best way (not the fastest) is to do a fresh install and copy the files that you need back 1 by 1 and add all the components, sensors etc back from scratch. Because HA gets updated very very frequently there is a lot of unused files that remain etc (or corrupt files etc). I have had many problems fixed just because of a fresh install.

I know it is not the fastest, but you asked for the best way. I sincerely believe that this is the best way. As is with computers and phones. Installing Windows from scratch is always better than to restore a backup.

But then again it is totally up to you. If I were you Iā€™d take a friday or saturday and work through this. I have a pretty large setup and it takes me about 2 evenings to get a fresh install going. This will take considerably less time on smaller setups.

2 Likes

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:

  1. Flash Hassbian on a new ssd using Etcher and boot rPI from it.
  2. 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
  1. 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
  1. 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
  1. 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
  1. 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
  1. Turn off rPI. Remove new SD card and unplug USB card reader from rPI. Only plug the SSD and boot from it.
2 Likes

mgluk, you did this with a USB ssd, or an ssd with an x850 expansion board?

I am looking to do the same just need to know what parts I need to experiment with.

bumpā€¦

I have done some more research and it seems on my pi3b+ this should work as expected. My understanding is that setting the boot bit is only necessary on the non-"+" models. Flashing a bootable image with etcher should just work like an sdā€¦ i hope.

Iā€™m about to pull the trigger on a startech usb3-sata3 adapter and a kingston 120gb ssd for this. Any advice/pointers are welcome.

I updated my previous post. I used SanDisk SSD Plus 120GB SSD.

With hassos, hasbian, or other? From what Iā€™ve been reading, it seems this may not actually work for me as Iā€™m running hassos. Iā€™ve seen there is a usb boot compatible image of hassos here, and that may be the closest method to what I was after thus far:

Iā€™m still unclear on the differences between running raspbian+hassio as outlined in this thread:

ā€¦versus just using that usb bootable image instead. Either way, I have to learn how to transfer my configuration to the new system.

I do not think it matters whether you have HASSIO or Hassbian. You just need to boot from something to run my steps. You also can use a different method to create a backup, e.g. on a PC. But anyway you need to fix a file system corruption on the restored image.

mgluk, I may well not understand it correctly. I have read a lot of info about how hassos cannot be made usb bootableā€¦ devs only intend to allow moving the database to ssdā€¦ etc. All the tutā€™s on installing hassio on ssd seem to make use of either resin-os or hassbian, then you install docker, then install hassio in docker (or something like that?). Some folks use scripts to do it, some do it manually.

Iā€™m not sure on how that goes as Iā€™ve never done it that way; my previous instance was just a hassio (hassos based) image for rpi flashed on an sdcardā€¦ plug it in, turn it on, and lovelace pops up to guide you throughā€¦ no terminal commands to install docker, hassio, etc. OS updates are done through the gui (vs having to ssh in to use apt-getā€¦ or making a cron job, etc). This is the ā€˜noobā€™ level system Iā€™m talking about.

Well, it works! Iā€™ve got hassos running on my pi3b+ with no sd card: