LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS (*)
User Name
Password
CentOS (*) This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices

Reply
 
Search this Thread
Old 07-18-2014, 02:03 PM   #1
dipanjan
Member
 
Registered: Jul 2008
Location: Calcutta, India
Distribution: redhat
Posts: 35

Rep: Reputation: 0
Question /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
 
Old 07-18-2014, 02:09 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,410
Blog Entries: 1

Rep: Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115
You also have to enable the rc-local service in systemd.
 
Old 07-18-2014, 02:25 PM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,650
Blog Entries: 2

Rep: Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095
Just out of curiosity, why not just add the mount to /etc/fstab (or better write a proper .mount file for it)?
 
Old 07-18-2014, 02:30 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, Ubuntu, SLES, CentOS
Posts: 1,790

Rep: Reputation: 324Reputation: 324Reputation: 324Reputation: 324
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.
 
Old 07-18-2014, 02:43 PM   #5
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,410
Blog Entries: 1

Rep: Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115
Use 'noauto'
 
Old 07-18-2014, 02:50 PM   #6
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, Ubuntu, SLES, CentOS
Posts: 1,790

Rep: Reputation: 324Reputation: 324Reputation: 324Reputation: 324
Yes, noauto can be used but I guess that will fail the purpose as then it has to be user,noauto.
 
Old 07-18-2014, 03:10 PM   #7
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,410
Blog Entries: 1

Rep: Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115Reputation: 1115
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.
 
Old 07-19-2014, 02:44 AM   #8
dipanjan
Member
 
Registered: Jul 2008
Location: Calcutta, India
Distribution: redhat
Posts: 35

Original Poster
Rep: Reputation: 0
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.
 
Old 07-19-2014, 11:23 PM   #9
sag47
Senior Member
 
Registered: Sep 2009
Location: Philly, PA
Distribution: Kubuntu x64, RHEL, Fedora Core, FreeBSD, Windows x64
Posts: 1,505
Blog Entries: 35

Rep: Reputation: 383Reputation: 383Reputation: 383Reputation: 383
Quote:
Originally Posted by T3RM1NVT0R View Post
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 11:26 PM.
 
Old 07-20-2014, 12:01 PM   #10
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,650
Blog Entries: 2

Rep: Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095
Quote:
Originally Posted by sag47 View Post
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.
 
Old 08-26-2014, 04:12 PM   #11
tonj
Member
 
Registered: Sep 2008
Posts: 263

Rep: Reputation: 22
@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....
 
Old 08-28-2014, 07:50 AM   #12
jensd
LQ Newbie
 
Registered: Jun 2014
Posts: 10

Rep: Reputation: Disabled
/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
Code:
/root/script.sh
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.
 
Old 08-28-2014, 09:11 AM   #13
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 4,197

Rep: Reputation: 642Reputation: 642Reputation: 642Reputation: 642Reputation: 642Reputation: 642
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 ?
 
Old 08-28-2014, 06:14 PM   #14
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,650
Blog Entries: 2

Rep: Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095
Quote:
Originally Posted by schneidz View Post
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 ?
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 06:15 PM.
 
3 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Local CentOS Repository sorvad Red Hat 4 11-04-2012 02:00 PM
Local repository on centos 5.4 callmanager Linux - Server 11 09-11-2012 06:46 AM
Centos: no local address available. JJX Linux - Server 3 09-07-2012 05:09 PM
[SOLVED] CentOS BIND Local DNS server samarudge Linux - Server 6 11-29-2010 11:33 AM
rc.local does not work - Centos Black187 Linux - Newbie 3 07-19-2009 02:49 PM


All times are GMT -5. The time now is 04:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration