Categories
Home Assistant Project

Running Home Assistant Off An External Drive

In this post I go over how to move Homeassistants data folder on to an external drive to help increase the longevity of our Pi’s SD card.

Why an External Drive?

The Raspberry Pi is a great piece of tech and it comes at a great price. The down side of being as cheap as possible is the fact that there is no on board memory, so the Pi utilizes SD cards for the OS. SD cards are pretty cheap nowadays, but do not like being written too very often. When SD cards are written on too much, the flash wears out until the card become corrupted and/or unusable. Home Assistant uses a database to store all events that occur so you have a record of everything that has happened in your home, which is great, but tends to cause many writes to occur on the SD card. To get around this, we can move all of the settings, databases, and other file off of the SD card and put them on an external drive. These steps will also help in the future when we want to start adding addition docker containers that might also do lots of writing.

Step 1: Where are the current files?

If you followed my tutorial on how to install Hass.io using docker, then these steps will apply to you. We need to take a look into what the installer script actually did so we can figure out how to change it. The installer script is meant to be generic and function for many different platforms, which causes the script to be rather long and hard to read, but around the middle, we see the creation of a JSON file containing three elements that are of interest to us:

The data element is the piece we are interested in, as that will be the location that the docker image will be looking for. Searching the script for the values of the variables above, we find the following:

The JSON file itself can be found at “/etc/hassio.json” and the Data folder can be found at “/usr/share/hassio”. Now that we have the location of both the current data folder and the config to change it, we can move on.

Step 2: Moving Existing Data to the External drive

In a previous post, I went over how to mount an external drive to the Pi and create a filesystem on it. Now we want to take advantage of the increased storage capacity and longevity of the drive. The first thing we want to do is move the current data folder to the external drive. I used the “cp” command to make a duplicate of this folder, making sure to be at the root directory first:

cd ../..
sudo cp -r /usr/share/hassio /mnt/hassio

This command copies the data folder and puts it into a folder called “hassio” onto the hassio mount point that I created for the disk in the previous post. If you mounted the disk to another location, just change the folder name. Note: This just makes a copy of the current state of the folder, the existing one will still exists if you make a mistake and need to go back.

Step 3: Changing Config to New Location

Finally, we want to edit the JSON file we saw earlier to point to the new location we just made. We can once again use “nano” to edit this file in the command line:

sudo nano etc/hassio.json

Inside the file, we can edit the “data” parameter to match the new location we created earlier.

Save and exit. To check if our changes took effect, we need to reboot the Pi:

sudo reboot

Step 4: Verify the changes

Once the Pi comes back online, we want to verify that Hass.io is using the new location. This can be done by verifying the files are being updated on the external drive. Let the system run for a few minutes to ensure the database was written to recently and run this command:

sudo ls -l /mnt/hassio/hassio/homeassistant

Once again making sure the path matches your setup, you should see somthing similar:

The two files that should be updated are the “home-assistant.log” and “home-assistant_v2.db”. Either of these files should be within a couple minutes of your current time. To make even further sure that its correct, wait a few minutes and run the command again and see that the time has updated. If the time is never updating, go back to the JSON file and verify the path is correct and reboot the Pi once more.

Conclusion

Now that we have successfully moved all of the files used by HomeAssistant off of the SD card and on to an external drive, we have just greatly increased the longevity of the SD card. One thing that going through all this setup is showing, even if you backup all of your configs, preferences and data, it would be a huge pain to have to set all of this work we are doing again in the case of a failed SD card. Speaking of backing things up, in a future post I will go over how to set the Pi up to automatically backup all of our settings and data, so look forward to that soon.

5,094 replies on “Running Home Assistant Off An External Drive”

Long time reader, first time commenter — so, thought I’d drop a comment..
— and at the same time ask for a favor.

Your wordpress site is very simplistic – hope you don’t mind me asking what theme you’re using?
(and don’t mind if I steal it? :P)

