You can use \x20 for space.
That is hex value for ASCII (and utf-8 encoded) space.
Or you can use the octal variant \040
.
So that would be (in fstab):
UUID=01CD72098BB21B70 /media/tusharmakkar08/Local\x20Disk1
# or
UUID=01CD72098BB21B70 /media/tusharmakkar08/Local\040Disk1
If you are not to familiar with ASCII fun install ascii
and:
ascii # decimal and hex view
ascii -o # octal view
Non the less I'd also recommend, like @TNW, changing the mount point to one without space. Generally makes things easier. You can also change the label
though that might affect other things if you have something configured to recognize it as it is.
Leverage udev to use the same device name
Instead of listing UUIDs in /etc/fstab
, you could list a device name, and set up udev to use the same device name for all of these devices. Put a line like this in a file in /etc/udev/rules.d
:
KERNEL=="sd*", ATTRS{serial}=="123456798", NAME="one_of_my_disks%n"
or
KERNEL=="sd*", ATTRS{serial}=="123456798", SYMLINK+="one_of_my_disks%n"
Run udevadm info -a -n sdb
to see what attributes of the disk (like ATTRS{serial}=="123456798"
in the example above) you can match against. Note that you can only use multiple attributes but they all have to be from the same section.
Then, in /etc/fstab
, use /dev/one_of_my_disks
as the block device.
If your disks have different layouts, this is more complicated. You can use auto
for the filesystem type; this should work most of the type. If you need different partition numbers or mount options, however, you'll need different fstab entries. You can work around that by editing fstab
on the fly through a script invoked by the udev entry, which will be executed when the disk is detected by the system. For example, use the following udev rule:
KERNEL=="sd*", ATTRS{serial}=="123456798", ENV{FSTAB4}="compress=lzo", NAME="one_of_my_disks%n", RUN+="/usr/local/sbin/fstab_update_my_disk"
and the following fstab_update_my_disk
script (untested):
#!/bin/sh
/usr/bin/sed -i -e '/^\/dev\/one_of_my_disks1/ s/\([^ \t][^ \t]*[ \t][ \t]*[^ \t][^ \t]*[ \t][ \t]*[^ \t][^ \t]*[ \t][ \t]*\)[^ \t][^ \t]*/\1'"$FSTAB4"'/'
Leverage udev to not care about the mount point
Another approach would be to keep separate fstab entries, with distinct device names and distinct mount points. But use a udev RUN
hook to update a symbolic link that points to the mount point.
KERNEL=="sd*", ATTRS{serial}=="123456798", RUN+="/bin/ln -snf /media/disk1 /media/one_of_my_disks"
Best Answer
I don't know anyway round this systemd restriction, as the mount point directory name is converted into a systemd filename. The simplest answer may be to remove the entries from the fstab and write a tiny script to do the mounts on demand:
Don't forget, after modifying
/etc/fstab
, to do asudo systemctl daemon-reload
to ensure systemd notices your changes.If you want to keep the entries in
/etc/fstab
you could use make the second mount point a symbolic link to the first, egln -s /media/strontium /media/strontium2
. When the mount is done the link is followed so it ends up on the directory as usual. You must add optionnoauto
to both lines in this case, else systemd will get confused and immediately unmount what it thinks is the first entry.Instead of a symbolic link you can instead use a real directory and then do a manual bind mount to mount that directory at the wanted place:
You must remember to umount this bind mount as well as the first mount.
In the past you could have added a udev rule to call mount explicitly when you see the UUID appear, eg in
/etc/udev/rules.d/92-my.rules
:but this doesn't work with recent systemd's, as it runs
udevd
in a separate mount namespace, so although it does the mount, you cannot see it. I don't yet know the reason for this namespace, but you can in principle override this feature by creating a file/etc/systemd/system/systemd-udevd.service
with the 2 linesIf you want something that is still automatic, then an alternative is to monitor the events from
udevd
concerning block devices and do an explicit mount. For example, run permanently: