umount device or mount point?

1

1

Is there a more-correct way to unmount a device/filesystem/etc? Should I umount the device I originally mounted or the mount point?

mount /dev/sda1 /mnt/myusbstick
do stuff
umount /mnt/myusbstick

OR

umount /dev/sda1

tarabyte

Posted 2015-11-11T17:08:34.273

Reputation: 1 151

Answers

3

It doesn't matter which way you refer to the mount.

The only case where it makes a difference is when you have a device mounted to multiple mount points. In that case when you specify the device to the umount command, it'll unmount the most recently mounted mountpoint. Specifying a mountpoint will allow unmounting that specific mountpoint.

Vojtech

Posted 2015-11-11T17:08:34.273

Reputation: 934

3

On Linux, the recommended way (according to the util-linux maintainers)[citation neeed] is to use umount <mountpoint>, for several reasons:

  • The same device may be mounted on multiple locations, e.g. using bind mounts, btrfs subvolumes, or FUSE filesystems; you don't know which one would be unmounted first.

    (You can use umount --all-targets <device> though.)

  • A mount might have multiple backing devices, for filesystems such as btrfs, and umount won't necessarily understand all of them (as the mtab & mountinfo files only show one).

  • The backing device might be not what you think it is. For example, mount foo.iso /mnt will set up a loop device and mount that. (Though, luckily, umount foo.iso is also smart enough to look up the corresponding loop device.)

  • You can stack several mounts on the same location, with only the latest one being visible.

user1686

Posted 2015-11-11T17:08:34.273

Reputation: 283 655

and can you clarify which is the mount point? e.g a or b of mount a b? – tarabyte – 2015-11-12T17:34:33.000

The mountpoint is the directory, so b. – Tom Hale – 2017-09-05T10:34:48.303