I've just upgraded to Fedora 15. I've used Bacula for backup for some years now, and it works fine. But now I've just run into a problem, probably because Bacula is now running as user bacula rather than as root.

My backup media is two USB disk drives (I keep one offsite and swap them over once a month or so). However Fedora auto-mounts the USB drive with its mount point owned by my UID with mode 700, presumably because I am logged in and this would be the Right Thing for most USB storage. However in this case it is not because Bacula can't access it.

If I understand the sequence of events correctly, udev creates the /dev/sdb and /dev/sdb1 device nodes, and these are then automounted by udisk (which is a Gnome component). It's udisk that decides what the mount parameters are.

What I want is for any disk labelled "BACKUP*" to be mounted with its mount point owned by bacula:bacula, mode 700. I think I need a custom udev rule file in /etc/udev/rules.d. I've read the udev(7) page and "Writing udev rules". Here is what I have come up with so far, in a file called "10-backup-disk.rules". It's being parsed by udev OK, but isn't working: the disk still winds up being owned by me. Can someone tell me what I am doing wrong?


KERNEL!="sd[a-z][0-9]", GOTO="backup-disk_auto_mount_end"
ENV{ID_FS_LABEL}!="BACKUP*", GOTO="backup-disk_auto_mount_end"

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

# Get disk label

# Global mount options
ACTION=="add", ENV{mount_options}="relatime,rw"
# Filesystem-specific mount options
ACTION=="add", ENV{mount_options}="$env{mount_options}"

# 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

I know nothing about udev, but since you're using Fedora 15 you can accomplish the same thing with systemd much more simply.

Assuming you have a USB drive labeled BACKUP_ONE, create the following file:



Note the filename must end in .mount and have a name that matches the mount point (in the Where= line of the unit file), with slashes (/) changed to dashes (-). For more information, see man systemd.unit.

Additionally, you can prevent it from mounting the drive until Bacula actually runs a backup (or you try to access the drive) by creating /etc/systemd/system/mnt-backup1.automount:


Repeat this for your other drive, and then run systemctl enable mnt-backup1.automount and systemctl daemon-reload to inform systemd of the changes. (I'd make sure they're unplugged at this time so it doesn't get confused.)

udisks will now defer to your systemd configuration and mount it with the options you defined.

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.