cyttorak
Posts: 97
Joined: Wed Dec 26, 2012 10:34 pm

boot in "safe mode" or "maintenance mode"?

Sat Jan 02, 2016 8:30 pm

Hello

How can I boot raspbian in boot in "safe mode" or "maintenance mode"?

Thanks.

User avatar
DougieLawson
Posts: 42217
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: boot in "safe mode" or "maintenance mode"?

Sat Jan 02, 2016 11:03 pm

What do you mean by that?
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

cyttorak
Posts: 97
Joined: Wed Dec 26, 2012 10:34 pm

Re: boot in "safe mode" or "maintenance mode"?

Sun Jan 03, 2016 12:11 am

the monouser mode to run things like fsdk o badblocks to check o repair the sd card

User avatar
DougieLawson
Posts: 42217
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: boot in "safe mode" or "maintenance mode"?

Sun Jan 03, 2016 12:18 am

cyttorak wrote:the monouser mode to run things like fsdk o badblocks to check o repair the sd card
Why do you think you need that? The cmdline.txt for the latest Raspbian Jessie is set-up to automatically run fscks at boot time, if needed.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

cyttorak
Posts: 97
Joined: Wed Dec 26, 2012 10:34 pm

Re: boot in "safe mode" or "maintenance mode"?

Mon Jan 04, 2016 9:36 pm

My English is quite bad so if the next lines seen don't have sense (or you think I'm follow the wrong way) but you know how boot in "safe mode" or "maintenance mode", please, just tell me how, just in case.

Well, the situation is that:

Some days ago raspbian (wheezy) detect that my sd was corrupt so ask me for the root password to go to "maintenance mode" and run fsdk manually.

I did that and fsdk said that everything was fixed but it wasn't. Raspian still working with problems, some files were corrupt, every time and again I saw error messages about ext4 in the terminal, etc.

So finally I format the sd card and burn a Raspbian jessy (lite version) image.

