GuideHome Automation

Migrate Home Assistant to Argon One M.2 SSD

Now that my previous issues with the Argon ONE M.2 case have been resolved, I’m able to finally put the case to use for its originally intended purpose, as the new home for running my Home Assistant instance. Over the years I’ve had a small number of MicroSD cards fail in my Pi’s running Home Assistant, though this has been mitigated over time by switching to using SanDisk Max Endurance micro SD cards, along with switching the SQLite running on the Pi to a MariaDB on a network-connected server. However, now that the Raspberry Pi 4 and Home Assistant support USB boot for SSD storage, I thought I could consolidate and get a speed boost from the SSD storage.

My Home Assistant Server Hardware

  • Argon ONE M.2 Case for Raspberry Pi 4
  • Raspberry Pi 4 – 4GB version
  • Transcend 240GB M.2 SATA SSD (short 42mm M.2 card, just what I had available)
  • RFXCOM RFXtrx433E USB 433.92MHz Transceiver
  • Nortek HUSBZB-1 USB Zigbee Hub (Z-Wave USA frequencies only)


Prepare Snapshot

If you’re performing a new install and not a migration, you can skip this step.

If you’re starting with an existing installation then create a full Snapshot and download the file, we’ll upload this later to restore the system to persist the current setup. This will also serve as a second backup (in addition to the SD-Card) should things go wrong along the way. You create a Snapshot via the Home Assistant UI: Supervisor > Snapshots > Create Snapshot. Once created, click on the Snapshot and then “Download Snapshot“, which will save the .tar file to a location of your choice.

Now, shutdown the current Home Assistant Raspberry Pi and remove the micro SD-Card.

Prepare Raspberry Pi 4 for USB Boot

Being able to boot from a USB connected SATA drive, is a relatively recent update to the Raspberry Pi, as such you may need to configure your Raspberry Pi with the latest firmware to allow it to work. If you’ve not updated your Pi you may need to update and enable USB boot. Fortunately, this process has been simplified thanks to the new Raspberry Pi Imager tool.

First, you’ll need a spare micro SD-Card (assuming you want to keep your current card as a backup), secondly, you’ll need to download the Raspberry Pi Imager, once downloaded run the Imager:

  • Operating System: Choose OS > Misc utility images > Bootloader > USB Boot
  • Using your spare micro SD-card, insert this into your card reader and under Storage: Choose Storage > [Pick your SD card from the dialog]
  • Choose: Write and wait for the image to be written to the card and unmounted (ejected).
  • Insert the micro SD-card into your Raspberry Pi and power up the Pi and wait for about 5 minutes whilst it boots, updates the firmware and sets the device to boot from USB. This happens automatically so you don’t need to connect a display to your Pi.
  • After a few mins, power off the Pi and remove the SD-card.

Installing Home Assistant Directly onto SSD

Whilst the Raspberry Pi Imager includes Home Assistant under the “Operating System” list, it may not be the latest version. So better to download the latest image directly from the website, opting for the 64bit image. At time of writing, this was: haos_rpi4-64-6.1.img.xz

In order to install Home Assistant directly onto the SSD in the base of the Argon ONE M.2 case, you’ll need to connect the Argon M.2 board to your PC. To do this requires either:

  • A USB-A to USB-A cable, a slightly unusual cable you may not have on hand, but easily sourced and inexpensive.
  • A USB3 Male to Female extension cable, and use the U shaped USB adapter that comes with the case to convert it to a male to male cable. (Great suggestion from Bill in the comments below, in his case he had to attach it to a USB port directly on the motherboard to get it to be recognised).
  • An adapter to allow the M.2 drive to be directly connected to your PC via USB.
  • Using the Raspberry Pi Imager (or Balena Etcher, or similar) set Operating System: Choose OS > Use custom then pick the haos image file downloaded previously.
  • Connect the M.2 SATA SSD drive via a suitable cable or adapter to your PC, it should be recognised as a USB drive. Select Choose Storage > Argon Forty SCSI Disk Device
  • Time to Write the image. Once complete you can disconnect the drive from your computer and it’s ready to be used with the Pi.

Preparation is now complete, you can assembly your Argon ONE M.2 case, ensuring you’ve removed the micro SD-card from your Raspberry Pi.

Setup Home Assistant

Network Connection

If you can, I’d recommend setting up Home Assistant initially with the Pi connected via a wired ethernet connection to your network. Wireless can be configured via the Home Assistant UI later (Supervisor > System > Host > IP Address > Change > WI-Fi) if needed. If this isn’t an option you can configure WiFi via a number of means, I’ll cover just one method.

