Raspberry Pi says it has run out of space

Over the last couple of weeks I have been plagued by my Raspberry Pi telling me it has run out of space. I have reformatted the SD card (32GB) and reloaded Hassbian several times, and things run fine for a couple of says before it stops working again and shows the same warning.
I started using a new SD card yesterday and all was working well until I amended by sensors.yaml file. I am trying to add two SMA Sunny Boys (but that’s another story). The run out of space error has recurred. I am unable to open the sensors.yaml, or at least when I do it is completely empty, as are all the other home assistant files. I can see that the /dev/root directory is completely full but I don’t know what to do with it. I have another RPi running Hassbian and this is showing 14% use of this directory.
Thanks for any advice. Is there a problem with the Raspberry Pi hardware?

This is the error I am getting:

homeassistant@hassbian:~/.homeassistant $ nano sensors.yaml
Unable to create directory /home/homeassistant/.nano: No space left on device
It is required for saving/loading search history or cursor positions.

Press Enter to continue

Here is the file use:

pi@hassbian:/home/homeassistant/.homeassistant $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 1.8G 1.7G 0 100% /
devtmpfs 460M 0 460M 0% /dev
tmpfs 464M 0 464M 0% /dev/shm
tmpfs 464M 6.6M 458M 2% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 464M 0 464M 0% /sys/fs/cgroup
/dev/mmcblk0p1 43M 22M 22M 51% /boot
tmpfs 93M 0 93M 0% /run/user/1000
pi@hassbian:/home/homeassistant/.homeassistant $

Here is a breakdown of the files in /dev:

pi@hassbian:/dev $ du -bsh *
0 autofs
796 block
0 btrfs-control
240 bus
0 cachefiles
3.5K char
0 console
0 cpu_dma_latency
0 cuse
756 disk
0 fb0
13 fd
0 full
0 fuse
0 gpiochip0
0 gpiochip1
0 gpiomem
0 hwrng
25 initctl
60 input
0 kmsg
28 log
0 loop0
0 loop1
0 loop2
0 loop3
0 loop4
0 loop5
0 loop6
0 loop7
0 loop-control
60 mapper
0 mem
0 memory_bandwidth
0 mmcblk0
0 mmcblk0p1
0 mmcblk0p2
40 mqueue
60 net
0 network_latency
0 network_throughput
0 null
0 ppp
0 ptmx
0 pts
0 ram0
0 ram1
0 ram10
0 ram11
0 ram12
0 ram13
0 ram14
0 ram15
0 ram2
0 ram3
0 ram4
0 ram5
0 ram6
0 ram7
0 ram8
0 ram9
0 random
60 raw
0 rfkill
7 serial1
40 shm
232 snd
15 stderr
15 stdin
15 stdout
0 tty
0 tty0
0 tty1
0 tty10
0 tty11
0 tty12
0 tty13
0 tty14
0 tty15
0 tty16
0 tty17
0 tty18
0 tty19
0 tty2
0 tty20
0 tty21
0 tty22
0 tty23
0 tty24
0 tty25
0 tty26
0 tty27
0 tty28
0 tty29
0 tty3
0 tty30
0 tty31
0 tty32
0 tty33
0 tty34
0 tty35
0 tty36
0 tty37
0 tty38
0 tty39
0 tty4
0 tty40
0 tty41
0 tty42
0 tty43
0 tty44
0 tty45
0 tty46
0 tty47
0 tty48
0 tty49
0 tty5
0 tty50
0 tty51
0 tty52
0 tty53
0 tty54
0 tty55
0 tty56
0 tty57
0 tty58
0 tty59
0 tty6
0 tty60
0 tty61
0 tty62
0 tty63
0 tty7
0 tty8
0 tty9
0 ttyAMA0
0 ttyprintk
0 uhid
0 uinput
0 urandom
0 vchiq
0 vcio
0 vc-mem
0 vcs
0 vcs1
0 vcs2
0 vcs3
0 vcs4
0 vcs5
0 vcs6
0 vcsa
0 vcsa1
0 vcsa2
0 vcsa3
0 vcsa4
0 vcsa5
0 vcsa6
0 vcsm
0 vhci
0 watchdog
0 watchdog0
0 zero

EDIT
Also, are you sure you using full SD card space?
If you just wrote image to SD card not likely you using full space

1 Like

It looks like you are only using 2GB of your SD Card. Before reinstalling, be sure to remove all partitions and use the recommended SD Formatter.

I had the same problem, I’m using etcher to write the hassbian image.

Solved with sudo resize2fs /dev/mmcblk0p2

I have used etcher too with good results. I just know the makers of the Pi say to use the SD Formatter before installing an image in an SD Card. It has worked for me and helped others here.

Ultimately, of course, the choice is yours.

Thanks for the rapid response, very helpful. I have been using SD Memory Card Formatter and doing an Overwrite format, then using Balanetcher to put on the hassbian image.
I have run through this process again, and ended up with a fresh install with the following:

pi@hassbian:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 1.8G 1.5G 167M 91% /
devtmpfs 460M 0 460M 0% /dev
tmpfs 464M 0 464M 0% /dev/shm
tmpfs 464M 12M 452M 3% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 464M 0 464M 0% /sys/fs/cgroup
/dev/mmcblk0p1 43M 22M 22M 51% /boot
tmpfs 93M 0 93M 0% /run/user/1000

So, the pre-existing problem of the full card not being used occurred again.

I tried cinquemic’s solution:

pi@hassbian:~ $ sudo resize2fs /dev/mmcblk0p2
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mmcblk0p2 is now 7779456 (4k) blocks long.

And recheck:

pi@hassbian:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 30G 1.6G 27G 6% /
devtmpfs 460M 0 460M 0% /dev
tmpfs 464M 0 464M 0% /dev/shm
tmpfs 464M 12M 452M 3% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 464M 0 464M 0% /sys/fs/cgroup
/dev/mmcblk0p1 43M 22M 22M 51% /boot
tmpfs 93M 0 93M 0% /run/user/1000

Now the full card is being used.
Superb solution cinquemic, bang on!

As well as running out of space over the last 2 weeks my RPi has been mysteriously getting stuck at the username, refusing to recognise my private key and dropping out when I used my password. Hopefully this has been caused by the 2GB limit as well.
Also a bit odd but my other RPi which is running another Home Assistant instance, and for which I use the same SD Card Formatter and BalanaEtcher is showing it’s full 16GB size.
Thanks again!

If you’re using hassbian, you can just use sudo raspi-config to modify this.

This isn’t an issue with Home Assistant OR the method in which you create the SDCard, it’s how Raspbian works.

My Raspbian Lite (installed using NOOBS Lite used all my 32 GB card except the small NOOBS partition.
So, that is NOT how Raspbian works!

Thanks flamingm0e, good tip.

It actually is EXACTLY how Raspbian works. NOOBs does things differently.

https://www.raspberrypi.org/documentation/configuration/raspi-config.md

Expand Filesystem

If you have installed Raspbian using NOOBS, the filesystem will have been expanded automatically. There may be a rare occasion where this is not the case, e.g. if you have copied a smaller SD card onto a larger one. In this case, you should use this option to expand your installation to fill the whole SD card, giving you more space to use for files. You will need to reboot the Raspberry Pi to make this available. Note that there is no confirmation: selecting the option begins the partition expansion immediately.

Educate yourself.

The strange thing is that I write Hassbian image a lot of times and this is never happened.
Only with the latest image I have to expand the file system.