5

When I press "safely remove drive" in Nautilus as user to my USB 3.0 Transcent Storejet 25H3 drive it reconnects immediately.

How can I safely remove it without that behaviour?

I think the only solution is to disable the automounting in Ubuntu. I did that now with: How to disable automount in nautilus's preferences

But it is a shame, cause now my external music library doesn't automount anymore.

Isn't there a solution where harddisks don't remount on safely remove?!

4
5

Valid for this Ubuntu at least:

$ lsb_release -d  
Description:    Ubuntu 14.04.1 LTS


I have found that:

$ udisksctl mount --block-device /dev/$device

... will mount /dev/xxx in the same style as automount,
that is - in /media/$USER/Disk_Label-or-UUID/ with the last level dir auto-created.

$ udisksctl unmount --block-device /dev/$device;  

... will umount the above, but not '-eject' memory card/USB reader content.

$ gvfs-mount --eject "file:///media/$USER/DISK_LABEL"  

... lastly appears to be equal to 'Safely remove' or 'Eject' - and that WITHOUT an immediate re-mount.

Note: $ udisksctl power-off --block-device /dev/$device;
... would otherwise be a 'natural' option, but is hampered by an immediate re-mount.


EDIT --- you could use this script to "umount all" without having to dig out the names:

#! /bin/bash
#
for device in $(mount | grep "/media/$USER/" | cut -d" " -f1); do
        echo Unmounting $device 
        udisksctl unmount --block-device $device
done

if you prefer eject, change the -f1 into -f3 in the cut command and the line with udiskctl with

gvfs-mount --eject "file://$device"

(I think --- you can have problem with correctly quoting labels with blanks in it; and you'll have warnings if the device has multiple partitions mounted).



$ lsblk

... will display all the available block devices (except ram disks, no sudo required).
RAM and loop --> lsblk --all .



How do I "automount" a labelled disk?

Bring up the Dash (hit the 'Super' key) and type 'startup appl' and 'Startup Applications' should appear, click on it. Click Add and type anything you want in 'Name' and 'Comment' fields. Then fill in 'Command' with your version of:

/bin/bash -c '/bin/sleep 5 && /usr/bin/udisksctl mount -b /dev/disk/by-label/GreenWD_3TB'

... where /dev/disk/by-label/GreenWD_3TB is anything suitable you find from
the display of ls -lR /dev/disk/* | less



More:
How to access gvfs mounts from command line?
How to mount drive in /media/userName/ like nautilus does using udisks

5
  • gvfs-mount --eject doesn't work as "Safely Remove" for me on the same 14.04.1 LTS. It just unmouts and keeps harddisk spinning. Error ejecting mount: Error ejecting /dev/sdc: Command-line 'eject "/dev/sdc"' exited with non-zero exit status 1: eject: unable to eject, last error: Invalid argument. It seems a bug. – AliN Oct 18 '14 at 17:56
  • Please check above again; you cannot use /dev/sdc with gvfs-mount . – Hannu Oct 23 '14 at 19:16
  • Yeah, I see, the error uses this way to mention the drive. – AliN Oct 23 '14 at 22:51
  • @Hannu I added a script to the answer --- I hope you don't mind. – Rmano Oct 17 '15 at 10:49
  • 1
    Well, does not seem directly related to answering the Q - but might be useful for someone. – Hannu Oct 17 '15 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.