WiFi Configuration

  • Reconnect Argon ONE M.2 drive to your computer. The drive should mount as: hassos-boot
  • Create folders \Config\Network
  • Create a file \Config\Network\my-network (ensure it doesn’t have any file extension, e.g. .txt)
  • Edit the file my-network with either Visual Studio Code or Notepad++ (as we need to change the file line endings)
  • Using the template below, enter your WIRELESS_SSID and WIRELESS_PASSWORD, if you have multiple devices you may also want to set a new uuid, you can generate using this Online UUID Generator.
  • Before saving the file set the line endings to LF not the Windows defauly CRLF. In VSCode this can be done using the selector in the footer area

Initial Home Assistant Setup

It can take several minutes for HomeAssistant to complete the initial setup, you can monitor progress if you connected to the HDMI connection, or just have a cup of tea and check back later. Once set up the Home Assistant instance should be available at alternatively check your DHCP allocations and determine what IP address has been issued.

Restore Snapshot

If your snapshot doesn’t have a password select the link at the bottom of the initial screen, to upload and restore your snapshot.

Otherwise, if your snapshot is password-protected, create a temporary user account, and complete the setup wizard. Don’t worry about the details as all this will be reset once the snapshot is restored. Once the wizard is complete navigate to: Supervisor > Snapshots and click on the 3 dots menu in the top right, then select: Upload snapshot and pick your snapshot. Once uploaded enter the password and select Restore.

Once the snapshot has been restored, you should see your Home Assistant instance running as before the migration. We now need to make configuration changes specific to running with the Argon ONE enclosure.

Argon ONE Configuration

The Argon ONE enclosure provides a great passive cooling solution, but with the option to control a fan to provide active cooling if needed. The enclosure also provides a power button that can be used, but both use I2C, which isn’t enabled by default in Home Assistant.

Enable i2c Support

As always there are multiple ways of enabling i2c, I’ll cover one method here.

  • If powered on, shutdown your Raspberry Pi.
  • Reconnect Argon ONE M.2 drive to your computer. The drive should mount as: hassos-boot
  • Create folders \Config\modules
  • Create and edit a file \Config\modules\rpi-i2c.conf and the following line:
  • Before saving the file set the line endings to LF not the Windows defauly CRLF. In VSCode this can be done using the selector in the footer area.
  • Next edit \config.txt at the the root of hassos-boot. Add these to the end of the configuration file:
  • Save changes, then disconnect the M.2 SSD from your computer and reconnect to the Raspberry Pi and boot it once again.
  • Upon boot hassos will read the rpi-i2c.conf file, however it requires a further reboot before this can be used. So once booted goto: Supervisor > System > Host > Reboot Host

Fan Control

I found a couple of options for adding automated Fan Control to Home Assistant and went with the Argon ONE Active Cooling Addon.

  • Navigate to the Argon ONE Active Cooling Addon page and press the “Add Respository” button. Alternatively within your Home Assistant goto: Supervisor > Add-on Store select Respositories from the tripple dot menu in the top left and add:
  • Once added, select ArgonOne Active Cooling from the list of available Add-ons and install it
  • Once installed, select Start then navigate to the Addon Log. The log should look similar to:
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] executing... 
 Add-on: ArgonOne Active Cooling
 Actively keeping your Argon One cool.
 Add-on version: 23
 You are running the latest version of this add-on.
 System: Home Assistant OS 6.1  (aarch64 / raspberrypi4-64)
 Home Assistant Core: 2021.7.1
 Home Assistant Supervisor: 2021.06.8
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
[cont-init.d] exited 0.
[cont-init.d] executing... 
[cont-init.d] exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Detecting Layout of i2c, we expect to see "1a" here.
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- 1a -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Settings initialized. Argon One Detected. Beginning monitor..
Current Temperature 46 °C
2021-07-11_14:36:35 Level 1 - Fan 0% (OFF)
  • If you get an error when i2c, check you completed the steps to enable i2c above and that you have rebooted your Pi.
  • The configration can be changed between degrees F and degrees C. My configuration (in YAML) is:
CorF: C
LowRange: 55
MediumRange: 60
HighRange: 75
QuietProfile: true
Create a Fan Speed entity in Home Assistant: true
Log current temperature every 30 seconds: false
  • Note that the option to “Create a Fan Speed entity in Home Assistant”, isn’t all that useful. As it only works if you start/restart the add-on after Home Assisatant has started.
  • You can monitor Home Assisatant temperature using the built in sensor: sensor.ha_cpu_temperature which appears to update every minute.

Power “Always On”

Current versions of the Argon ONE case have a jumper that can be configured so that when power is connected, the Pi boots immediately without needing to press the power button. This is probably what we want for Home Assistant, in order to ensure that after a power cut, our system is up and running. Sadly older versions of the Argon ONE, Lacked this jumper and could only be set via a special command being sent via i2c. I doubt this is going to be a problem for anyone with a current case, so I’ll not cover that hack here, instead, you can learn about the code here.

SSD Optimisations

