Why are all snaps being mounted and listed as block devices or partitions for Ubuntu 18.04?
When you type the command
snap list
you will get the output of actual installed snap packages. The reason is when a snap package is updated, the old version is kept (see snapcraft docu).
Citate from snapcraft docu
Garbage collection then removes and purges any snap files, and their writable areas, for snap versions prior to the one that has just been updated — meaning that, at most, two versions of a snap will be present on the system. This saves disk space without compromising the ability to revert the snap to a previous known-good state.
Explicitly removing a snap from your system will also remove the code and purge the data for all prior versions.
For instance you have got installed more than one versions of gnome-calculator.
In case you only need the newest version, you can use
sudo snap remove gnome-calculator --revision <verison to be placed>
Using the command
losetup -a
shows you the mounted snaps (loop devices)
If you want to delete the double ones, type
sudo losetup -d /dev/loop<loopnumber>
It seems to be an error of the snap code, since all older been kept in the /var/lib/snapd/snaps file.
From the content in your question, your problem is about searching for a way to have control over what you're seeing when you try to view your block devices than how snap uses block devices for its operation.
I agree with your referenced distinction between fdisk -l
and parted -l
. While fdisk shows a very good detailed output of block devices, it shows too many other things that distract from what you're trying to see.
Resolution
You can use filter the lsblk formatted output. This works well to give a clean output like what you get with gnome-disk-utility.
$ lsblk -o name,mountpoint,label,size,fstype,uuid | egrep -v "^loop"
Or as you indicated in your question:
$ sudo parted -l
For the df
command in your question, use:
$ df | egrep -v /dev/loop
I find this annoying too. It seems if they are not running they should not be mounted or listed. You can run this command to exclude all the loop devices.
$ lsblk -e 7