Mount from rc.local fails; how to do it properly?

Rody Oldenhuis

Here is my current /etc/rc.local:

#!/bin/sh -e

# Test 1
echo line1 > /home/myHome/rclog.txt

# the mount
mount /mnt/mediaDrive &> /home/myHome/mountlog.txt

# Test 2
echo line2 >> /home/myHome/rclog.txt

exit 0

The /mnt/mediaDrive is a noauto in fstab. It is a network share, hence the mount in rc.local.

The mount in the above script does not work at boot. After boot, the rclog.txt file contains both line1 and line2, and the mountlog.txt file is empty. This would indicate that all commands in the script were run successfully, however, the drive is not mounted.

Running sudo /etc/rc.local manually in a terminal does mount the network share.

There is nothing relevant in /var/syslog that I can see, and permissions for rc.local are 755. The relevant fstab entry:

//192.168.1.100/home  /mnt/mediaDrive  cifs  noauto,credentials=/home/myHome/.mediaCredentials,uid=myName,gid=myGroup  0  0

What's going on here?

Braiam

The problem must be that at boot time your network isn't available yet, and it's the reason why it mounts after boot. You must use another mechanisms to mount the device, like upstart. Example using upstart:

# mount CIFS share

start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]

pre-start script /bin/mount /mnt/mediaDrive
pre-stop script /bin/umount /mnt/mediaDrive

You can modify it to suit your needs. The file name must end with .conf and saved in the /etc/init directory.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Solaris and smf: how to do a rc.local shutdown with smf?

From Dev

mount fails from spawned process

From Dev

Piping echo into sendmail in rc.local fails

From Dev

LXC: How do I mount a folder from the host to the container?

From Dev

What does `printf` do in rc.local?

From Dev

Where is log file from rc.local?

From Dev

Where is log file from rc.local?

From Dev

how do I setup VisualGDB for Nucleo F091RC, for mbed local development?

From Dev

How to mount a local directory without root

From Dev

How to mount Local Disk as C: in Windows XP

From Dev

How to mount docker volume on gitlab local branch?

From Dev

How to run script in rc.local

From Dev

How to run rc.local as normal user?

From Dev

How to avoid rc.local been executed?

From Dev

How to mount partition from disk

From Dev

After upgrade, rc.local now gives su must be ran from a terminal in rc.local

From Dev

How do I mount logical volumes from a VG of hard disks taken from another computer?

From Dev

How do I properly read numbers from awt textfields?

From Java

How do you properly return multiple values from a promise?

From Dev

How do you properly order data from Firebase chronologically

From Dev

How do i parse Json data from openlibrary api? (properly)

From Dev

Vagrant fails to properly boot box after host reboot, causes mount errors

From Dev

What does foremost do that is different from mount?

From Dev

How I can properly auto-mount a drive using fstab?

From Dev

How to mount properly ntfs partition shared between linux and windows

From Dev

Do I *need* `exit 0` at the end of `rc.local`?

From Dev

angular 2 rc1 - how to properly use router

From Dev

Mac OS X Mavericks: How do I remove the quarantine flag from my Sparsebundle mount?

From Dev

How do I mount Nexus 7 to view files from command line

Related Related

  1. 1

    Solaris and smf: how to do a rc.local shutdown with smf?

  2. 2

    mount fails from spawned process

  3. 3

    Piping echo into sendmail in rc.local fails

  4. 4

    LXC: How do I mount a folder from the host to the container?

  5. 5

    What does `printf` do in rc.local?

  6. 6

    Where is log file from rc.local?

  7. 7

    Where is log file from rc.local?

  8. 8

    how do I setup VisualGDB for Nucleo F091RC, for mbed local development?

  9. 9

    How to mount a local directory without root

  10. 10

    How to mount Local Disk as C: in Windows XP

  11. 11

    How to mount docker volume on gitlab local branch?

  12. 12

    How to run script in rc.local

  13. 13

    How to run rc.local as normal user?

  14. 14

    How to avoid rc.local been executed?

  15. 15

    How to mount partition from disk

  16. 16

    After upgrade, rc.local now gives su must be ran from a terminal in rc.local

  17. 17

    How do I mount logical volumes from a VG of hard disks taken from another computer?

  18. 18

    How do I properly read numbers from awt textfields?

  19. 19

    How do you properly return multiple values from a promise?

  20. 20

    How do you properly order data from Firebase chronologically

  21. 21

    How do i parse Json data from openlibrary api? (properly)

  22. 22

    Vagrant fails to properly boot box after host reboot, causes mount errors

  23. 23

    What does foremost do that is different from mount?

  24. 24

    How I can properly auto-mount a drive using fstab?

  25. 25

    How to mount properly ntfs partition shared between linux and windows

  26. 26

    Do I *need* `exit 0` at the end of `rc.local`?

  27. 27

    angular 2 rc1 - how to properly use router

  28. 28

    Mac OS X Mavericks: How do I remove the quarantine flag from my Sparsebundle mount?

  29. 29

    How do I mount Nexus 7 to view files from command line

HotTag

Archive