As Home Assistant (HAOS) runs using a collection of Docker images, using SSH to connect into your Home Assistant opened a session within a docker container, whereas for the low-level changes we need to do, we need to access the underlying OS. For obvious security reasons access to this isn’t enabled by default and you’d want to ensure you restrict access to this endpoint.

This guide provides some clear steps to get access to the underly system that we need. Though the page needs to be translated from Italian by google translate.

Enable Trim Support

Not all SATA SSD Controllers support Trim, however, those that do will increase the life of your SSD. The controller used in the Argon ONE M.2 case does support trim, but it’s not enabled automatically. At least not at the moment.

Connect to your Pi on port 22222 logging in as root. (Note this privileged SSH connection isn’t enabled by default, see setup instructions here) Below shows the initial series of commands showing trim isn’t enabled. The lsusb command lists out the attached USB devices, depending on the version of the M.2 board the last 4 digits of the device ID may be different, but I believe they all have the same prefix 174c.

# fstrim -v /
fstrim: /: the discard operation is not supported
# lsblk -D
sda           0        0B       0B         0
|-sda1        0        0B       0B         0
|-sda2        0        0B       0B         0
|-sda3        0        0B       0B         0
|-sda4        0        0B       0B         0
|-sda5        0        0B       0B         0
|-sda6        0        0B       0B         0
|-sda7        0        0B       0B         0
`-sda8        0        0B       0B         0
zram0         0        4K       2T         0
zram1         0        4K       2T         0
zram2         0        4K       2T         0
# lsusb
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 006: ID 10c4:8a2a
Bus 001 Device 002: ID 2109:3431
Bus 002 Device 002: ID 174c:1156
Bus 002 Device 001: ID 1d6b:0003
Bus 001 Device 004: ID 0403:6001

To enable trim you’ll need to use the editor vi (sorry that’s all there is).

  • Enter the command: vi /etc/udev/rules.d/50-usb-ssd-trim.rules
  • press i (to enter inserrt mode)
  • Type or copy and paste the following, updating your Vendor and Product IDs as needed:
ACTION=="add|change", ATTRS{idVendor}=="174c", ATTRS{idProduct}=="1156", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
  • Press ESC to exit insert mode
  • Type :wq then press enter (this will save and exit the editor)
  • Restart the operating system via the Home Assistant UI: Supervisor > System > Host > Restart Host
  • Once rebooted, reconnect to your Pi on port 22222
  • The lsblk command should now show non zero valudes for DISC-GRAN and DISC-MAX
  • You can now manually issue a trim command: fstrim -a -v
# lsblk --discard /dev/sda
sda           0      512B       4G         0
|-sda1        0      512B       4G         0
|-sda2        0      512B       4G         0
|-sda3        0      512B       4G         0
|-sda4        0      512B       4G         0
|-sda5        0      512B       4G         0
|-sda6        0      512B       4G         0
|-sda7        0      512B       4G         0
`-sda8        0      512B       4G         0
# fstrim -a -v
/var: 30.9 MiB (32350208 bytes) trimmed on /dev/zram1
/tmp: 15.4 MiB (16162816 bytes) trimmed on /dev/zram2
/mnt/data: 215.8 GiB (231723094016 bytes) trimmed on /dev/sda8
/mnt/overlay: 87.3 MiB (91492352 bytes) trimmed on /dev/sda7
/mnt/boot: 24.9 MiB (26101760 bytes) trimmed on /dev/sda1
  • Now that it’s configured Home Assistant will perform trim opperations weekly without further intervention.

Reduce Writes

Using an SD Card or SSD it’s beneficial to reduce the number of writes occurring. One simple set of changes to consider is to configure Home Assistant to queue changes to write, this can be done using the commit_interval setting. Setting this to commit every 60 seconds, does mean that in the event of power loss up to 60 seconds worth of data could be lost.

You may also want to look at how many days of data you want to store here, I suspect it’s rare you need more than a few days. For longer-term trend data, I’d recommend you use InfluxDB and Grafana or similar, rather than trying to make Home Assistant try and do everything.

  purge_keep_days: 3
  commit_interval: 60

Product Links

  • Raspberry Pi 4 (Amazon) (ThePiHut)
  • Argon ONE M.2 SSD case (Amazon) (ThePiHut)
  • Argon ONE M.2 expansion kit (Amazon) (ThePiHut)
  • USB 3.0 Type-A to Type-A cable (Amazon)
  • SanDisk Max Endurance Micro SD Card (Amazon)
  • Transcend 240GB 42mm M.2 SATA SSD (Amazon)
  • RFXCOM RFXtrx433E USB Transceiver (RFXCOM)
  • Nortek HUSBZB-1 USB Zigbee (and Z-Wave USA Frequencies only) (Amazon)
  • 90 Degree USB Adapter (UP) to mount Zigbee vertically (Amazon .COM, .UK)

