6

I need to reset a forgotten RPI OS password. In order to do that I need to insert the SD card to the computer and edit the cmdline.txt file. It is not anywhere on the SD card root folder or any of the subfolders.

These are the files that I can find on the SD card

  • (DIR) defaults
  • (DIR) os
  • bootcode.bin
  • BUILD-DATA
  • INSTRUCTIONS-README.txt
  • recovery.cmdline
  • recovery.elf
  • RECOVERY_FILES_DO_NOT_EDIT
  • recovery.img
  • recovery.rfs
  • riscos-boot.bin
  • config.txt
  • (DIR) etc
goldilocks
  • 60,325
  • 17
  • 117
  • 234
PrashanD
  • 163
  • 1
  • 1
  • 5

7 Answers7

5

cmdline.txt is residing in /boot which is a separate FAT partition on the SD card (that's the way with my Arch Linux but to my knowlegde the same for other distributions). If that SD card is read at a Windows PC this should be the only partition directly visible in the explorer.

EDIT: As we are now discussing NOOBS, same rules apply, with just more than one possible /boot partition on the card. Other than for RISC OS these partitions will still be VFAT but Windows cannot directly access them. Best way to go: mount with Linux.


Note that on NOOBS (from "NOOBS bootup (low-level)"):

When the Raspberry Pi is powered on with a NOOBS card inserted, it:

  1. Loads and runs bootcode.bin from the FAT-format /dev/mmcblk0p1, exactly as it does for standalone images. (This behaviour is built into the BCM2835's internal firmware on all Pis, and so can't be changed.)
  2. bootcode.bin then spots that start.elf is missing, so it loads and runs recovery.elf instead.
  3. Running recovery.elf then switches the firmware into "NOOBS mode" - it uses recovery.img instead of kernel.img, recovery.cmdline instead of cmdline.txt, and it sets the root filesystem to recovery.rfs.

In case that's not clear, this is why you don't have a start.elf, which the normal distros do. It means that you should use the recovery.cmdline file (in your question) instead of cmdline.txt

goldilocks
  • 60,325
  • 17
  • 117
  • 234
Ghanima
  • 15,958
  • 17
  • 65
  • 125
3

Some Raspberry Pi SD cards contain a bug where the wrong partition is mounted as /boot.

You probably find that:

  • cmdline.txt and/or config.txt are not present in /boot
  • changes to these files seem to not take effect

https://github.com/raspberrypi/noobs/wiki/NOOBS-partitioning-explained#noobs-os-installation mentions two FAT partitions. The files you list belong to the RECOVERY partition (/dev/mmcblk0p1), not boot partition (e.g. /dev/mmcblk0p5).

As this is a bug that's been fixed, rather than change /etc/fstab manually, the simplest option is to update your Raspberry Pi:

$ sudo apt-get udate
$ sudo apt-get upgrade
Mircea Baja
  • 171
  • 6
2

On the bootup of raspberry pi press Shift button , it will take you to recovery mode, there you can see the option Edit Config.

In that you can select cmdline.txt

The original content should look like

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

At the end of it add the following text

init=/bin/sh

Thats it!

You are ready to go, Hit the ok button !

In the next bootup of Pi You will be asked to enter the new Password

Hope this helps

km_pawar
  • 41
  • 5
1

While booting, press Shift+up and it will take you to the recovery console. the cmdline.txt file is editable from one of the tabs

0

The cmdline.txt file you are looking for is found in /boot.bak

the file contents is this:

dwc_otg.lmp_enable=0 console-ttyAMAO,115200 console=tty1 root=/dev/mmcblk0p2 ro rootfstype=ext4 elevator=deadline rootwait logo.nologo loglevel=1 quiet
Bex
  • 2,929
  • 3
  • 26
  • 34
Colby
  • 1
0

The answer posted by Akash on Jul 22, 2016 was most useful for me. I did run into something that I wanted to add to what he said, because it seems something has changed with the latest Raspbian update.

After the pi starts booting and you hold shift to enter setup mode, it brings you to a recovery mode GUI. Here you can access the config.txt file that is mentioned.

I was not able to get anywhere with adding init=/bin/sh to the end of the file. When I did, the boot would hang.

I had read on some other sites that people were instead adding single to the end of the file. I tried that and it worked. This time, when it booted, it ended up at a command line (instead of booting into Pixel). From there I did:

sudo raspi-config

and was able to get back to the configuration screen to change my password again.

How I messed up the password is still a mystery, but I think it had to do with using the numeric keypad while typing the password at the command line and it may have had NumLock disabled...

Hope this helps somebody (it'll probably be my future self).

SlySven
  • 3,631
  • 1
  • 20
  • 46
0

This is what I did. Hold shift to open recovery mode on bootup. Hit the edit config, then click on cmdline.txt. Add word single to end. Hit exit. On bootup, will stop at root command line. enter sudo raspi-config. Select second option, change user passwd. Then, finish and halt system. Re-boot then hold shift again. Delete word 'single' from cmdline.txt and boot system. login with updated password.

Benji
  • 1