Rescue RPI with “Cannot open access to console, the root account is locked.”
If your Rasberry Pi (RPI) won’t boot and is showing “Cannot open access to
Don’t sweat. It can be fixed with a little work.
You were probably editing /etc/
To fix this get your SD card out of the RP and plug it into your computer. Ignore the requests to format the card (don’t format it or you’ve lost everything). One of the drives will have data on it and you will see a file called cmdline.txt open this text file in Notepad or similar and add the following text to the end of the first line init=/bin/sh
Save the file and put the SD card back into the RPI and power it up. You will need a keyboard plugged into the RPI for the next step and be viewing the output via HDMI.
Part way through startup the pi will now switch into bash (the console). This will enable you to go and fix the /etc/
sudo nano /etc/fstab - remove the faulty line (ctrl+k to remove line)
- Save the file
- Take the SD card back out and remove the init=/bin/sh from the
cmdline.txt - Reboot the Pi and it should now work fine
However, sometimes you
- mount -o remount,
rw / –target /
before the steps above.
Thanks You. You are My hero
It leaves a kernel panic saying that something tried to kill init
Found another tutorial talking about the same thing. put it at the end of the first line, not beginning
“you will see a file called cmdline.txt open this text file in Notepad or similar and add the following text to the START of the first line init=/bin/sh”
Sloppy writing from V5.
Thank you for taking the time to look up the other tutorial and writing the solution here.
“By Eric Jin
It leaves a kernel panic saying that something tried to kill init”
Same problem here… :-/
This error is not always an fstab problem. It can also be an unrecovered disk error that prevents root from being mounted RW. Of course if this is the case, fstab can be run since the disk is in RO mode.
Yep. It could also be a mucked up /boot/config.txt, which is what I probably did. I’m also wondering if maybe disabling the root password has something to do with it.
You should not need to remove the SD card, once you have your raspberry pi booting again. You can just go vi /boot/cmdline.txt , right? 😉
Saved my bacon 🙂 Thanks!
I was editing fstab today, trying to get a network drive to mount automatically and started getting an error [FAILED] Failed to mount /boot. At the end of the error string it tells me I am in emergency mode, then says Cannot open access to the console, the root account is locked.
I tried your fix, but when I insert init=/bin/sh into the cmdline.txt file it causes kernel panic and the system still doesn’t boot.
I tried it on the boot partition and the rootfs partition. Is there anything else I can try?
I have exactly the same conditions (stuffed fstab file), and exactly the same errors. Can’t get past kernel panic. Anyone else have a recommendation for this one?
Put the init=/bin/sh at the end of the line and not beginning
had this problem when I overwritten the /boot folder from the berryboot pack, and still my second OS option did not boot successfully, however I’m getting this account locked error sometimes when booting up, what I do is I hard shutdown my Pi with an argon m.2 case, and then boot it up again and it boots successfully.
would like to have this fixed permanently though, to avoid anymore further issues
Messed up fstab, now its read-only and I can’t edit it
mount -o remount,rw /dev/mmcblk0p2 /
The easiest solution is to connect the SD card to another linux computer, by inserting the SD card in a SD to USB convertor. (= small USB device where you can insert an SD card)
To find the device : sudo fdisk -l
Mount the device : sudo mount -t auto /dev/sda2 /mnt (change sda2 to your device)
Now you can edit the file : sudo nano /mnt/etc/fstab
Delete the line that contains the bad command : CTRL-K
Unmount the device : sudo umount -t auto /dev/sda2
If you have changed the file cmdline.txt: do not forget to leave out ” init=/bin/sh”
Insert the SD card again in your RPI: everything will work again!
I solved the problem on a Windows by using a VMware or VirtualBox Linux Ubuntu-Image (you can easily find in the internet) in combination with an external USB-card reader (2€ China hardware :-)) . Within the image the Raspberry’s SD card was mounted as “boot” and “roots” (in my case /dev/sdb1 and dev/sdb2 – which may differ on your system). I unmounted first “boot” with “sudo unmount /dev/sdb1” and performed “sudo -c -v /dev/sdb1” (instead of “-v” you can try “-p”). After this I remount the card reader because you need at least one partition of the SD-card mounted, otherwise the complete SD card will be disconnected from the VM and remounted to the host PC. Then I did the same with “rootfs” (in my case “sdb2”) as described before for “boot”. Additionally I also edited the etc/fstab file an removed the mount entries for my both SSD drives where seems to be also a problem solved with “fsck” in the same way.
“Error writing /etc/fstab: Read-only file system”
After all these steps, I got the error message: “Error writing /etc/fstab: Read-only file system”
What helped me: I directly edited the /etc/fstab file (instead of cmdline.txt) when SD card was out of the RPi and plugged it into my computer (Linux PC). You need to find it out in directory structure (by the way, I have 2 partitions on my SD card).
Bro, Thanks! Saved me a whole afternoon in restoring OpenVPN Server, Pi-Hole, etc.
THANKS!
Another solution for Read-only file system when trying to write fstab, is adding “rw” before “rootwait” in cmdline.txt
LEGEND! THANK YOU!!! This saved me hours, was just about to reformat after hours of work
awesome, thank you very much. You are my savior