-   Linux - Desktop (
-   -   Automounting usb drives in KDE? (

nokangaroo 06-10-2011 06:21 PM

Automounting usb drives in KDE?
I just installed KDE, because Lubuntu/Openbox is just too unstable (The panels crash all the time). I'll get used to KDE, especially as konsole does not automatically quote anything that's dragged into it, and gwibber and ubuntuone are not installed by default (Also, video works without fracture lines!).

So far, so good. But how do I automount usb drives in /media when booted from an external disk? I just noticed that /home (/dev/sdb5 in this case) is mounted in /media, where it has absolutely no business. This also means that my backup scripts won't work. How can I fix this?

nokangaroo 06-10-2011 06:50 PM

Solved - installed usbmount and copied the following udev rule, named 69-local.rules, to /etc/udev/rules.d:

# Leave sda to fstab
KERNEL!="sd[b-z]*", GOTO="media_by_label_auto_mount_end"
# If booted from /dev/sdb with home on /dev/sdb5:
# KERNEL!="sd[c-z]*", GOTO="media_by_label_auto_mount_end"
# KERNEL=="sdb5", GOTO="media_by_label_auto_mount_end"

# Handling only ext4 partitions; better leave this commented out
# ENV{ID_FS_TYPE}!="ext4", GOTO="media_by_label_auto_mount_end"

# Import FS info
IMPORT{program}="/sbin/blkid -o udev -p %N"

# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"

# Mount options
ACTION=="add", ENV{ID_FS_TYPE}=="ext3|ext4", ENV{mount_options}="rw,nodev,nosuid,relatime,acl,uhelper=udisks"
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="rw,relatime,utf8,gid=100,umask=002,uhelper=udisks"
ACTION=="add", ENV{ID_FS_TYPE}=="hfsplus", ENV{mount_options}="rw,nosuid,nodev,uhelper=udisks"

# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -t %E{ID_FS_TYPE} -o %E{mount_options} /dev/%k /media/%E{dir_name}"

# Clean up after removal
ACTION=="remove", RUN+="/bin/umount /dev/%k", RUN+="/bin/rmdir /media/%E{dir_name}"

# Exit

Many thanks to the archlinux people - found the original of this on

"Safely remove drive" will work with kde, but it did not work in GNOME.

All times are GMT -5. The time now is 10:00 AM.