Ask Your Question
2

how do I mount nas to folder on startup in fedora20?

asked 2014-08-05 07:24:13 -0600

sonicfishcake gravatar image

updated 2014-08-05 20:57:07 -0600

abadrinath gravatar image

Every time I start up I have to open a terminal and do the following to access my nas drive in the folders I've created.

$su

mount -o username=me,password=** //192.168.0.9/personal /mnt/personal

mount -o username=me,password=** //192.168.0.9/Drive /mnt/Drive

How do I get fedora 20 to do this automatically on logon?

(new user from Windows trying to learn)!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-08-05 09:27:12 -0600

NickTux gravatar image

updated 2014-08-06 10:04:17 -0600

If the commands you indicated, are working, you can add them to an autostart script, so they will be executed at every boot (or reboot), of the system.

Create the service file

sudo gedit /etc/systemd/system/automount-nas.service

the contents of this file should be

[Unit]
Description=automount nas at boot
After=NetworkManager.service

[Service]
Type=oneshot
ExecStart=/usr/bin/nas-auto.sh

[Install]
WantedBy=multi-user.target

Create the script

sudo gedit /usr/bin/nas-auto.sh

The contents of the script should be the commands you execute in order to mount the nas drives.

eg

#!/bin/bash
sleep 5
mount -o username=me,password=** //192.168.0.9/personal /mnt/personal
sleep 5
mount -o username=me,password=** //192.168.0.9/Drive /mnt/Drive
exit 0

Of course the mountpoints should be exist (/mnt/personal and /mnt/Drive). If not, create them.

Make the script executable

sudo chmod 755 /usr/bin/nas-auto.sh

and enable the systemd service

sudo systemctl enable automount-nas.service

Reboot the system and see the results.

edit flag offensive delete link more

Comments

Excellent. Thanks for the walkthrough!

sonicfishcake gravatar imagesonicfishcake ( 2014-08-05 09:42:13 -0600 )edit

typo: wokring

abadrinath gravatar imageabadrinath ( 2014-08-05 20:56:38 -0600 )edit
1

Also, you can create an autostart script for your user only (please note: it says logon not during system boot). Init scripts, desktop files, autostart scripts for system and user might also work. BTW, what is the sleep 5 for.

abadrinath gravatar imageabadrinath ( 2014-08-05 20:59:50 -0600 )edit

What about a mount unit, described in man systemd.mount ?

randomuser gravatar imagerandomuser ( 2014-08-06 01:24:33 -0600 )edit

I think the sleep 5 delays the startup slightly by 5 seconds for the system to start up other things first? I think this because when I first did it the first folder didnt mount but the second one did so I changed the value to sleep 10 for the first folder and it cured it. it's nice all this experimenting lol!

sonicfishcake gravatar imagesonicfishcake ( 2014-08-06 08:47:42 -0600 )edit

Question Tools

Stats

Asked: 2014-08-05 07:24:13 -0600

Seen: 2,619 times

Last updated: Aug 06 '14