2

I have a broken lxd installation and want to completely delete it and start over, but there's a problem. /var/lib/lxd/devices/desktop contains a bunch of subdirs that are linked to directories elsewhere in the filesystem (even on different drives) such as

drwxr-xr-x 28 karl   karl       4096 Apr 11 15:40 disk.shareName.home-karl
drwxr-xr-x  4 nobody nogroup    4096 Apr 14 12:07 disk.thor.mnt-thor
drwxr-xr-x  2 root   root       4096 Mar 29 14:02 disk.usbdrive.mnt-usbdrive

For example, if I delete a file from disk.thor.mnt-thor, it also gets deleted from /home/storage (both directories point to the same place). disk.usbdrive.mnt-usbdrive shows all contents of my usb drive mounted to /mnt/usbdrive. Both directories show its contents, and modifications in one are reflected in the other.

But now if I want to delete these directories, I have a problem, because I just want to remove those directories under lxd, not the actual directories they point to and not their contents. I tried using unlink, but it doesn't work on directories.

1
  • If they were hardlinks, rm would just remove the link, and the link reference count on the destination would decrease by one.
    – tripleee
    Apr 14, 2018 at 12:25

1 Answer 1

1

Try umount-ing them.

The VFS layer in Linux allows files and directories to be "bind-mounted" to another location. The result indeed looks like a hardlink, but doesn't actually exist on disk – bind mounts are in-memory just like regular mounts are.

This feature also means that a single filesystem can be mounted on several places at once. For example, the same /dev/sda1 could be mounted at /mnt/usbdrive and on /var/lib/lxd/mnt-usbdrive.

All such magic mounts can be seen by running findmnt or mount.

(Windows and FreeBSD have similar features as well, e.g. nullfs.)

You must log in to answer this question.

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