1

I use udisks --detach /dev/sdb for safely remove my hard disk. This command works like safely remove menu in nautilus when you right click on an external HDD. The problem is, after 2 sec hard drive automatically mounted and nautilus window pops up.

I know udev manage this kernel events, so I search a command to monitor those events. This is output of udevadm monitor --udev.

UDEV  [67744.241650] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7/target7:0:0/7:0:0:0/bsg/7:0:0:0 (bsg)
UDEV  [67744.242272] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7/target7:0:0/7:0:0:0/scsi_device/7:0:0:0 (scsi_device)
UDEV  [67744.242308] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7/target7:0:0/7:0:0:0/scsi_disk/7:0:0:0 (scsi_disk)
UDEV  [67744.243365] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7/target7:0:0/7:0:0:0/scsi_generic/sg2 (scsi_generic)
UDEV  [67744.243399] remove   /devices/virtual/bdi/8:16 (bdi)
UDEV  [67744.243545] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7/target7:0:0/7:0:0:0/block/sdb/sdb1 (block)
UDEV  [67744.248425] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7/target7:0:0/7:0:0:1/bsg/7:0:0:1 (bsg)
UDEV  [67744.248520] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7/target7:0:0/7:0:0:0/block/sdb (block)
UDEV  [67744.248566] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7/target7:0:0/7:0:0:0 (scsi)
UDEV  [67744.248596] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7/target7:0:0/7:0:0:1/enclosure/7:0:0:1 (enclosure)
UDEV  [67744.248625] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7/target7:0:0/7:0:0:1/scsi_device/7:0:0:1 (scsi_device)
UDEV  [67744.248660] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7/target7:0:0/7:0:0:1/scsi_generic/sg3 (scsi_generic)
UDEV  [67744.248689] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7/scsi_host/host7 (scsi_host)
UDEV  [67744.252526] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7/target7:0:0/7:0:0:1 (scsi)
UDEV  [67744.252563] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7/target7:0:0 (scsi)
UDEV  [67744.252594] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host7 (scsi)
UDEV  [67744.317378] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0 (usb)
UDEV  [67744.339889] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3 (usb)
UDEV  [67751.203840] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3 (usb)
UDEV  [67751.205913] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0 (usb)
UDEV  [67751.207203] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host8 (scsi)
UDEV  [67751.208287] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host8/scsi_host/host8 (scsi_host)
UDEV  [67752.183035] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host8/target8:0:0 (scsi)
UDEV  [67752.183988] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host8/target8:0:0/8:0:0:0 (scsi)
UDEV  [67752.184022] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host8/target8:0:0/8:0:0:1 (scsi)
UDEV  [67752.184944] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host8/target8:0:0/8:0:0:0/scsi_device/8:0:0:0 (scsi_device)
UDEV  [67752.184959] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host8/target8:0:0/8:0:0:1/scsi_device/8:0:0:1 (scsi_device)
UDEV  [67752.185348] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host8/target8:0:0/8:0:0:0/scsi_generic/sg2 (scsi_generic)
UDEV  [67752.185365] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host8/target8:0:0/8:0:0:1/scsi_generic/sg3 (scsi_generic)
UDEV  [67752.185381] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host8/target8:0:0/8:0:0:0/bsg/8:0:0:0 (bsg)
UDEV  [67752.185392] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host8/target8:0:0/8:0:0:0/scsi_disk/8:0:0:0 (scsi_disk)
UDEV  [67755.138374] add      /devices/virtual/bdi/8:16 (bdi)
UDEV  [67755.140810] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.

As you see, HDD detach from system and after that come back to system again. Kernel add this device after i removed it.

I do not want to get HDD come back. I want to set the external HDD to shut down mode.

Any command, script, and idea appreciated.

1 Answer 1

0

A usb device is supposed to be plug and play. So after you detach it it will attach again unless you pull the plug. That is the whole idea behind plug and play isn't it?.

If you are not using the HDD you should unmount /dev/sdb. The device itself will remain detected but no IO operations will occur as it is not mounted.

1
  • When i detached a USB flash, it will not attach unless it is unplugged and plugged physically.
    – soroosh
    Apr 17, 2013 at 13:41

You must log in to answer this question.

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