Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I insert an SD card in the reader, slackware creates a mount point and mounts my card volumes. On unmounting the volumes, the mount point vanishes. How do I achieve this manually?

When I attempt to mount a volume using the mount command, the mount point folder must exist and the folder does not vanish on umount. Is there a way to create a mount point if it does not exist? and ensure that the folders vanish on umounting?

Can I do so with some switches and not write a complete script?

Thank you.

share|improve this question

migrated from Jun 19 '11 at 20:04

This question came from our site for professional and enthusiast programmers.

up vote 3 down vote accepted

In modern Linux systems the udev subsystem is responsible for sending events to some higher level program or subsystem that does this. Your distro has such a system, probly HAL. You could write a udev rule to do this yourself. For example the following achieves what you want in the context of adding and removing a backup drive:

# Auto mount the USB backup drive we attach. Theoretically should be done from HAL.
ACTION=="add", ENV{ID_FS_LABEL_ENC}=="backups", PROGRAM=""
ACTION=="remove", ENV{ID_FS_LABEL_ENC}=="backups", PROGRAM=""

# Auto mount the USB backup drive we attach. Theoretically should be done from HAL.
[[ -d $mnt_pt ]] || mkdir $mnt_pt && mount -L backups $mnt_pt &

umount $mnt_pt && rmdir $mnt_pt &
share|improve this answer

The simple answer is now, you can't. Slackware will be doing that by having higher level software that creates the directory before doing the mount and removes it after doing the unmount.

As there are no switches to the mount or unmount commands to do that for you, the only way to achieve the same thing from the command line would be to write scripts to wrap the commands and create and remove the directories as requires.

share|improve this answer
Thanks. I can see the higher level software creating the folder, but the folders vanish on umount which I run manually. So is there a demon checking for unmounts all the time? – Lord Loh. Jun 19 '11 at 20:40
Quite probably, yes. The software that created the folder and did the mount will watch for the unmount and remove the directory again regardless of who did the mount. – TomH Jun 19 '11 at 20:51

Create one folder in /media or /mnt or of your choice directories and then give the mount point like:

mount -t typeFilesystem(vfat/NTFS/EXT#) /media/sdcard
share|improve this answer
I think that only works if you have the entry in fstab and will it remove the mount point on umount? – Lord Loh. Jun 19 '11 at 20:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .