10

I've a lot of partitions named loop they're likely created by a snap app called Anbox, I could care less about lopp0 to loop4 but the partition named loop5 which is mounted at /media/sumeet/disk appears in nautilus

Nautilus screenshot 326mb volume is the loop partition is question

when I opened this partition I found that I don't have the permission to open most of the folders inside it.


output of lsblk

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0    7:0    0 341.2M  0 loop /snap/anbox/16
loop1    7:1    0     4K  0 loop /snap/anbox-installer/11
loop2    7:2    0     4K  0 loop /snap/anbox-installer/12
loop3    7:3    0  78.4M  0 loop /snap/core/1577
loop4    7:4    0  79.5M  0 loop /snap/core/1689
loop5    7:5    0 310.8M  1 loop /media/sumeet/disk
sda      8:0    0 111.8G  0 disk 
├─sda1   8:1    0   7.6G  0 part [SWAP]
├─sda2   8:2    0     1K  0 part 
├─sda5   8:5    0  19.1G  0 part /
└─sda6   8:6    0  85.1G  0 part /home
sdb      8:16   0   1.8T  0 disk 
├─sdb1   8:17   0   220G  0 part /media/sumeet/Stuff
├─sdb2   8:18   0   220G  0 part /media/sumeet/Movies
├─sdb3   8:19   0   710G  0 part /media/sumeet/Hollywood
└─sdb4   8:20   0   713G  0 part /media/sumeet/Series

output of ls /media/sumeet/disk

acct           etc                   init.zygote32.rc     selinux_version
anbox-init.sh  file_contexts.bin     init.zygote64_32.rc  sepolicy
cache          fstab.goldfish        mnt                  service_contexts
charger        init                  oem                  storage
config         init.environ.rc       proc                 sys
d              init.goldfish.rc      property_contexts    system
data           init.rc               sbin                 ueventd.goldfish.rc
default.prop   init.usb.configfs.rc  sdcard               ueventd.rc
dev            init.usb.rc           seapp_contexts       vendor

How can I hide loop5 from being visible in nautilus?

5
  • 1
    I don't think you can "delete" these loop devices without breaking your snap application. And the loop5 one looks as if this is the internal memory of your emulated Android device.
    – Byte Commander
    May 6, 2017 at 17:32
  • @ByteCommander I think so too, but I do not have permission to make changes in it. Can I at least hide it? May 6, 2017 at 17:34
  • See stackoverflow.com/questions/11092601/…, maybe that does help to hide it in Nautilus?
    – Byte Commander
    May 6, 2017 at 18:02
  • @ByteCommander seems a bit confusing, reading it. May 6, 2017 at 18:04
  • 1
    I have no direct answer, but be aware that these are not partitions; these are loopback devices, which are normally used to mount files as if they were partitions. I point this out so that you don't go on a wild goose chase looking for new partitions on your disk.
    – Rod Smith
    May 6, 2017 at 22:26

4 Answers 4

10
+50

The easiest way to do this would be to do it with GUI

  • Go to disk app (through Unity Dash or terminal with gnome-disks command)
  • Choose your partition (that would be loop5)
  • Click the little gear icon Gear icon
  • Select Edit mount options
  • Toggle Show in User Interface to Off

It'll stop showing the partition in Nautilus but will not affect Anbox in any way

2
  • That simple? now i'm regretting that I started a bounty on this one ;p May 17, 2017 at 10:08
  • I'm half a mind to take that bounty May 17, 2017 at 14:26
1

I am using Ubuntu 16.04.3 LTS,

It is a fresh install, with all updates done, for some reason the above solution doesn't work.

Toggle Show in User Interface to Off in the disks application did not work, nautilus still showed the partition after mount -a and even a reboot.

I fixed it by adding x-gvfs-hide in /etc/fstab, like this

UUID=123-some-number-s /home/user/special ext4 defaults,x-gvfs-hide 0 0

after this the partition is mounted properly but hidden in nautilus.

Let me know if there is a better solution.

1

Detaching with losetup

my case is:

the phenomenon

  • snapd's loopN file residual in nautilus left panel
    // maybe by some accident

  • disks also show those loopN device, and they was marked auto clean
    // they may autoclean failed

