Hi,
Few days ago I ran into malfunction of my home-assistant setup on a Raspberry PI 3running from SD Card. A decent Samsung EVO U1 16GB card that is. Playing with some configuration changes, it all worked with restarting Home Assistant via sudo systemctl restart home-assistant.service
, but all changes were gone after a sudo shutdown -r now
. Puzzled me for a while, until I realized my SD card was the issue. It had become read-only, but apart from that everythig still seemed to work with changes to the filesystem being stored in the journal in memory, but never being written onto the SD card.
I knew SD cards will fail someday from previous experience, so I had backups of all configuration files. But I did not really feel for re-installing from scratch and I wanted the next install to run from USB. This is what I did, maybe somebody is helped with this:
I tried to follow instructions from here https://github.com/raspberrypi/documentation/blob/master/hardware/raspberrypi/bootmodes/msd.md .
First problem, as I could not write onto the original SD card was to program USB bootmode. I used an SC card from another PI so tackle this.
Preparing the USB stick (also a 16 GB one) all went well, but problem two was that copying all files with rsync
did not fly on a running system. Even stopping all services as much as possible still left me with rsync errors. So I decided to just try to copy the whole card image to the USB stick. Put the SD card in a USB adapter, connect to a linux PC and copy the image from the SD card to the harddisk.
Then problem 3 arose: my USB stick was a few MB smaller than the SD card, so I could not put the image on the USB stick. Solved this by using a larger USB stick, okay for proof of concept but not teh USB stick I wanted to use. After following the remaining instructions I got my system working again, albeit rather slow.
But I still wanted it on the other (almost 16 GB) USB stick. Using gparted I made the ext4 partition a bit smaller, hoping I could then do an image transfer, but this failed for the same reason as above. So I reverted to gparted to copy the two partitions one by one, a slow process with 2 USB sticks in the PC copying over a USB2.0 connection, but it worked. I extended the ext4 partition again to fill the whole USB stick, and everything still worked. But slow.
Final step was then to speed up. Some more internet search revealed the sync option is better not used, as it leads to large / frequent writes. And I’m not planning to remove the USB stick anyhow. It was suggested to modify this in the /etc/usbmount/usbmount.conf
but there is no such file on my PI 3. So I decided to add the async
option in the \etc\fstab\
file for the ect4 partition, which seems to do the trick.
So now my system is up and running again from a USB stick, not noticeably slower or faster than it was from SD card. From now on, I will not only make backups of the configuration files, but also a regular image backup for fast reinstall as the above took me a couple of days…