4

I need to mount directory from another HDD to my current home directory. I can do it by following command and it works properly:

sudo mount --bind /media/username/HDD3TB/'Мои документы'/Фото /home/username/Pictures/HDD_Photo

But I want it to mount automatically during system initialization. I have tried to add the entry below to /etc/fstab:

/media/username/HDD3TB/'Мои документы'/Фото /home/username/Pictures/HDD_Photo none bind 0 0

But this way does not work and it entails errors in time of system initialization.

enter image description here

In journalctl I have found out the following error messages:

kernel: ACPI Error: [\_SB_.PCI0.XHC_.RHUB.HS11] Namespace lookup failure, AE_NOT_FOUND (20170831/dswload-210)
kernel: ACPI Exception: AE_NOT_FOUND, During name lookup/catalog (20170831/psobject-253)
kernel: ACPI Exception: AE_NOT_FOUND, (SSDT:xh_rvp08) while loading table (20170831/tbxfload-228)
kernel: ACPI Error: 1 table load failures, 5 successful (20170831/tbxfload-246)
kernel: clocksource: hpet: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635855245 ns

and

-- The start-up result is RESULT.
июн 30 20:03:24 elementaryOS systemd-remount-fs[448]: mount: /etc/fstab: parse error at line 19 -- ignored
июн 30 20:03:24 elementaryOS systemd[1]: Started Remount Root and Kernel File Systems.
-- Subject: Unit systemd-remount-fs.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit systemd-remount-fs.service has finished starting up.

...

-- The start-up result is RESULT.
июн 30 20:03:32 elementaryOS systemd-fsck[1055]: fsck: /etc/fstab: parse error at line 19 -- ignored
июн 30 20:03:32 elementaryOS systemd[1]: Started File System Check Daemon to report status.
-- Subject: Unit systemd-fsckd.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support

...

-- Unit systemd-fsck@dev-disk-by\x2duuid-4e02e814\x2d86be\x2d4995\x2d9989\x2dbe965304d5ea.service has begun starting up.
июн 30 20:03:32 elementaryOS systemd-fsck[1078]: fsck: /etc/fstab: parse error at line 19 -- ignored
июн 30 20:03:32 elementaryOS systemd[1]: Found device ST1000DM003-9YN162 1.
-- Subject: Unit dev-disk-by\x2duuid-c6e31fc0\x2d90ae\x2d48c3\x2dba37\x2db124bffc57f3.device has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit dev-disk-by\x2duuid-c6e31fc0\x2d90ae\x2d48c3\x2dba37\x2db124bffc57f3.device has finished starting up.

Can I use spaces and cyrillic symbols in path? Or maybe I should use another way to auto mount this directory?

5
  • Please edit the question and include the error. Thanks!
    – mchid
    Jun 26, 2019 at 0:23
  • @mchid sorry, but my question is not so much about the error as about the possibility of using spaces and Cyrillic symbols in /etc/fstab. As for the error, I have edited /etc/fstab again and execute "mount -a" command, the following error appeared: mount: /etc/fstab: parse error at line 19 -- ignored Jun 26, 2019 at 17:51
  • @mchid I have edited my question and added original errors. Also I have tried to use \040 and specify filesystem. In this time I have not entered in emergency mode, but result was unsuccessful with the same errors. As I noticed while editing a /etc/fstab file in vim, Cyrillic characters are highlighted in red. Jun 30, 2019 at 18:12
  • Regarding the spaces see stackoverflow.com/questions/15316017/…
    – mook765
    Jun 30, 2019 at 20:06
  • Thanks for the error! I have found an answer that should work for you and this answer uses systemd instead of fstab. Please post any errors and don't forget to delete line 19 from /etc/fstab. Thanks!
    – mchid
    Jul 1, 2019 at 6:33

1 Answer 1

3

You don't need to use /etc/fstab/ and you can create the following systemd service to mount the file instead.

I adapted: this answer written by user: @detuur to fit this particular situation.

Create a new file using: sudo vim /etc/systemd/system/boot-shadow-mount.service and then copy and paste the following and then save the file and exit vim

# Automatically mounts and binds HDD3TB directory to /Pictures/HDD_Photo
# 

[Unit]
Description=bind mount HDD3TB drive directory to /Pictures/HDD_Photo
Requires=bindmount@home-username-Pictures-HDD_Photo.mount
Conflicts=umount.target

[Service]
Type=oneshot
ExecStart=/bin/mount --bind /media/username/HDD3TB/'Мои документы'/Фото /home/username/Pictures/HDD_Photo

ExecStop=/bin/umount /home/username/Pictures/HDD_Photo
RemainAfterExit=True

[Install]
RequiredBy=local-fs.target unattended-upgrades.service

Next, run the following command to correct the "username" in the file:

sudo sed -i "s/username/$USER/g" /etc/systemd/system/boot-shadow-mount.service

Then, run the following commands to "enable" the new service so that the service will automatically start when you boot the system:

sudo systemctl daemon-reload
sudo systemctl enable boot-shadow-mount

When you reboot, the file should automatically mount.

Please post any errors. Thanks!

additional source: blog.iwakd.de/systemd-fstab-and-bind-mounts-with-options

1

You must log in to answer this question.

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