ArchLinux
Install: sudo pacman -S udiskie
;
Start service: run udiskie &
manually when system startup,
or add "udiskie &" into ~/.xinitrc;
Now when you plug USB key into computer, it will be automount to /media folder.
Unmount USB disk
Create an executable script in /usr/local/bin:
$ cat /usr/local/bin/unmount
#!/bin/sh
# Global variables
TITLE="Unmount Utility"
COLUMNS=3 # TARGET,SOURCE,FSTYPE
#IFS=$'\n'
# Populate list of unmountable devices
deviceList=($(findmnt -Do TARGET,SOURCE,FSTYPE | grep -e "sd[b-z]"))
deviceCount=$((${#deviceList[@]} / $COLUMNS))
# Start of program output
echo $TITLE
# Display list of devices that can be unmounted
for ((device=0; device<${#deviceList[@]}; device+=COLUMNS))
do
printf "%4s) %-25s%-13s%-10s\n"\
"$(($device / $COLUMNS))"\
"${deviceList[$device]}"\
"${deviceList[$(($device + 1))]}"\
"${deviceList[$(($device + 2))]}"
done
printf "%4s) Exit\n" "x"
# Get input from user
read -p "Choose a menu option: " input
# Input validation
if [ "$input" = "X" ] || [ "$input" = "x" ]
then
echo "Exiting"
exit 0
fi
if (( $input>=0 )) && (( $input<$deviceCount ))
then
echo "Unmounting: ${deviceList[$(($input * $deviceCount))]}"
sudo umount "${deviceList[$(($input * $deviceCount))]}"
exit 0
else
echo "Invalid menu choice"
exit 1
fi
$ chmod 755 /usr/local/bin/unmount
Now when eject USB disk, run unmount
, and choose a menu item to eject.
See USB storage devices
for details. Or use udiskie-umount -a
to unmount it manually.
See man udiskie
for more information.
Mint
Install: sudo apt install udevil
;
Start service: run devmon
in dmenu when system startup,
or add "devmon &" into ~/.xsession;
After plug USB key into computer, it will be automount to /media folder.
If you do not startup devmon in background,
you can run devmon -a
to mount the USB key.
Run devmon -c
to unmount the USB key.
See man devmon
for more information.
Difference between .xinitrc and .xsession:
If you startup your system with display manager,
where you get a graphical login screen, it will read ~/.xsession.
In case of you startup your system without display manager and login to shell,
startup i3 (or other wm) with startx
,
then the xinit program will read ~/.xinitrc;
See What is “.xsession” for? for details.
See Arch boot process for how Getty manage login process in system boot process.