Defina um disco rígido externo para desligar o modo

1

Eu uso udisks --detach /dev/sdb para remover com segurança meu disco rígido. Este comando funciona como remover com segurança o menu no nautilus quando você clica com o botão direito do mouse um disco rígido externo. O problema é que, após 2 segundos, o disco rígido é montado automaticamente e a janela do nautilus aparece.

Eu sei que udev gerencia esses eventos do kernel, então eu procuro um comando para monitorar esses eventos. Esta é a saída de 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.

Como você pode ver, o HDD se desconecta do sistema e depois disso volta ao sistema novamente. Kernel adiciona este dispositivo depois que eu o removi.

Eu não quero que o HDD volte. Eu quero definir o disco rígido externo para desligar o modo.

Qualquer comando, script e ideia são apreciados.

    
por soroosh 17.04.2013 / 14:30

1 resposta

0

Um dispositivo usb deve ser plug and play. Então, depois de soltá-lo, ele será conectado novamente, a menos que você puxe o plugue. Essa é a idéia por trás do plug and play, não é?

Se você não estiver usando o HDD, desmonte / dev / sdb. O dispositivo em si permanecerá detectado, mas nenhuma operação de E / S ocorrerá, pois não está montada.

    
por 17.04.2013 / 15:28