We have a device (actually two of them) running Debian 8.4, largely preconfigured by the vendor. There is a slot for an SD card, which (if present) is automatically mounted at boot.

Question is: after I manually unmount the card in order to fsck it, how can I mount it again? I can manually mount it again, but since it was mounted automatically at boot, it seems to me there should be a way to make the system mount it the same way again. I can simply reboot the system, but that doesn't seem an optimal solution.

Since systemctl | grep mmc includes this:

media-sd\x2dmmcblk0p1.mount          loaded active mounted   /media/sd-mmcblk0p1

it seems to me it was systemd that mounts the card at boot. But after umount that entry disappears. Systemd still is largely a mystery to me, so that knowledge doesn't help me much.

Edit: I forgot to say: there's nothing about the SD card in /etc/fstab

Edit: After boot, systemctl status 'media-sd\x2dmmcblk0p1.mount' says:

? media-sd\x2dmmcblk0p1.mount - /media/sd-mmcblk0p1
   Loaded: loaded (/proc/self/mountinfo)
   Active: active (mounted) since Fri 2016-04-15 11:47:52 UTC; 3h 2min ago
    Where: /media/sd-mmcblk0p1
     What: /dev/mmcblk0p1

After umount, it says:

? media-sd\x2dmmcblk0p1.mount
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

systemctl cat 'media-sd\x2dmmcblk0p1.mount' says nothing in both cases.

  • You should check /etc/fstab as this might be read by systemd and you can try to investigate what systemd knows about this mount point by using systemctl. For example systemctl status 'media-sd\x2dmmcblk0p1.mount' or systemctl cat 'media-sd\x2dmmcblk0p1.mount'. Maybe that provides some insight. – Lucas Apr 15 '16 at 14:41
  • @Lucas: Thanks for your comment; I edited my answer to add the output of systemctl status and systemctl cat. – Roel Schroeven Apr 15 '16 at 14:56

I think I found it.

Contrary to what I first thought, the SD card is mounted at boot by udev, not by systemd. It turns out there's a rule /etc/udev/rules.d/11-media-by-label-auto-mount.rules containing:

KERNEL!="mmcblk[0-9]p[0-9]", GOTO="media_by_label_auto_mount_end"
# Import FS infos
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}="sd-%k"
# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"
# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"
# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"
# Exit

So I can mount the SD card with something like:

sudo udevadm trigger -c add -y "mmcblk*"

Still a bit cryptic for something simple (I think), but it works.

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.