/etc/fstab and the case against it

Problem: I have a faulty hard disk. I do not know what’s wrong with it, but it is pretty dated and I am assuming some sectors are corrupted. It works normally, but sometimes it gets stuck, unresponsive and it slows down the entire system.

Now, I’ve had this problem for almost a year now, so I just usually avoid using that hard disk altogether. However, recently, I ran out of space on my main machine and my primary disk, so I thought there’s no harm in storing some “useless” files on this drive. Useless as in, I have them backed up in Cloud, but for easier access, I have it locally. All this was fine, except that my machine wouldn’t boot if I had the hard drive plugged in. Usually, rebooting the system worked fine, until today. And this caused me to figure out why was it a problem.

Solution: Don’t use /etc/fstab with faulty drives

Explanation: When the system boots up, a plethora of services are initialized, and scripts are run. One such script is mounting all the attached storage media. I use Fedora 32, and in this machine, like almost all *NIX environments, /etc/fstab is a file, which is used to mount media automatically. I had configured it to mount the hard disks in their respective mount points.

Little did I know, that it would try to mount it WHILE the machine was booting up. Surely, there would be a good reason for the OS designers to choose it, if someone knows the answer to that, do let me know. However, I was not privy to that fact. Now, when my machine was booting up, it tried to mount the drive to that mount point. But it couldn’t because, well, faulty hard disk (at least that’s what I am presuming happened). So, just unplugging the hard disk should work fine, right? It would just not boot it.

So, I did just that. Except then, the machine wouldn’t boot still. I went through the logs, and I found out that there’s a 90s timeout for waiting for devices to be ready and mounted. But since there was no device, the timeout exceeded, and the machine refused to boot up altogether.

Now that’s just bad system design, in my opinion. If something, which is not crucial for the machine to function, fails to load, the machine should just report it, ignore it and move on to work with the bits which it can make do with. Now, here, I’d like to state that my hard disk may not be entirely innocent either. I used it as my secondary boot device a few years ago, and I had not “cleansed” it. So, I’m not sure if that qualifies as being “important” enough that the machine could not function without it, but still, it should give an option to move on without it, should it not?

So, what I did was, I had a bootable thumb drive with Fedora 32 on it. I live-booted into that, and I used it to edit the /etc/fstab on my primary SSD.

So, now when I rebooted it, it opened within seconds. So, that was the solution to the problem which popped up later. I still had the original problem of automatically mounting the device on boot, without it breaking my system.

For that, I wrote a tiny bash script in my /etc/profile.d/custom_script.sh file.

#! /bin/bashmount /dev/<partition_name> /media/<mountpoint>
mount /dev/<some_other_partition_name> /media/<other_mountpoint>

This works well for me, as it would mount the device only after I have logged in. The takeaway here is that don’t use fstab with faulty devices. Use the script above for the same. It may save you a lot of trouble.




Undergrad at BITS Hyderabad. Data Scientist. This is my personal blog where I may rant about technology, or some TV show or movie, or anything at all.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to track screen transitions in Flutter with RouteObserver

DataNumen Zip Repair 3.5 is released on May 4, 2021

DataNumen Zip Repair Boxshot

Hacking Series Part 2

Make database isolation levels understandable


What is Agile Testing exactly?

Why you must know about web accessibility

Using the Animation Override Track in Timeline

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Animesh Srivastava

Animesh Srivastava

Undergrad at BITS Hyderabad. Data Scientist. This is my personal blog where I may rant about technology, or some TV show or movie, or anything at all.

More from Medium

Differences between static and dynamic libraries

Reasons Why You Should Use Kubernetes

Introduction to ETCD

Keys laying on a table, all facing the same direction

The Big Fuss about Log4j & CVE-2021–44228