File system too easy to become corrupted

It seemed the file system can easily be corrupted as it is not backed by modern file system such as EXT4?

It seemed to be FAT16 from what I can tell.

I’m currently running my setup on Raspberry Pi 3 B+ which doesn’t has a hardware power off button, I used to run a few other projects and disconnecting the device form power source without shutting the system down won’t do me any harm as long as there aren’t any ongoing file operation and the file system is mounted with “sync” flag.

Is there anything I can do to make the file system more robust?

I intended to use the setup as a portable smart home system when I travel.

Pretty sure hassio is based on ext3 or ext4. (Except the boot partition of course).

I think the filesystem is marked with dirty bit and no longer mount.

The boot log says it cannot mount data partition.

Put it in a computer and fix it then :slight_smile:

2 Likes

go to configuration in the GUI and stop HA before disconnecting power to the RPi.

1 Like

Using the sync flag seems like an ugly bandaid to cover for the practice of pulling the plug on a working computer.

Sync means every write is immediately flushed to disk. So there’s a performance penalty plus high write frequency to an SD card. That’s a lot of negatives for daily operation, just to compensate for yanking the power cord.

My two RPi’s are protected by UPS and I still refrain from unceremoniously cutting power to them. I do an orderly shutdown first, then cut power.

I have an OpenWRT travel router and I don’t believe it is an uncommon practice?

I think all embedded OS has more or less protection against power loss? When is the last time you shut down your home router before unplug it?

You’re always at risk of corrupting your sd-card If you just pull the power and it will eventually bite you.

1 Like

Your comparing a ‘travel router’ to an RPi configured for Home Assistant?

One loads its entire OS (firmware) into RAM each time it starts and configures it as read-only. The other doesn’t.

Guess which one?

One stores its configuration in non-volatile memory. The other one doesn’t.

Guess which one?

The fact is some devices are designed to be ‘appliances’ that can have the rug pulled out from under them and still land on their feet. An RPi running Home Assistant is not one of these appliances.


EDIT
In the realm of home automation, my first encounter with devices that load their OS into RAM (and can survive having their plug pulled) was about 14 years ago while hacking a Compaq IA-1 and a 3COM Audrey. Several Audreys became front-ends for my home automation system.

1 Like

My OpenWRT router has an external storage mounted and shared via Samba.

I believe there are chances of data loss, but I’m not expected completely corrupted file system.

But you’re right, it seemed Raspberry Pi is not designed to be unplugged without properly shutdown, I should find a way to easily shutdown the device before disconnecting the power, maybe soldering a switch to its GPIOs.

running

sudo halt

will work.

1 Like

And the configuration info that tells the router to establish that connection upon startup is safely tucked away in NVRAM. So the only exposure to data-corruption is if a file-write is in progress, to external storage, when the power goes out.

As a rule of thumb, cutting power to any general-purpose computer, without the benefit of an orderly shutdown, is inadvisable.

If you google it, you’ll find several tutorials to make a shutdown button (need a small pushbutton, access to GPIO pins, and some scripts). Here’s one that allows the button to perform either a restart or a shutdown:

1 Like

Plenty of stories in the forums with others who thought the same but anyway…

Just from the ssh addon do a hassio ha stop

Funny, calling the hassio.host_shutdown from a script does shutdown the home-assistant, but the OS itself is still alive, I can still ping the IP address.

Edit:

It seemed sth stuck the shutdown process, after 10 minutes the system is properly shutdown

So year 2023 Homeassistant yellow is offering a blue button in the back of the device that will shutdown the system if you long press it for 5 seconds.