SSH no sudo (port 22 and 22222)

I installed hassio on a Raspberry Pi 3B+ with the hassio image for Raspberry Pi 3B+ 32bit (https://www.home-assistant.io/hassio/installation/)

Because of the many read/writes, I want to move logs and database to a USB-drive like mentioned here:

I installed the SSH server addon to be able to run the commands mentioned in the guide. To do so I need to have SU rights? When I setup just a normal password in SSH server config’(hassio . local : 8123) I can’t run this command:

sudo dmesg|tail -n 20|grep sd

Then I’ll get this message:

 -bash: sudo: command not found

I read I had to create a private key, so I did and added that to the SSH config under authorized_keys, but I still got the same message. After some reading, I had to add the authorized_keys through a config usb drive. So I did, and I could connect to hassio through PuTTy with the passphrase and privatekey file on port 22222. But when I try to run the command, I get this message:

hassio > sudo dmesg|tail -n 20|grep sd
Error: unknown command "sudo" for "hassio"
Run 'hassio --help' for usage.
FATA[0000] Error while executing rootCmd: unknown command "sudo" for "hassio"

So it’s still not working. What can I do to fix this?

Sorry but the “only” ssh login via the standard hassio addon is root.
You can’t ‘assume’ privileged commands from root, you are root.
There may be issues with what you are trying to do given that the instructions assume the sudo command as they will not be written for hassos.
But you can try using the same commands but just remove the sudo.

Without the sudo I got nothing back, also no error. But I should get something back if I see the guide. But the guide says it’s for home assistant, so that would suggest it would work right? I’m new to this all so I just try to follow guides to be sure that what I’m trying to do is right. Do you know a better guide for hassos to move the logs and database to usb drive?

Based on this command in the guide:
sudo mv ~homeassistant/.homeassistant/home-assistant_v2.db /data/
That guide is for the PYTHON VENV installed version of home assistant, and not HassIO/HassOS.

Sorry, I’ve never tried to do what you are attempting, I’m sure someone else will have though so just hang tight someone ‘should’ come by with the relevant bits.

To flesh out some of the above : -
HA is a python package that runs in a docker environment
That docker ‘could’ be running in numerous different ways.
Generally the easiest for most people is VIA HassOS on a Rasberry Pi (I presume this is what you are using ?)
But other ways include running it on a Synology or QNAP NAS
Some install ubuntu or debian or ‘other’ brand of linux on a generic PC platform (be it a laptop, NUC of full desktop)
Hell, it’s even possible to install it in a venv (virtual environment) under (or should that be ‘on’ ? ) a windows 10 PC.
The least exotic alternate is Rasbian on a Pi
So the commands you are issuing are to the underlying OS or the OS running the Docker (in the case of a venv). And the systems are specific sometimes to the packages the user has installed. so guessing at the right commands is fraught with unintended consequescies.
The HassOS is most common so someone should be able to help.

HA is a python package. Docker doesn’t come into play unless you are running Docker or HassIO/HassOS.

You can run in python venv without docker even being near your system.

To clarify, the SSH add-on is a separate container from Home Assistant / HassIO, and the method to access HassOS using 22222 is accessing the very minimal, and not general distro, host operating system that is running bare necessities for Docker. HassOS is “an appliance” and not to be messed with.

1 Like

There you go, @flamingm0e knows this shit backwards, so follow his advice.
If on HassOS (I think you are) don’t mess !
If you still want to ‘mess’ then you have two options.

  1. move to an SSD on a Pi 3b or similar (not a 4 just yet) (and your files will be fine, with them as they are)
  2. install via a venv and resume your instructions (contact the guy who issues the instructions regarding support)

Okay thank you for the replies! That explains why it didn’t work. I heard you shouldn’t run all te logs and databases from the sd card for possible corruption. That’s the reason I tried to follow that usb guide.

But how to install it to a ssd? Without modifying the one-time programmable (otp) memory block? And can I also install it to an USB-stick instead of SSD? I have some 16GB and 32GB SanDisk Cruzer Ultra 3.0 usb sticks which I would like to use (I have no spare ssd’s here)

I can only find that the old version of Home Assistant is able to be installed to an USB-stick

I may have an answer :wink:

Install Raspbian, the default Raspberry Pi OS.
Then do a generic Linux install of HassIO.

Now, you can follow that guide in OP, just substitute “homeassistant/.homeassistant/” with “/usr/share/hassio/config/”

I have gone down similar install route.
Except on a 4GB Pi4. I allocated 2GB RAMdisk to hassio/addon (I’m using mariaDB addon instead of home-assistant_v2.db), allocated 100MB to hassio/config and 600MB to hassio/tmp. A custom systemd script to restore/save RAMdisk on shutdown and save it every few hours.
Everything else still runs on the SD card.

The read write cycles and the type of memory used for USB sticks vs SD cards means that the USB stick will not last significantly longer, hence the suggestion to go to SSD

Not sure about avoiding the write to otp, but you could try the method used used for running the system from SSD (USB would also work but would be as slow as SDcard) This uses the SD card just as a boot loader and points to the system via USB


(There’s also one on Tom’s Hardware guide, but I find the web page cripples my browser when I have 20ish pages open (only one of them Tom’s. He has a LOT of video Ads).
I assume you’d then do as @wyx087 suggests above and do a Hassio install on top

This seems a bit extreme but if you suceed please report back your findings and experiences.
Good Luck