CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
07-18-2014, 01:03 PM
|
#1
|
Member
Registered: Jul 2008
Location: Calcutta, India
Distribution: redhat
Posts: 36
Rep:
|
/etc/rc.local in CentOS 7
I want to mount .iso file after every booting of system. I know in centos-7 the /etc/rc.local file is not executable and need to change permission to run it like previous version. But i have made the changes but still after booting the .iso file is not mounted. Please advise.I have used the below command in rc.local file and make it executable.
mount -o loop /media/xxx-xxx.iso /mnt/dvd
|
|
|
07-18-2014, 01:09 PM
|
#2
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
You also have to enable the rc-local service in systemd.
|
|
|
07-18-2014, 01:25 PM
|
#3
|
Moderator
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
|
Just out of curiosity, why not just add the mount to /etc/fstab (or better write a proper .mount file for it)?
|
|
|
07-18-2014, 01:30 PM
|
#4
|
Senior Member
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385
|
Hi Tobi,
Actually I was about to suggest that but then I thought if by mistake he moves that iso file to somewhere else then with entry in /etc/fstab it will leave the system unbootable.
|
|
|
07-18-2014, 01:43 PM
|
#5
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
Use 'noauto'
|
|
|
07-18-2014, 01:50 PM
|
#6
|
Senior Member
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385
|
Yes, noauto can be used but I guess that will fail the purpose as then it has to be user,noauto.
|
|
|
07-18-2014, 02:10 PM
|
#7
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
Don't move the iso file? Make it immutable, and put the loop into the fstab file...
You can't have it both ways. Either the mount is permanent and it can go in fstab as-is, or it is temporary and likely to change and needs to be put in fstab with noauto.
|
|
|
07-19-2014, 01:44 AM
|
#8
|
Member
Registered: Jul 2008
Location: Calcutta, India
Distribution: redhat
Posts: 36
Original Poster
Rep:
|
Thanks guys.Actually I just want to play with new rc.local in centos-7.Yes I could put it in fstab but I really want it in rc.local to perform my some other experiment.
|
|
|
07-19-2014, 10:23 PM
|
#9
|
Senior Member
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
|
Quote:
Originally Posted by T3RM1NVT0R
Yes, noauto can be used but I guess that will fail the purpose as then it has to be user,noauto.
|
Actually, you can have noauto but use the root cron to still mount it. I do that with several of my very large filesystems (12TB) to avoid a fsck on reboot but allow for manual fsck.
@reboot alias for cron see "man 5 crontab"
Code:
@reboot /path/to/mount.sh
In my script I mount the drives and bounce the smb service as part of the start-up after all other things have loaded.
Last edited by sag47; 07-19-2014 at 10:26 PM.
|
|
|
07-20-2014, 11:01 AM
|
#10
|
Moderator
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
|
Quote:
Originally Posted by sag47
Actually, you can have noauto but use the root cron to still mount it. I do that with several of my very large filesystems (12TB) to avoid a fsck on reboot but allow for manual fsck.
@reboot alias for cron see "man 5 crontab"
Code:
@reboot /path/to/mount.sh
In my script I mount the drives and bounce the smb service as part of the start-up after all other things have loaded.
|
Are you referring to the fsck that happens based on the number of mounts that were done or the number of days since the last fsck run?
If so, there is no need for having scripts to handle those filesystems, you can simply use tune2fs to disable those fsck runs at boot, have a look at the -c and -i options.
|
|
|
08-26-2014, 03:12 PM
|
#11
|
Member
Registered: Sep 2008
Posts: 556
Rep:
|
@dipanjan did you ever solve this thing with rc.local in centos 7? I have the same problem, this thread goes nowhere, tia if you can share any solution you may have found....
|
|
|
08-28-2014, 06:50 AM
|
#12
|
LQ Newbie
Registered: Jun 2014
Posts: 13
Rep: 
|
/etc/rc.local or /etc/rc.d/rc.local are no longer executed by default due to systemd-changes. (as mentioned in the first post, but just to be sure)
to still use those, you need to make /etc/rc.d/rc.local executable:
Code:
chmod +x /etc/rc.d/rc.local
If the script is executable, it should be executed at boot when you add a line containing
to /etc/rc.local (which is a symlink to /etc/rc.d/rc.local)
to be sure that your script is executable, just do a chmod +x /root/scripts.sh
To debug your problem, it would be a good idea to redirect the output of the script (if there is any) to a logfile to be sure if the script has been executed or not.
|
|
|
08-28-2014, 08:11 AM
|
#13
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326
|
similar:
http://www.linuxquestions.org/questi...al-4175514081/
i have another frustration with fedora. why is it that if i put my thumb drive in /etc/fstab and i boot up with it unplugged, the machine will drop me in a minimal root shell ?
|
|
|
08-28-2014, 05:14 PM
|
#14
|
Moderator
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
|
Quote:
Originally Posted by schneidz
|
Because systemd bails out when you add incorrect definitions to your fstab. Filesystems that are not present every time have to get either the general "noauto" mount option or the systemd specific "nofail" mount option (which states that the filesystem is only "wanted", but not "required"). Having none of them in an entry in an entry of fstab means that this filesystem is considered to be present at boot. If such a filesystem is not present this is a non-recoverable error and the system rightfully drops to a shell, so that the admin can fix the situation, instead of trying to boot a system to a possibly inconsistent state.
More info on systemd mount options here: http://www.freedesktop.org/software/...emd.mount.html
Last edited by TobiSGD; 08-28-2014 at 05:15 PM.
|
|
3 members found this post helpful.
|
All times are GMT -5. The time now is 03:08 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|