1

I edited my fstab file (/etc/fstab) to mount a new /media local network drive.

After this wrong edition, my Raspberry eventually can't boot anymore. I get the error:

Cannot open access to console, the root account is locked.
See sulogin(8) man page for more details.

My aim is to edit the fstab to correct the mistake and get my Pi bootable again.

4

Since I found the solution myself, I am posting it here, very grateful to every author of the raspberry pi forum posts.

1. Part 1 - getting command line in the boot

Error

Got "Cannot open access to console, the root account is locked." error.

Solution

  • Mount the SDCard on another computer (any type).
  • Tip: if you don't have a SDCard reader on your computer, use your smartphone.
  • In the FAT32 /boot partition (which should be accessible in Windows for instance), there is a file called cmdline.txt. I appended init=/bin/bash to that file.
  • Now, my Raspberry Pi boot with a root access command line.

2. Part 2 - remount with the commmand line

Error

  • I tried to edit directly with nano /etc/fstab
  • But I get an error mount: can't find PARTUUID=f2d3cb4f-02.
  • I tried to mount the partition in rewrite mode with mount -o remount,rw / but I still got the fstab error

Solution

  • Remount partially only one mounting point with sudo mount -o remount,rw /dev/mmcblk0p2 /
  • Edit the fstab file to fix the mistake
  • Use your other computer to remove the init=/bin/bash from the cmdline.txt
  • Reboot your Raspberry Pi
  • Tada!

Sources

Many thanks to:

| improve this answer | |
  • Why do not edit etc/fstab direct on your other computer? – Ingo Nov 8 '18 at 10:23
  • on windows, I cannot access the right partition, so I couldn't edit the file. I could if I had a Linux or (probably) MacOS – JMax Nov 12 '18 at 14:22
  • mac doesn't support ext4, and also when I try adding that line it ends up with a kernel panic saying that I tried to kill the init process – Eric Jin Jun 8 at 18:43
1

I couldn't use @jmax's answer because for some reason I couldn't ever get into the command line. Maybe it's a mac thing?

For anyone that hits this problem that only has a mac, you can install this software and use the free 10-day trial to mount the sd card on your mac and just edit the /etc/fstab file directly.

https://www.paragon-drivers.com/en/extfsmac/

It's not free software though so just don't mess up your fstab again ;)

| improve this answer | |

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.