6

If I put a USB-drive in, it will automount. I can see it with lsblk

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb      8:16   1   7,5G  0 disk 
└─sdb1   8:17   1   7,5G  0 part /media/user/usb-drive

If I unmount it with umount

umount /media/user/sdb1

it will still be visible with lsblk, but not mounted any more:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb      8:16   1   7,5G  0 disk 
└─sdb1   8:17   1   7,5G  0 part

but if I instead eject it by clicking the eject icon in Thunar (xfce file manager), it will disappear from the list in lsblk. Why is that so?

PetaspeedBeaver
  • 1,207
  • 3
  • 15
  • 32
  • 1
    [_By ejecting the device, you effectively disable any further access to the device. Only a reset of the USB subsystem (e.g. a reboot) will reload the device. Otherwise, you must physically disconnect the USB device and reconnect it in order to access it again._](https://unix.stackexchange.com/a/83587) – don_crissti Sep 28 '17 at 12:13
  • For sake of linking my thread to yours: I had the same question as yours [here (duplicate)](https://unix.stackexchange.com/questions/396126/unwanted-permanent-umount). – patryk.beza Oct 04 '17 at 20:02

1 Answers1

6

Mounting just means "set up the operating system to actively use the some (part of) a block device". Often there is some "busy" or "dirty" on the superblock that gets changed when a file system is mounted, but otherwise the hardware is unaffected.

OTOH, eject sends a SCSI "START STOP" command to the device, with option "eject" set. The USB controller in a flash ROM stick usually reacts by powering down the device and preventing any further interaction. That means it disappears completely from the USB subsystem, and must be re-enumerated to be able to accessed again.

The same command when send e.g. to a CD/DVD drive will eject the disk, and the also existing "load" option of the "START STOP" command will load it again. But this interpretation only applies to devices with removable media.

BTW, you can also send this SCSI command from the commandline using eject from the package with the same name, or with sg_start from the package sg3-utils.

dirkt
  • 31,679
  • 3
  • 40
  • 73
  • 1
    @PetaspeedBeaver: you can see it physically on many devices: umount will just save data, but the LED on device is still on (e.g. on many USB pen drives). Eject will power off the device, so also the LED. – Giacomo Catenazzi Sep 28 '17 at 12:39
  • 1
    You can also use `sg_start -s /dev/sdX` to start the device again, so you won't have to manually plug it back in or reboot the system. See also [this question](https://unix.stackexchange.com/questions/422880/how-do-i-plug-in-a-usb-drive). – Yeti Feb 09 '18 at 12:03