Jbar
Posts: 3
Joined: Fri Jan 27, 2017 2:44 pm

Emergency Mode due to fstab

Fri Jan 27, 2017 4:05 pm

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!

epoch1970
Posts: 2076
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Emergency Mode due to fstab

Fri Jan 27, 2017 5:18 pm

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.
Last edited by epoch1970 on Sat Jan 28, 2017 9:41 am, edited 2 times in total.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Emergency Mode due to fstab

Fri Jan 27, 2017 6:47 pm

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.

Jbar
Posts: 3
Joined: Fri Jan 27, 2017 2:44 pm

Re: Emergency Mode due to fstab

Sat Jan 28, 2017 12:34 am

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.

ejolson
Posts: 2041
Joined: Tue Mar 18, 2014 11:47 am

Re: Emergency Mode due to fstab

Sat Jan 28, 2017 1:05 am

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.
Last edited by ejolson on Sat Jan 28, 2017 5:12 pm, edited 1 time in total.

epoch1970
Posts: 2076
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Emergency Mode due to fstab

Sat Jan 28, 2017 9:44 am

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.)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Jbar
Posts: 3
Joined: Fri Jan 27, 2017 2:44 pm

Re: Emergency Mode due to fstab

Sat Jan 28, 2017 10:41 pm

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).

RPiRipple
Posts: 1
Joined: Wed May 03, 2017 8:12 pm

Re: Emergency Mode due to fstab

Wed May 03, 2017 8:26 pm

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).

serkanb
Posts: 1
Joined: Sat Jan 13, 2018 12:13 am

Re: Emergency Mode due to fstab

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 /  

toldcodger
Posts: 22
Joined: Sat Feb 25, 2017 7:15 pm

Re: Emergency Mode due to fstab

Sat Feb 10, 2018 11:46 am

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
😂
You should always keep the prime objective in mind.
However, when you’re up to your ass in alligators, it’s hard to remember that you came to drain the swamp. :D

timnixon
Posts: 2
Joined: Tue Sep 05, 2017 4:41 pm

Re: Emergency Mode due to fstab

Fri Mar 09, 2018 9:01 pm

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

Ceppetto
Posts: 3
Joined: Fri Jul 27, 2018 5:40 pm

Re: Emergency Mode due to fstab

Tue Aug 07, 2018 6:53 pm

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.

Return to “General discussion”