I’m not a heavy user of snaps particularly on the Raspberry Pi 5. I find that installing software with Flatpak is a better solution than snap in most instances even though both are wasteful of disk space. But occasionally it’s useful to use a snap.
After installing a few snaps, df output gets overridden with /dev/loop entries
. Here’s an example.
A snap is a SquashFS file carrying content alongside metadata to tell the system how it should be manipulated.
What’s the easiest remedy to clean up df’s output besides avoiding snaps altogether?
I can exclude squashfs with the -x
flag. And use the -h
option to make the output human readable.
$ df -hx "squashfs"
Another solution is to use an alternative to df. There are quite a few alternatives to df featured in this roundup. My favourite is dysk which can be installed with cargo, Rust’s package manager. First install cargo.
$ sudo apt install cargo
Now let’s try to build dysk with the command:
$ cargo install dysk
dysk fails to build because the version of rustc installed with the Raspberry Pi OS is too old.
It’s suggested re-running cargo install with --locked
.
$ cargo install dysk --locked
That didn’t help.
Let’s remove the old version of rustc and cargo we’ve got.
$ sudo apt remove rust cargo
Let’s install the current version of Rust. Issue the command:
$ curl https://sh.rustup.rs -sSf | sh
Select option 1 by pressing enter.
I’ve now installed the current version of Rust on my Pi 5.
$ rustc --version
Let’s try compiling dysk again.
$ cargo install dysk
Success, dysk is now installed on my system.
Issue the command:
$ dysk
Here’s example output from dysk. In my opinion the output is much neater than with df.
Let’s go the whole hog and use an alias, so I can just type df. I’m going to use the -s label
flag in my alias.
Add the following line to ~/.bashrc
using a text editor such as nano.
alias df='dysk -s label'
Log out of the shell or type: $ source .bashrc
Now when I type df, I get the output.
This article was written on a Raspberry Pi 5 (16GB RAM) provided by SunFounder, a company focused on STEAM education with products like Open-source robots, Arduino & Raspberry Pi Kits, display screens, and other smart devices.
All articles in this series:
Raspberry Pi 5 Series | |
---|---|
Hardware | |
iRasptek Starter Kit | All the kit you need to get started with the Pi 5 |
Pironman 5 Case Review | Transform the Pi 5 into a beautiful desktop mini PC |
Passive Cooling the Pi 5 | Passively cool your Pi 5 the right way. Silent yet cool |
Benchmarking | Benchmarking the Pi 5 against an Intel N100 mini PC |
Overclocking | Let's increase the clock speed of the BCM2712 SoC |
Power Consumption | Compare the power consumption of the Pi 5 with Intel Mini PCs |
2.5Gbps Networking | Improving the wired performance of the Pi 5 |
WiFi | Improve WiFi performance of the Pi 5 |
Desktop PC | Is the Pi 5 good value compared to an Intel N100 Mini PC? |
Configuration | |
raspi-config | Useful text-based tool to configure the Pi 5 |
PiGro | GUI tool that streamlines the process of managing the Pi 5 |
Increase Swap Memory Size | Increase the swap size from 512MB to 2GB |
ZRAM swapdrive | Simple script to use a ZRAM swapdrive instead of a swapfile |
Software | |
Installing Software | Different ways to install software on the Pi 5 |
df snap pollution | Replace df with dysk |
Ollama GUI | Running Large Language Models on the Pi 5 |
Many software articles are planned. Stay tuned! |
This way you don’t solve the pollution of snaps, but you only hide it by polluting your system even more with Rust and dysk.
Your blog would have been so much better if you had explained that you can display the list of installed snaps with the command: snap list
Next you can remove the snap packages one by one from this list with the command: sudo snap remove <package>
The core packages you need to remove in this order:
sudo snap remove snap-store
sudo snap remove gtk-common-themes
sudo snap remove gnome-42-2204/201
sudo snap remove core24
sudo snap remove core22
sudo snap remove core18
Get rid of the annoying /dev/loop mount points using the command:
sudo umount /var/snap
Getting rid of the whole snap stuff with this command:
sudo snap purge snapd
Your df view is now free of those annoying /dev/loop mountpoints and that without reinstalling rust and dysk which only camouflage it.
I disagree. You are missing the whole point of the article. Snaps can be very useful. Lots of users like them. The fact you obviously don’t is not relevant. Just removing snapd and all snaps is not a solution as we’re not here to dictate what people install on their system.
The Blog title is “Raspberry Pi 5 Desktop Mini PC: Avoid snap pollution”, and the whole Blog is about hiding the annoying /dev/loop mount points that the df command shows you. That is NOT avoiding snap pollution, it’s just hiding it.
I’m only pointing out a huge mistake in you Blog.
There’s no ‘huge mistake’. The point is that snap pollutes df output, not the system. That’s made crystal clear in the article if you read it.
At the same time, the article also explains how to install software with cargo. The amount of amazing Rust-based open source software is definitely worth introducing to newcomers to the Raspberry Pi 5.
I just installed dysk on my desktop. It makes the output so much clearer.
There are lots of other modern alternatives written in Rust such as exa (for ls), bat (for cat), fd (for find), sd (for sed), dust (for du), ripgrep (for grep) etc etc.