1

Well this just goes from bad to worse. My problem started with an otherwise perfectly good Ubuntu 16.04 install that has been working for a couple of months, aside from broken links on reboot. Following some instructions here: (see Link to (shortcut) is broken after reboot) I decided to try and make sure the drive was mounted on reboot, and edited my fstab file to mount the second hard disk as required (how risky could that be?...)

Now my whole system will not reboot! Apparently the fstab file is now corrupted by the last line I added to include the mounting of the second hard disk. Fortunately a backup file was made of fstab, however I am unable to do anything with it. Although I can boot up using myu ubuntu bootable flash drive and can see both files (fstab and fstab.orig) I am unable to rename the files, remove them, or edit them in any fashion. I presume they are write protected, but can find no way to make them writable.

I have already tried using the GUI (files access) and can see the files, but that's it. Can't edit them in any fashion. Under the permissions it states I am not the owner, so I cannot change permissions. Tried using a terminal window, but if I try to rename the file I get: Bareword "fstab" not allowed while "strict subs" in use at (user-supplied code)

I presume this is also because it is read only. Tried changing permissions using chmod, but I get told: chmod: changing perissions of 'fstab': operation not permitted.

So, what now? And please don't tell me I have to do a full reinstall just because I have a single line of invalid code in this frickin fstab file...

  • "Tried using a terminal window, but if I try to rename the file I get: Bareword "fstab" not allowed while "strict subs" in use at (user-supplied code)" sounds like you're trying to use the (perl based) rename command - for this task, you would be better off using mv command. There certainly should be no need to re-install. – steeldriver Aug 21 '16 at 3:33
  • Ah, just tried to do "mv fstab aafstab" and was told mv: cannot move 'fstab' to 'aafstab' : Permission denied. Was able to "mv fstab.orig fstab" however the newly replaced file is now a binary file and not a text file... – witenitenz Aug 21 '16 at 3:46
  • Have you tried sudo -i nautilus and going to the directory, directly renaming them from Live CD? – Anwar Aug 21 '16 at 14:43
1

Success! After a lot of attempted copying, moving, deleting and editing of the file, I finally restored the backup fstab file I had by doing the following:

  1. Booted Ubuntu from flash drive (like a live CD). I had to revert to using the onboard graphics port, as my GTX950 graphics card refused to play ball with the flash drive boot. Noted for relative newbies like me.

  2. used ctrl+alt+T to open a terminal window and entered sudo gnome-terminal to start a terminal with root privileges.

  3. As my file path was long and had spaces in it, I discovered a very nice means of copying the file path required to get to the fstab file (folder) on my computer. I opened up File, which is the file/folder viewer in Ubuntu similar to Windows Explorer in Windows. I navigated to my machines drive (media/etc/fstab) and then clicked and dragged the file path shown at the top of File to the terminal window with root privileges.

I realize that many more advanced users will laugh at this, but really, do you know how difficult I have found it trying to find the applicable path etc, when blkid tells me my media UUID is some long random list of alphanumeric characters! No sda1 or similar as people repeat here. Perhaps it has something to do with the fact that I am not using a physical hard disk, but instead an M.2 Samsung solid state drive. I don't know, but Ubuntu refused to call it something logical. So dragging the path from the GUI to the terminal window worked.

Once there, add a prefix cd /filepath and hit enter (remember to remove the apostrophes that were dragged/dropped). You should now be in the /etc/ folder containing your fstab file.

  1. Delete the old file. If you have no backup file, perhaps you can try editing at this point, but I had a backup file, so my procedure will cover this method, which involves deleting the present file by typing rm fstab and hitting enter.

  2. Use the command mv to rename your file (mv SourceFile NewFileName). In my case this was mv fstab.orig fstab.

    1. Finally, in the GUI, navigate using File to get to fstab, and confirm it still looks like a txt file, and you can open it and see its contents. I only say this, because one of my attempts to rename the file caused it to spontaneously turn into a binary file(?)

    2. All done. Shutdown, remove your flash drive or live CD and reboot.

And just to iterate, yes I did try numerous things with the prefix sudo. Nothing worked, and Ubuntu refused to let me change/delete the file despite the use of a sudo prefix to the commands. Apologies for the format of this answer, but the editor on this site is less than user friendly...

0

You can't edit/rename the fstab files because you're not the owner of the files, and you don't have enough privileges. BUT, by using the SUDO command, you should be able to do it. In terminal, like so:

cd to the /etc directory on your hard disk

sudo mv fstab fstab.bad

sudo cp fstab.orig fstab

Let us know how that works for you. Cheers, Al

  • Sorry, but using sudo did not give me any privileges over the file. I tried copying, editing it, deleting it, etc. all using sudo in a terminal window. Nothing worked. And I did this both with my ubuntu booted from flash drive, as well as booting to ubuntu on the machine, but choosing one of the other options to start Ubuntu in a limited fashion. And FYI, something wrong with that too. I would boot my machine, get to the screen where it gives you about 3 options (top one being to just boot Ubuntu as normal) and I would select to use one of several other versions. They crashed. – witenitenz Aug 22 '16 at 7:28
  • Your solution as stated above is EXACTLY what I had suggested. The only difference was that you started two terminal sessions, the second one started with sudo, giving you the EXACT same end result as my individual commands with sudo. Anyway, if you're still crashing when you make other selections in GRUB, you've still got other problems. Cheers, Al – heynnema Aug 22 '16 at 14:03
0

This is the procedure for editing fstab from a live usb

sudo mkdir /media/mount
sudo mount /dev/sd__ /media/mount
sudo nano /media/mount/etc/fstab

sd___ is sda1 or whatever the system partition is

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.