2

Under a Raspbian 3.18.7 ARMV71 GNU/Linux embedded inside a cute Raspberry Pi B 2, when configuring some 'silent' options under /etc/init.d files with a now evidently broken and stupid file, the following symptoms appeared:

  1. Linux booted with a root@(none) prompt,
  2. System is a 'Read-only file system',
  3. Most (if not all) functionality if broken.

The error was a commented line under /etc/init.d/dphys-swapfile, which should be as-is. Editing them, is impossible now.

Of course, the backups for the original files are there, under <filename>_bkp names, but the system is read-only, and renaming commands are all disabled.

How can I edit the 'offensive' lines under those init.d files, or restore the backup files, or start under recovery mode?

Raspberry Pi exchange solutions are all 'wipe and reinstall' kind, but this is a more Linux flavoured question, and im pretty sure there exist another command line approach for recover from this dumbness...

1

If you have the root@(none) prompt, then you're pretty close to recovery: you have a root shell. The hardest part of recovery is usually figuring out what is wrong, but if you have backups of the correct files, that should be easy.

The first thing you should do is mount a couple of filesystems. Depending on exactly what you need to do, they may or may not be necessary, but they can't hurt.

mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t devpts devpts /dev/pts
mount -t tmpfs -o mode=1755 tmpfs /tmp
mount -t tmpfs -o mode=1755 tmpfs /run

If you don't have /run (I don't know whether it's present on your version of Raspbian), ignore that line. If you don't have /dev/pts, that's a symptom of missing more things in /dev; I think that indicates that your system has devtmpfs built in so you should run mount -t devtmpfs devtmpfs /dev.

You also need to remount the root filesystem read-write. Then start a new shell (the shell you're getting is process ID 1, which causes some signal handling oddness and in particular makes Ctrl+C and Ctrl+Z inoperative).

mount -o remount,rw /
bash

You're now all set to carry out repairs.

When you've finished, remount the root filesystem read-only (as well as any other filesystem that you mounted read-write), then reboot.

mount -o remount,ro /
reboot -f
  • Thanks. The solution work fine!. And i was able to made all the repairs. But some setting kept messing the system, and i finally reset the OS. Thanks for the magic!! – Brethlosze Mar 16 '15 at 0:24

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.