Everything seemed to return to work at first but after a while I have seen another strange behavior: The last file created was being rewritten (I don't know how, neither by who, neither when) with another content.

For example. I created a bash script called /home/pi/scripts/eth and suddenly their contend was

Code: Select all

grep '-s'
state.ALSA {
	control.1 {
		iface MIXER
		name 'PCM Playback Volume'
		value -2000
		comment {
or something like that.
I restored my script but at the next boot the problem goes back.

After that, I created another bash script called /home/pi/script/log.sh and suddenly their contend was strange characters.

And more things like that.
So I'm thinking that maybe the sd card is still corrupted, and I do

Code: Select all

touch /forcefsck
To force fsck in the boot but fsck don't return any useful message.

So now, I want to boot in "safe mode" or "maintenance mode" to run manually fsck (maybe try with deferents parameters) and badblocks or other things that I can find in Internet and seems useful.

User avatar
rpdom
Posts: 20382
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: boot in "safe mode" or "maintenance mode"?

Mon Jan 04, 2016 9:45 pm

Edit the cmdline.txt file in your /boot partition and add " init=/bin/bash" on the end. Then boot and you will go straight to a root shell prompt (#). You should now be able to run the fsck.

cyttorak
Posts: 97
Joined: Wed Dec 26, 2012 10:34 pm

Re: boot in "safe mode" or "maintenance mode"?

Mon Jan 04, 2016 10:15 pm

rpdom wrote:Edit the cmdline.txt file in your /boot partition and add " init=/bin/bash" on the end. Then boot and you will go straight to a root shell prompt (#). You should now be able to run the fsck.
Hi, I did and I go straight to a root shell prompt (#) but when I try run

Code: Select all

fsck /dev/mmcblk0p2
fsck said that /dev/mmcblk0p2 is mounted

And when I try to poweroff or reboot there is this error:

Code: Select all

Failed to read /proc/cmdline. Ignoring: No such file or directory
Failed to talk to init daemon
So I can't switch off properly my raspberry

And when I try to edit cmdline.txt, nano said me that I don't have write permission
Last edited by cyttorak on Mon Jan 04, 2016 10:22 pm, edited 1 time in total.

User avatar
rpdom
Posts: 20382
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: boot in "safe mode" or "maintenance mode"?

Mon Jan 04, 2016 10:19 pm

Is it mounted read-only or is it read/write? You should be able to fsck if it's read-only.

Try "mount -o remount,ro /dev/mmcblk0p2". It should work (I think).

cyttorak
Posts: 97
Joined: Wed Dec 26, 2012 10:34 pm

Re: boot in "safe mode" or "maintenance mode"?

Mon Jan 04, 2016 10:29 pm

I get that:

Code: Select all

# mount -o remount,ro /dev/mmcblk0p2
[    84.312734] EXT4-fs (mmcblk0p2: re-mounted. Opts: (null)
# fsck /dev/mmcblk0p2
fsck from util-linux 2.25.2
e2fsck 1.42.12 (29-Aug-2014)
ext2fs_checl_if_mount: Can't check if filesystem is mounted due to missing mtab file while determining whether /dev/mmcblk0p2 is mounted.
fsck.ext4: Device or resource busy while trying to open /dev/mmcblk0p2
Filesystem mounted or opened exclusively by another program?

FM81
Posts: 518
Joined: Wed Apr 17, 2013 4:33 pm

Re: boot in "safe mode" or "maintenance mode"?

Wed Jan 06, 2016 9:32 am

cyttorak wrote:How can I boot raspbian in boot in "safe mode" or "maintenance mode"?
I think, not anymore ...

How ever, the "Emergency kernel" of earlier days wasn't a bad thing at all, at least for peoples like our thread-opener, who seems to know very well, how to use it!?
On the FAT32-partition of the latest 'raspbian-jessie' I find about 40MB empty space, may be someone know what it is reserved for? For my opinion is enough space available, but may be there are other reasons, not supporting this anymore?

Greetings, FM_81

PS: If it wasn't needed at all cyttorak wouldn't have asked ... :)
A: What does the command 'cat /dev/urandom', can you tell me please?
B: Yeah, that's very simple: It feeds your cat with radioactive material!

User avatar
DougieLawson
Posts: 42217
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: boot in "safe mode" or "maintenance mode"?

Wed Jan 06, 2016 1:20 pm

The problem is that without a root passwd the emergency shell is as much use as an ashtray on a motorcycle. Because of the way Raspbian is built with the pi user using sudo for everything very few folks have ever set a root password. Getting a root shell running by changing the init= line in /boot/cmdline.txt isn't easy either. So for most users they have to rely on the automated fsck.

Hence "safe mode" or "maintenance mode" isn't easy. The easier option right now is another SDCard and a USB reader. Boot the system from the "rescue card" login as pi and use sudo -i to get the root shell for recovery. That can be used to a) mount the broken card and b) fsck broken filesystems.

The thing NOOBS needs is a) a pi userid password "resetter" b) a recovery root shell. Then NOOBS might be more useful. The current trash and re-install isn't a sensible option as soon as you have any user created data or programs on your RPi.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

User avatar
procount
Posts: 2695
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: boot in "safe mode" or "maintenance mode"?

Fri Jan 08, 2016 12:38 pm

(I hope I'm not hijacking but I just wanted to respond to Dougie's comment re: noobs)
1. I agree that the "trash and reinstall" could be better. I am thinking of ways I might be able to improve that but it's not easy.
2. A noobs shell already exists (ctrl-alt-F2) but the busybox shell is quite basic. What extra is needed for a "recovery shell"?
3. Does a pi userid password resetter exist already? Maybe I could incorporate it?
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

User avatar
DougieLawson
Posts: 42217
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: boot in "safe mode" or "maintenance mode"?

Fri Jan 08, 2016 2:36 pm

procount wrote:(I hope I'm not hijacking but I just wanted to respond to Dougie's comment re: noobs)
1. I agree that the "trash and reinstall" could be better. I am thinking of ways I might be able to improve that but it's not easy.
2. A noobs shell already exists (ctrl-alt-F2) but the busybox shell is quite basic. What extra is needed for a "recovery shell"?
3. Does a pi userid password resetter exist already? Maybe I could incorporate it?
1. Anything is going to be better than the current sledgehammer, there must be so many folks who've lost everything. That was OK back in the days of ZX80s & Microtan65s (when there was no permanent storage apart from a flaky cassette recorder), but it ain't OK now.
2. I don't know, it's months since I had any RPi booted with NOOBS and I've not looked. What I was thinking of was a GUI option that would silently do the fsck stuff under the covers and report results (or even an automatic process when NOOBS starts). Don't know how you handle the irreparable case - trash and install may be the only option in that case.
3. http://unix.stackexchange.com/questions ... etc-shadow has a few ways to reset /etc/shadow entries with a new known password

I don't think we're hijacking the thread since we're looking at ways of providing the OP's requirements.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

Return to “Advanced users”