losetup check

$ losetup -l -a | grep del
/dev/loop8   0  0  1  1 /var/lib/snapd/snaps/core20_1242.snap (deleted)  0   512
/dev/loop25  0  0  1  1 /var/lib/snapd/snaps/snapd_14066.snap (deleted)  0   512
/dev/loop4   0  0  1  1 /var/lib/snapd/snaps/snapd_14549.snap (deleted)  0   512

losetup detach

seems they are unused loop devices, and backing file was deleted.

try

losetup -v -d /dev/loop4

to detach it manually.
// it was lazy device destruction, may not destory immediately.

the do a reboot, they disappeared.
// if it's snap loop, directly reboot without those steps, it also gone..

one line command

for i in $(losetup --list --all | awk '/.snap \(deleted\)/ {print $1}'); do sudo losetup --verbose --detach "$i"; done
1
  • 1
    Nice find an investigation after so many years! I added a one liner with safer filtering for the matching devices based on your example. To anyone reading this feel free to contact me if you have problems reading this one liner. I tried to keep it short an precise.
    – LiveWireBT
    Apr 30 at 8:42
0

Note: After a few days I found out that yurenchen's answer is valid and you don't need to reboot, some deleted images will be released and won't show up anymore. So mix and match the answers as it fits your needs.

Hiding snap loop devices

You can hide Snapd's loop devices the same way through Gnomes Disks app. Since they are not identified by UUID you would at some point need to edit and clean up entries in /etc/fstab by hand if devices you expect to show up don't.

  • Go to disk app (through Dash or terminal with gnome-disks command)
  • Choose your partition (that would be loop5)
  • Click the little gear icon Gear icon
  • Select Edit mount options
  • Toggle Show in User Interface to Off and additionally add x-gvfs-hide to the mount options.

That will create the following entry in /etc/fstab:

/dev/loop5 /mnt/loop5 auto nosuid,nodev,nofail,x-gvfs-hide 0 0

If you have a few more you might want to use the terminal. Id did it like this:

$ losetup --list --all | awk '/.snap \(deleted\)/ {print $1}' | sort
/dev/loop12
/dev/loop17
/dev/loop2
/dev/loop22
/dev/loop23
/dev/loop28

Then I added the following entries to my fstab with vim, but you can use nano.:

# Snap
/dev/loop12 /mnt/loop12 auto nosuid,nodev,nofail,x-gvfs-hide 0 0
/dev/loop17 /mnt/loop17 auto nosuid,nodev,nofail,x-gvfs-hide 0 0
/dev/loop2 /mnt/loop2 auto nosuid,nodev,nofail,x-gvfs-hide 0 0
/dev/loop22 /mnt/loop22 auto nosuid,nodev,nofail,x-gvfs-hide 0 0
/dev/loop23 /mnt/loop23 auto nosuid,nodev,nofail,x-gvfs-hide 0 0
/dev/loop28 /mnt/loop28 auto nosuid,nodev,nofail,x-gvfs-hide 0 0

As I said, this may have some side effects in the future. So always keep this in mind and document changes you make to you configuration files!

Notes

I tend to run some machines longer than other people and uncover a few more unexpected behaviors.

Snap is closely integrated into Ubuntu, so I disagree with the notion of removing it, but for some troubleshooting I had to and APT reported that there was still a lock on /var/snap

I checked with this command:

lsof 2>&1 | grep /var/snap | grep -v 'lsof: no pwd entry for UID'

Then I checked to processes (wow, didn't expect that cruft, but that explains to me why some applications felt really slow), and decided to kill the processes. Then I updated/added entries in /etc/fstab.

Since you have eventually been involved with removing Snap and you lost track of which packages were removed you should be able to find out about the details in these files:

less +G /var/log/apt/history.log
less +G /var/log/apt/term.log

Press q to close the invocation of less. If it was a few days ago you have too look into files with an additional number attached. At some point these logs are rotated and the information lost.

Okay, I guess I have everything written down what I wanted to tell you.

References and Links

https://superuser.com/a/1330590/252532

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .