Help Recovering Disk Space

root@DietPi:~# cat /boot/dietpi/.version
G_DIETPI_VERSION_CORE=9
G_DIETPI_VERSION_SUB=13
G_DIETPI_VERSION_RC=2
G_GITBRANCH=‘master’
G_GITOWNER=‘MichaIng’
G_LIVE_PATCH_STATUS[0]=‘not applicable’
G_LIVE_PATCH_STATUS[1]=‘applied’
G_LIVE_PATCH_STATUS[2]=‘applied’
G_LIVE_PATCH_STATUS[3]=‘applied’


root@DietPi:~# echo $G_DISTRO_NAME $G_RASPBIAN
bullseye 0


root@DietPi:~# uname --all
Linux DietPi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux


root@DietPi:~# dpkg --print-architecture
arm64


root@DietPi:~# echo $G_HW_MODEL_NAME
RPi 4 Model B (aarch64)


Factory power supply


Samsung EVO Select 64GB card

On my home network, I use an RPi 4b/8GB running DietPi 9.13 on a 64GB card. Its only purpose has been to run Pi-hole but I did install additional software with the intent to investigate it. Never happened.

Lately, I’ve been getting DISK_EXTENDED alerts in the Pi-hole dashboard.

Disk shortage ahead: 93% is used (58.8GB used, 62.8GB total) on ext4 filesystem mounted at /

Hunting around the iNet, I came up with a few commands, the output of which outline the basics of the problem but get me and my skill set no closer to a solution.

root@DietPi:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        59G   51G  5.1G  91% /
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G  6.2M  3.9G   1% /dev/shm
tmpfs           1.6G  160M  1.4G  11% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.9G     0  3.9G   0% /tmp
tmpfs            50M  492K   50M   1% /var/log
/dev/mmcblk0p1  253M   34M  219M  14% /boot
overlay          59G   51G  5.1G  91% /mnt/dietpi_userdata/docker-data/overlay2/94e41b7976941c14814013717e38aa7a63e89f52c205cae9fb05dc3619285b35/merged

root@DietPi:~# sudo du -hsx /* | sort -rh | head -n 40
du: cannot access '/proc/969097/task/969097/fd/4': No such file or directory
du: cannot access '/proc/969097/task/969097/fdinfo/4': No such file or directory
du: cannot access '/proc/969097/fd/3': No such file or directory
du: cannot access '/proc/969097/fdinfo/3': No such file or directory
48G	/mnt
2.0G	/etc
769M	/usr
312M	/lib
160M	/run
85M	/var
36M	/root
34M	/boot
9.8M	/bin
6.8M	/sbin
248K	/opt
20K	/home
16K	/lost+found
4.0K	/srv
4.0K	/media
0	/tmp
0	/sys
0	/proc
0	/dev

What I get from all that is DietPi is storing backups in a directory it probably shouldn’t be and they’re piling up.

I’m a Mac Guy, so I fired up iTerm, logged into the 4b and navigated to the Backup/Restore function. I turned off daily backups, reduced the amount of backups to keep from 14 to 10 and turned on Space Check. There is an option to delete backups from /mnt/dietpi-backup, but I haven’t done that yet as it’s not the offending directory. I’m guessing the previous limit of 14 backups is also not being observed because of a directory mixup.

Some deep background.

I’m about a Level Zero at this stuff. Over its four years of service, the 4b has run off the same card, so all updates have been built on past installations for both DietPi and Pi-hole. There have been power outages during that time and… of course… me poking at it periodically with a keyboard, not really knowing what I’m doing. Which is to say, it could be jacked up on blocks and missing a few wheels.

Ideas on how I can remove the backups from the wrong directory and direct future backups to the correct directory? Is this accomplishable with a dashboard and will one fit in the remaining space on the card?

Thanks

ncdu might help as well

once you find the offending disk usage…you can remove the files/directories

Your list from above shows something in the /mnt directory using 48GB of space…poke around in there

2 Likes

Ya know… I looked at a lotta different sites for advice and somehow that one didn’t come up. It even explains the commands - nice!

Guessing NCDU can be installed from within DietPi, so I’ll have a look at that too and report back.

Appreciate you.

1 Like

Why to install additional software. Not needed backups can be removed by simply using rm command. And yes, backups are stored in /mint/dietpi-backup as default location.

Yeah, you installed something with docker, which also needs a lot of space?!

I guess the default limit for dietpi-backup is to keep 3 backups, which IMO is enough for a pihole backup :sweat_smile:

Anyways, when you change the number of backups and execute a new one, unneeded backups should be deleted automatically

2 Likes

To get more details on where disk space is used

du -aBM / | sort -n -r | head -n 20

