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
/etc/fstab
, so the drive will be auto mounted until you unmount it manually. Additionally, if you want to be sure, it even mounts if it failed to mount read-write (due to an unclean unmount in windows before) you can use this script to remount it readonly then: askubuntu.com/questions/424913