I just launched my small businesses site –also built in wordpress like yours– but the theme
slows (!) the site down quite a bit.

In case you have a minute, you can find it by searching for “royal cbd” on Google
(would appreciate any feedback)

Keep up the good work– and take care of yourself during the coronavirus scare!

~Justin

Hi there would you mind letting me know which hosting company
you’re using? I’ve loaded your blog in 3 different internet browsers
and I must say this blog loads a lot faster then most.

Can you suggest a good hosting provider at a honest price?
Cheers, I appreciate it!

amateur sex cams [url=https://sexcams00.live]amature sex cams [/url] instant sex with strange girls hiden cams.
live sex cams naked [url=https://sexcams00.site]tasty hot latinas sex cams [/url] l.ive jap sex cams.
free naked sex cams [url=https://sexcams00.space]24 7 sex cams [/url] hidden cams nanny sex.
top ten sex cams [url=https://sexcams00.work]sexcams00.work[/url] live gay sex web cams.
snapchat sex cams [url=https://sexcams00.work]free live streaming sex cams [/url] mature forced sex cams.
dirty sex cams dirty sex chat now [url=https://sexcams00.online]cam4 free live sex cams [/url] trailer park go on live web cams to have and show having sex party.
hairy sex cams [url=https://sexcams00.site]watch free sex web cams [/url] phone chat sex cams.
live sex cams bbw [url=https://sexcams00.site]sexcams00.site[/url] just sex chat, no cams with mature women.

nude amateur babes giving head tumblr [url=https://amateurwebcams00.xyz]amateur mature nude women [/url] huge tit latina amateur tweety tattoo.
indian porn star shanaya fuck [url=https://asianwebcams00.website]asianwebcams00.website[/url] japanese full body massage porn.
ebony shower sex movies [url=https://blackwebcams00.icu]blackwebcams00.icu[/url] chubby ebony sucks big white dick.
black college graduate porn [url=https://collegewebcams00.site]collegewebcams00.site[/url] awesome orgasm teen lesbian college.
asian lesbian strapon girl ass [url=https://lesbianwebcams01.fun]lesbianwebcams01.fun[/url] star trek cosplay lesbian porn.
mature wife hand on dick [url=https://maturewebcams00.space]mature ebony pussy pics [/url] Turkish hairy mature pics.
latina milfs in panties [url=https://milfwebcams00.club]milfwebcams00[/url] milf and daughter sharing nigger cock.
old woman fucks teen boys [url=https://teenwebcams00.uno]free teen in thigh highs porn [/url] best new naked teen pics.
amateur black.mature fuck young giys [url=https://amateurwebcams00.monster]amateurwebcams00.monster[/url] red head amateur nude.
top 5 female asian porn stars for 1019 [url=https://asianwebcams00.host]desi wife radha gives boob suck [/url] black guy fucks thin tall japanese.
black girl tit whipping [url=https://blackwebcams00.pw]blackwebcams00.pw[/url] sex black men fucking asians.
busty teen college lesbian 69 porn [url=https://collegewebcams00.store]hot naked college petite blonde teen masterbating [/url] blonde petite college fuck.
mature lesbians sucks pussy [url=https://lesbianwebcams00.fun]lesbianwebcams00.fun[/url] watch lesbians live porn.
amateur blonde stockings mature porn [url=https://maturewebcams00.club]chubby mature woman missionary position porn [/url] amateur mature mom dp.
mike adriano milf pussy porn [url=https://milfwebcams00.casa]milfwebcams00[/url] xhamster milf loves 2 huge cocks.
ebony teen prone zone porn [url=https://teenwebcams00.press]teenwebcams00[/url] hot teen jocks gay fuck for a dare.

free xxx amateur homemade real incest sex movies [url=https://amateurwebcams00.xyz]amateurwebcams00.xyz[/url] real lesbian amateur couple.
naked japanese father in law forces sons wife [url=https://asianwebcams00.website]asian lesbian anal strapon [/url] chinese barber fuck bbc.
latex big tit ebony [url=https://blackwebcams00.icu]blackwebcams00[/url] interacial porn 2 black girk.
percentage of sex between college students [url=https://collegewebcams00.site]college girls boobs tumblr [/url] amateur hot college sex party.
naked lesbian clean lady [url=https://lesbianwebcams01.fun]lesbianwebcams01.fun[/url] 2 hot blondes lesbian scene in bed.
mature filiopino ladyboys creampie [url=https://maturewebcams00.space]mature amature monster sex toy [/url] mature women’s abused sex videos.
uncensored milf japanese tube [url=https://milfwebcams00.club]milfwebcams00.club[/url] milf ass fucking videos.
bhung black teen fuck gay white boy [url=https://teenwebcams00.uno]big tit teen walk naked inpubic porn [/url] naked femboy black teen.
brunette amateur toys her pussy on cam [url=https://amateurwebcams00.monster]amateur wife watches husband fuck [/url] amateur masturbates to orgasm for audience.
asian american teen girl sex [url=https://asianwebcams00.host]japanese girl lingerie nude [/url] asian sleeping mom and daughter porn.
my fat black ass [url=https://blackwebcams00.pw]blackwebcams00.pw[/url] bbw black latina milf hige ass.
hazing porn gettysburg college [url=https://collegewebcams00.store]little tits college girls tumblr [/url] raped college girls porn movies.
jenna jamison and traci lords lesbian video [url=https://lesbianwebcams00.fun]lesbian porn parody [/url] bride to be lesbian sex.
mature sex vinture long movies [url=https://maturewebcams00.club]maturewebcams00[/url] mature brunette porn small tits.
young 32 year old women milf and necks [url=https://milfwebcams00.casa]milfwebcams00[/url] older milf soccer moms.
tiny teen anal barely legal [url=https://teenwebcams00.press]amateur black teen pussy [/url] teen couple sex on couch.

amateur cfnm porn handjob [url=https://amateurwebcams00.xyz]free amateur nude beach pictures [/url] young amateur girl webcam sex.
korean first time with bra porn [url=https://asianwebcams00.website]asianwebcams00[/url] ears and tail asian porn.
ko xxx black porn [url=https://blackwebcams00.icu]all black sex tubes [/url] thick fit black nudes.
1980s nude college girls spring break fuck [url=https://collegewebcams00.site]collegewebcams00[/url] amatuer bisexual college porn.
free lesbian kissing and fingerung [url=https://lesbianwebcams01.fun]young first time lesbians [/url] lesbian strapon stepmother stepdaughter.
petite redhead mature porn [url=https://maturewebcams00.space]maturewebcams00.space[/url] mature porn watching son.
amateur milfs fucking gifs [url=https://milfwebcams00.club]milfwebcams00[/url] ginger lynn milf porn.
blue pill latina teen porn jennifer [url=https://teenwebcams00.uno]teenwebcams00.uno[/url] teen faet box fucked.
coed amateur lesbian nipple seduction [url=https://amateurwebcams00.monster]amateur pussy cum tumblr [/url] amateur naked wife in kitchen with black man.
japanese daughter in law fucking [url=https://asianwebcams00.host]asianwebcams00[/url] naked bike asian inagram.
watch free big asses black pron [url=https://blackwebcams00.pw]black bred porn captions [/url] obse ebony racist porn.
dick tantillo hamilton college [url=https://collegewebcams00.store]collegewebcams00[/url] fun sex college korean.
lesbian fucks girl with clit [url=https://lesbianwebcams00.fun]lesbianwebcams00.fun[/url] horny wet lesbian massage.
bbw mature mexican ass [url=https://maturewebcams00.club]maturewebcams00[/url] mature big cock solo.
hot nude amateur milfs [url=https://milfwebcams00.casa]milfwebcams00[/url] milf with nice tits.
hands tied ass fucked teen [url=https://teenwebcams00.press]teenwebcams00.press[/url] mia khalifa pussy indian teen porn.