I am using AWS EC2, and I have added an extra EBS volume. It is currently mounted as a new device.

MySQL & Redis DB stores their data on the new EBS volume, and they are registered in the chkconfig. Therefore, I need the volume to be mounted BEFORE the chkconfig service starts up.

But I do not want to add it in my /etc/fstab, as told in the forum below. https://forums.aws.amazon.com/message.jspa?messageID=304528#304528

So I have added mount /dev/xvdf /data in my /etc/rc.d/rc.local , and I rebooted my system.

But apparently chkconfig services starts up BEFORE /etc/rc.d/rc.local, and so the MySQL &Redis startup fails.

I want to know where I can write an init script that is called BEFORE chkconfig service starts.

Thanks in advance.

  • 2
    You should put this in /etc/fstab, and then ask Cindy what on earth she's talking about. Mar 24, 2013 at 21:51
  • 1
    @MichaelHampton I was able to reproduce the problem - When I had a detached EBS volume in my /etc/fstab, I couldn't even ssh (even though the EC2 management console tells me that the box is running). I'm sure a failure in an EBS volume is rare, but I can't afford to not be able to ssh for my production server...
    – ashiina
    Mar 24, 2013 at 22:23

2 Answers 2


As you might have noticed rc.local is usually the last script that is executed during the boot process. This is stated in the comments in the script.

Judging by the mention of chkconfig in your question I guess you're running either CentOS, Amazon's RHEL based Linux or another Red Hat (or Fedora) derivative. If that's the case then you can simply disregard what Cindy@AWS said in that thread.

Mounting of local filesystems in RHEL is done by the /etc/rc.sysinit script which mounts all filesystems that are not NFS, CIFS (SMB) or some other network-based filesystem. This is done by executing the following line in the script:

    action $"Mounting local filesystems: " mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev

This line executes mount and instructs it to try and mount all devices that don't match any of the nfs, nfs4, smbfs, ncpfs, cifs, gfs or gfs2 as their filesystem type. In addition to that it ignores all devices with _netdev in their options in fstab.

When mount tries to mount any filesystem that doesn't exist it doesn't block, but fails with the following error message:

# mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev`
mount: special device /dev/fhsd does not exist

In my case /dev/fhsd is a line in fstab that looks like this:

/dev/fhsd /mnt ext4 defaults 0 0

As you can see this failure is not blocking the mount process and the OS will not block waiting for the device, it will simply fail.

There is another script that takes care of mounting network-based filesystems in /etc/init.d/netfs and all filesystems that have _netdev in their options are handled by it.

There is a problem with missing devices in Ubuntu and you need to add nobootwait (also see this question about nobootwait and nofail on Unix.SE) to specify that the OS boot process should not fail if the device is missing, but under Ubuntu the mounting is performed by mountall(1).

  • I am using Amazon Linux AMI, which I believe is based on RHEL. You were absolutely right; The mount process fails but does not block the boot process. I am not sure why my ssh failed several times, but as far as I am testing right now, there does not seem to be any problem in rebooting / stop-starting the OS. Thank you!
    – ashiina
    Mar 25, 2013 at 6:25

You can tell chkconfig what order to execute init.d scripts in, via a comment in the script.

Write an init.d script to mount/unmount and have it execute before MySQL and Redis on boot, and after MySQL and Redis on shutdown.

  • That sounds very promising. I will give it a try and tell you how it turns out.
    – ashiina
    Mar 24, 2013 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.