/etc/rc.local in CentOS 7

General support questions
Post Reply
gibsongilbert
Posts: 1
Joined: 2022/07/19 08:18:46

/etc/rc.local in CentOS 7

Post by gibsongilbert » 2022/07/19 08:26:46

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

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: /etc/rc.local in CentOS 7

Post by TrevorH » 2022/07/19 09:46:44

Why would you not use /etc/fstab to do this? e.g.

Code: Select all

/media/xxx-xxx.iso /mnt/dvd nofail,loop,ro 0 0
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: /etc/rc.local in CentOS 7

Post by jlehtone » 2022/07/20 09:15:47

The /etc/fstab is definitely the right spot.

I'd go a step towards fancy:

Code: Select all

/media/xxx-xxx.iso /mnt/dvd  vfat  ro,loop,nofail,noauto,x-systemd.automount,x-systemd.idle-timeout=300 0 0
Rather than mount at boot, systemd generates a unit that will automount the image when something actually accesses /mnt/dvd.
With the timeout option there will be umount after 5 unused minutes (but automounter will remount on need again).

What is the actual type of the image? I did set "vfat" above. The fstab does require something on the fstype field.

Post Reply