Page 1 of 1

Emergency Mode due to fstab

Posted: Fri Jan 27, 2017 4:05 pm
by Jbar
Hi all. I am new here and new to raspberry pi and linux but doing by best to learn.

I am have a pi 3 for retro pie. I tried to mount an external self powered hard drive so that I could bring large size roms to my sd card. I made an error in the fstab (almost certain) and when I saved and rebooted I go into emergency mode.

I have no other machines running linux and have come up with only one way i can think to fix the fstab: buy another sd card and set it up and boot as a new retro pie machine. Then use WinSCP to copy the new virgin fstab over the corrupted one.

Any thoughts on this are appreciated. Another method? Tips? Thank you!

Re: Emergency Mode due to fstab

Posted: Fri Jan 27, 2017 5:18 pm
by epoch1970
Welcome to the forums.

Having an extra SD is never a bad idea.

You could also add "init=/bin/sh" at the end of cmdline.txt, in the boot partition of the SD.
That would start you in a minimum shell environment, as root, where you should be able to "mount -o remount,rw /" (to mount the root partition in read-write mode), then "nano /etc/fstab" and comment out the offending line.
Then run "sync" once or twice, then "exit" (and there the OS will panic, this is OK)

After that, power off the Pi, remove "init=/bin/sh" from cmdline.txt, and reboot.
Hopefully the machine will start this time.

(systemd loves to put the system in emergency mode when a drive is missing --or simply just a bit too slow. Look for threads that mention options like nofail, x-systemd-automount, etc.)

EDIT: Add the mandatory remount action I forgot in the initial post, sorry.

Re: Emergency Mode due to fstab

Posted: Fri Jan 27, 2017 6:47 pm
by stderr
Jbar wrote:I am have a pi 3 for retro pie. I tried to mount an external self powered hard drive so that I could bring large size roms to my sd card. I made an error in the fstab (almost certain) and when I saved and rebooted I go into emergency mode.
Does it go right into "emergency mode" or does it stall out? Have you tried hitting the s key for skip when that happens, if it does?
I have no other machines running linux and have come up with only one way i can think to fix the fstab: buy another sd card
You should be able to mount the boot partition under windows and then, as the other poster said, look at that which would then allow you to change how it is booting so you could then change out the fstab issue. But you might want to just find any old sdcard that fits in the pi and write tiny core linux, picore, to that. This will let you boot quickly to memory and remove the boot sdcard and replace with the one you are having trouble with. It will even let you chroot and do things that aren't interfering with, I think it is, systemd. Before you put stuff into the fstab, it's a good idea to make sure a version at the command line works correctly. They are formed differently but they should both work and recovery from the command line would be easier.

Re: Emergency Mode due to fstab

Posted: Sat Jan 28, 2017 12:34 am
by Jbar
Thank you Epoc1970 for the suggestion. Doing so I am allow to edit fstab but then when I exit I get an error "Error writing /etc/fstab: read-only file system" I did use sudo.

Re: Emergency Mode due to fstab

Posted: Sat Jan 28, 2017 1:05 am
by ejolson
Jbar wrote:"Error writing /etc/fstab: read-only file system" I did use sudo.
It should be possible to remount the root filesystem read/write and then edit the file. Something like

Code: Select all

# mount -o remount,rw /partition/identifier /mount/point
may work.
Jbar wrote:one way i can think to fix the fstab: buy another sd card and set it up and boot as a new retro pie machine. Then use WinSCP to copy the new virgin fstab over the corrupted one.

Any thoughts on this are appreciated. Another method? Tips? Thank you!
For the cost of burning a DVD blank, you could live-boot the x86 version of Pixel on your Windows computer, mount the sdcard and fix it. After you are done, remove the DVD and reboot your PC back into Windows.

Re: Emergency Mode due to fstab

Posted: Sat Jan 28, 2017 9:44 am
by epoch1970
Sorry for that, I edited my previous post. In this specific case the command you're looking for is simpler than the generic command offered by ejolson:
"mount -o remount,rw /" (no sudo needed, you're root already)

Good luck.

(I like the suggestion of Pixel live-cd as a rescue workstation.)

Re: Emergency Mode due to fstab

Posted: Sat Jan 28, 2017 10:41 pm
by Jbar
Thank you Epoc19170 . It worked like a charm. :D

Tried the pixel boot on windows and found etc/fstab was essentially empty and furthermore I did not have write access (probably my own ignorance).

Re: Emergency Mode due to fstab

Posted: Wed May 03, 2017 8:26 pm
by RPiRipple
I just typed
  • vi /etc/fstab
edited / saved the file then
  • reboot -r now
I'm surprised as it said root had been locked, but it worked a treat.
(I have a Pi model B running 2017-01-11-raspbian-jessie).

Re: Emergency Mode due to fstab

Posted: Sat Jan 13, 2018 12:18 am
by serkanb

Code: Select all

"mount -o remount,rw /"
command didn't work for me. It couldn't find Partition ID so that I tried below commands and it worked.

Code: Select all

umount / 
mount -o remount,rw /dev/mmcblk0p2 /  

Re: Emergency Mode due to fstab

Posted: Sat Feb 10, 2018 11:46 am
by toldcodger
Worked like a charm. Thanks epoch1970.

I had edited fstab and nofail was not in the line I added. I presume this was the reason for the read only boot up

I was trying to add a new user and give them full access to any usb devices without adding them to the root or pi groups. This was just the last in a long line of failures
😂

Re: Emergency Mode due to fstab

Posted: Fri Mar 09, 2018 9:01 pm
by timnixon
Had this happen twice, in my case the pi booted from SD but pointed at external disk /dev/sda1

My solution was to boot from a different SD card only and make sure the HDD was not mounted...
Then
  • fsck /dev/sda1
    e2fsck /dev/sda1
In both cases when it happened and I did this procedure it stopped the problem and the fsck had reported the disk hadn't been checked in 400 days

Also watch out for things in your startup (/etc/rc.local) that you may have added that aren't running correctly

Re: Emergency Mode due to fstab

Posted: Tue Aug 07, 2018 6:53 pm
by Ceppetto
hi i got this message a couple of times and ignored it for a couple times but then when I was reading what was wrong I followed the instructions the pi gave me and I followed these steps :

Code: Select all

journalctl -xb
then this

Code: Select all

systemctl reboot
to reboot it and then type

Code: Select all

systemctl default or ^d
and I rebooted twice and it works just fine.

Re: Emergency Mode due to fstab

Posted: Mon Apr 22, 2019 9:16 am
by Reece
serkanb wrote:
Sat Jan 13, 2018 12:18 am

Code: Select all

"mount -o remount,rw /"
command didn't work for me. It couldn't find Partition ID so that I tried below commands and it worked.

Code: Select all

umount / 
mount -o remount,rw /dev/mmcblk0p2 /  
This is exactly what I needed. I too broke my fstab!! After adding init=/bin/sh to the cmdline.txt, this was the only advice that worked for me.