Ask Your Question

How to run a bash script at startup in Fedora 22 [closed]

asked 2015-10-14 10:09:35 -0500

barastyr gravatar image

I am running Fedora 22 in dual boot with Windows 7. I wrote a script to mount the Windows partition at /win/ and link the Documents folder from Windows in my home folder. This is the script:


sudo mount /dev/sda2 /win/
ln -s /win/Users/name/Documents / /home/name/Documents

I have put the script in /etc/init.d/ and run chmod a+x but it does not run when I reboot. The script runs fine when I start it manually. Am I doing something wrong?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by barastyr
close date 2015-10-16 10:07:05.328185

2 Answers

Sort by ยป oldest newest most voted

answered 2015-10-14 13:08:46 -0500

sideburns gravatar image

Two comments: first, as this script is being run by root, using sudo is redundant. Second, you're doing things the hard way. Just add the appropriate line to /etc/fstab, and it gets mounted along with everything else.

edit flag offensive delete link more


Agreed - you shouldn't mount on on /dv/sdxx anyway - it's subject to change depending on boot order, speed and a number of other factors. You should specify a mount point in fstab as suggested above using the UDID of the drive. For reference though if you wanted something to run at startup put it in /etc/rc.d/rc.local and then start the daemon with systemctl start rc-local.

dcrdev gravatar imagedcrdev ( 2015-10-14 15:45:48 -0500 )edit

My understanding is that rc-local service always runs if /etc/rc.d/rc.local exists. However, what you want to run (as root) to be sure is systemctl enable rc-local because that makes it run at boot, instead of just starting it the one time. And yes, I agree, it's best to use the UUID because it won't change from one boot to another.

sideburns gravatar imagesideburns ( 2015-10-14 20:05:03 -0500 )edit

Thanks for the help. The fstab solution worked, and the background info was useful.

barastyr gravatar imagebarastyr ( 2015-10-16 10:06:50 -0500 )edit

answered 2015-10-14 11:48:23 -0500

richk gravatar image

the script is missing path. it dosen't know where sudo mount and ln reside. when you tried the script in the terminal; you use your path settings.


edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-10-14 10:09:35 -0500

Seen: 2,351 times

Last updated: Oct 14 '15