My bulletin board days are long behind me. I picked up and started running with a GUI when Apple released the II. I just figgered a GUI would be easier, but the DietPi CLI is friendly enough. It’s the commands that are a problem for me. Suppose I should take some online classes.

Last night I used the software removal tool in DietPi to remove Docker and Portainer. However, running the df -h command showed no gain in free space. Puzzled, I went to bed thinking elves would somehow fix it overnight.

Nope.

This command you shared shed some more light.

root@DietPi:~# du -aBM / | sort -n -r | head -n 20
du: cannot access '/proc/1114183': No such file or directory
du: cannot access '/proc/1114923/task/1114923/fd/3': No such file or directory
du: cannot access '/proc/1114923/task/1114923/fdinfo/3': No such file or directory
du: cannot access '/proc/1114923/fd/4': No such file or directory
du: cannot access '/proc/1114923/fdinfo/4': No such file or directory
51961M	/
48754M	/mnt/dietpi-backup
48754M	/mnt
3491M	/mnt/dietpi-backup/data
3484M	/mnt/dietpi-backup/data_2
3483M	/mnt/dietpi-backup/data_6
3483M	/mnt/dietpi-backup/data_5
3483M	/mnt/dietpi-backup/data_4
3483M	/mnt/dietpi-backup/data_3
3482M	/mnt/dietpi-backup/data_9
3482M	/mnt/dietpi-backup/data_12
3481M	/mnt/dietpi-backup/data_8
3481M	/mnt/dietpi-backup/data_7
3481M	/mnt/dietpi-backup/data_14
3481M	/mnt/dietpi-backup/data_13
3481M	/mnt/dietpi-backup/data_11
3481M	/mnt/dietpi-backup/data_10
1970M	/etc
1969M	/mnt/dietpi-backup/data/etc
1964M	/mnt/dietpi-backup/data_6/etc

Now, being able to see the Pi-hole backup files in the mnt/dietpi-backup directory, I opened up DietPi Explorer and deleted the backup folder. I then recreated it and backed up the system.

So now…

root@DietPi:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        59G  5.9G   51G  11% /
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G  6.3M  3.9G   1% /dev/shm
tmpfs           1.6G  160M  1.4G  11% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.9G     0  3.9G   0% /tmp
tmpfs            50M  524K   50M   2% /var/log
/dev/mmcblk0p1  253M   34M  219M  14% /boot

..Immediate problem solved. My Pi-hole backups are looking a little chunky however, so I’ll have to review what’s goin’ on there.

Thank you very much for the help.

Sometimes I just hit the, “Sure, Why Not?” button and unanticipated things happen. It’s a lesson I have to relearn every few months.

It’s clear to me now that 14 backups was only part of the problem. It’s as the backups grew in size that free space got choked. I set the number to three as you advised.

What I’d like to figure out next is how to change the DietPi backups from daily to weekly.

You would need to use regular crontab for this.

I feel you bro, I did so much trail and error in the beginning, but you took the right path and made backups (OK maybe a bit too many, but better then none! :sweat_smile:) but I learned the even harder way, without backups :joy:

The dietpi-backup script offers only daily backup, but as Joulinar already mentioned, you can just use crontab for this.
Disable the daily backup in dietpi-backup, let the rest untouched.
Then you can run dietpi-cron to take some settings for the weekly cronjob, like the day and the time.
In this menu are also the corresponding folders mentioned, where you have to place a script file (in your case it is /etc/cron.weekly/, which get’s then executed every week at the time you set earlier.

Then you just create file (e.g. backup-weekly) with this content:

#!/bin/bash
/boot/dietpi/dietpi-backup 1

So in the end you have a file /etc/cron.weekly/backup-weekly.

alternative:

you could also use sudo crontab -e and create an entry there for executing the backup script, like:

0 2 * * 0 /boot/dietpi/dietpi-backup 1

Which would execute this command every sunday at 2 AM.

see also:
https://ostechnix.com/a-beginners-guide-to-cron-jobs/
https://dietpi.com/forum/t/weekly-backup-instead-daily-backup/21715/2

1 Like

Thanks for those instructions. Looking at DietPi-cron, all you see is the Daily/Weekly/Monthly defaults. Didn’t realize customization was an option.

I think at this point I’m going to dedicate this 4b to just Pi-hole duty. That’s an important job on my network since my gear points to it for DNS. I’ve got other RPis and a Zimaboard I can use to mess around with. In fact, I should take one and create a backup Pi-hole server for redundancy.

For a system that is only used for PiHole, it is actually sufficient to create a manual backup before performing an update or doing configuration changes. There is actually no data that needs to be backed up daily.