Amazon links are affiliate links that help support the site, where possible I’ve used links that should take you to the product in the Amazon store in your region. Links to other suppliers are included for your convenience.

20 thoughts on “Migrate Home Assistant to Argon One M.2 SSD

  • Hi,

    I used this guide to install Home Assistant on my new Pi4 with Kingston A400 M.2 SSD. It was a great help! Thank you!

    For Home Assistant newbies a link to the “advanced configuration” page in the “Reduce Writes” section could be useful. That page explains how to edit configuration.yaml in a easy way.

    Best regards,

  • I really appreciated your guide, save me hours of trial and error. Thanks.

  • You don’t need a special USB cable. You can just use a USB-3 extension cable. Plug one end into your PC motherboard and them the other onto the U-shape USB bridge that comes with the Argon. I did find it required being plugged into a motherboard socket, otherwise the Crucial MX500 card I was using wouldn’t boot (just flashed red).

    Super good advice on everything else, too. Thanks!

    • Great suggestion, have added it to the post above.

  • Question about step 4—Insert the micro SD-card into your Raspberry Pi and power up the Pi and give it a few mins to boot, update the firmware and set the device to boot from USB. How do I update the firmware, I don’t have my Raspberry Pi connected directly to a display only through connecting via the network.

    Also, I only have a MAC (MacBook and iMAC if it matters). Does this change any of your instructions?



    • Hi Robert, If you’ve created an SD-Card using the Raspberry Pi Imager with the Misc utility images > Bootloader > USB Boot image, then when the device boots it automatically does the firmware update and configures the system to boot from USB (if available). If you don’t have any display connected, just give it a few mins, it does take very long. The instructions should be the same regardless of the machine/OS you’re using, there is a Raspberry Pi Imager for Windows, macOS and Ubuntu available.

      • Do you leave the sd card in permanently after you carry out the firmware update?

        • No, once the firmware is updated and booting from the USB M.2 SSD, you remove the MicroSD Card.

  • This is so helpful! I really appreciate the time and effort you put into such a fantastic tutorial!

    • Glad you found it helpful.

  • You are a legend, thank you!

    Having just bought myself an Argon One M.2 case, with a new Pi4 and an SSD to migrate my HA installation to something more permanent, it only just dawned on me – “how the heck do I setup this thing up on an SSD!?”

    Then I found what looks like a very thorough article right here explaining everything I need! :)

    • Glad you found it useful. If there is anything you think was ambiguous or could be added, please let me know.

  • Thank you for the wonderful guide. My migration was relatively painless, though a bit different. I had migrated from Webthings to Home Assistant recently, so this was the migration from the temporary sd-card copy to ssd (which used by the RPI-4 that ran Webthings). So a couple hours later and a couple of hacs fixed and I’m done.

  • Thanks for the great guide which has helped me a lot get up switching to SSD with the Argon One M.2.

    I had to do a full reboot after restoring my backup – before doing this, all my Add-ons were showing as not started (even though SSH and DuckDNS were clearly working). Settings > System > Hardware > … Menu > Reboot Host did the job for me.

  • Additionally, to the previous post – I normally use my Home Assistant server headlessly – no monitor. I can confirm that your steps under the heading “Prepare Raspberry Pi 4 for USB Boot” will complete automatically without any intervention. I was a little unsure, as I initially understood what you had written as:

    1.Insert the micro SD-card into your Raspberry Pi and power up the Pi and give it a few mins to boot
    2. update the firmware
    3. set the device to boot from USB.

    That wasn’t the case – all these things are done automatically. There is no need for anyone to do anything under 2 and 3 above. Just give it 5 minutes then disconnect power and move on to the next step.

    • Thanks, I’ve clarified the steps to make it clear that happens automatically.

  • Thank you for this guide, I had to look how to get the SSH 22222 add on working but this guide has been invaluable as I now have trim enabled :-)

    • I’m glad you found it helpful. Thanks for the feedback, I’ve added a link in the post to info for setting up the privileged connection on port 22222.

  • Bonjour
    Je veux installer homeassistant dernière version 64 bit sur un ssd intégré au boîtier Argon 2 , bien entendu j’installe homeassistant via le câble usb sur ordinateur et puis j’installe le ssd sur le boîtier.
    Ma question : est-ce nécessaire d’utiliser une la Micro SD si pourquoi puisque homeassistant est actuellement bootable sur usb .
    Merci d’avance de votre aide

    • Being able to boot the pi using USB may not be enabled, so writing home assistant directly to the SSD may still not allow the Pi to boot from it. You can of course try it and see if it works, if it doesn’t you’ll need to configure USB boot per the section in this post entitled: “Prepare Raspberry Pi 4 for USB Boot”. Thanks


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.