amitg1993
Posts: 17
Joined: Fri Jun 07, 2019 10:29 am

forgot the password.

Wed Jul 10, 2019 10:19 am

I have forgotten the raspberry pi 3 b+ password. how do I recover it or set a new one. I tried the method where cmdline.txt is edited and "init=bin/sh" is added at the last. But after that when i try "mount -o remount,rw /", I get an error of "mount: can't find PARTUUID=3259521a-02". How do i solve this ???

epoch1970
Posts: 3318
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: forgot the password.

Wed Jul 10, 2019 10:32 am

Does "mount -o remount,rw /dev/mmcblk0p2 /" work better?

This assumes you're using Raspbian where the root filesystem is in the second partition "p2", the boot FAT partition being "p1"
If you're running Noobs or something else the above command won't probably work. Perhaps " fdisk -l" can show the list of partitions, and you can then find which one you need to mount. See also if "blkid" returns something useful.

EDIT. Sorry. Fixed devices names, thank you rpdom.
Last edited by epoch1970 on Wed Jul 10, 2019 11:04 am, edited 1 time in total.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

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

Re: forgot the password.

Wed Jul 10, 2019 10:44 am

epoch1970 wrote:
Wed Jul 10, 2019 10:32 am
Does "mount -o remount,rw /dev/mmcblk0p2 /" work better?

This assumes you're using Raspbian where the root filesystem is in the second partition "p2", the boot FAT partition being "p1"
FTFY

amitg1993
Posts: 17
Joined: Fri Jun 07, 2019 10:29 am

Re: forgot the password.

Wed Jul 10, 2019 11:21 am

epoch1970 wrote:
Wed Jul 10, 2019 10:32 am
Does "mount -o remount,rw /dev/mmcblk0p2 /" work better?

This assumes you're using Raspbian where the root filesystem is in the second partition "p2", the boot FAT partition being "p1"
If you're running Noobs or something else the above command won't probably work. Perhaps " fdisk -l" can show the list of partitions, and you can then find which one you need to mount. See also if "blkid" returns something useful.

EDIT. Sorry. Fixed devices names, thank you rpdom.
I am new to raspberry....So I don't understand much about filesystem. I tried fdisk -l, i got "cannot open /dev/ram0....15: permission denied" and last entry is "/dev/mmcblk0: permission denied" .i can give you outputs of the commands you want. help me with it.

epoch1970
Posts: 3318
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: forgot the password.

Wed Jul 10, 2019 11:30 am

amitg1993 wrote:
Wed Jul 10, 2019 10:19 am
I tried the method where cmdline.txt is edited and "init=bin/sh" is added at the last.
Check your cmdline.txt file, it should include "init=/bin/sh"
(forward-slash bin forward-slash sh)

Then boot and try the mount command above.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

amitg1993
Posts: 17
Joined: Fri Jun 07, 2019 10:29 am

Re: forgot the password.

Wed Jul 10, 2019 11:51 am

epoch1970 wrote:
Wed Jul 10, 2019 11:30 am
amitg1993 wrote:
Wed Jul 10, 2019 10:19 am
I tried the method where cmdline.txt is edited and "init=bin/sh" is added at the last.
Check your cmdline.txt file, it should include "init=/bin/sh"
(forward-slash bin forward-slash sh)

Then boot and try the mount command above.
Tried it, still getting cant find PARTUUID. While booting there is one message displayed which says "/bin/sh: 0: can't access tty: job control turned off", Is it because of that message.

epoch1970
Posts: 3318
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: forgot the password.

Wed Jul 10, 2019 12:16 pm

You can disregard the "job control turned off" message, it is unimportant.

Again. Try exactly this command

Code: Select all

mount -o remount,rw /dev/mmcblk0p2 /
It will not speak to you about a partition UUID.

This command is ok if you have installed Raspbian.
What system have you installed?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

amitg1993
Posts: 17
Joined: Fri Jun 07, 2019 10:29 am

Re: forgot the password.

Thu Jul 11, 2019 6:31 am

epoch1970 wrote:
Wed Jul 10, 2019 12:16 pm
You can disregard the "job control turned off" message, it is unimportant.

Again. Try exactly this command

Code: Select all

mount -o remount,rw /dev/mmcblk0p2 /
It will not speak to you about a partition UUID.

This command is ok if you have installed Raspbian.
What system have you installed?
I have raspbian installed...Above command worked, I was able to change the password. Can you explain in short what we actually did ??

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

Re: forgot the password.

Thu Jul 11, 2019 6:40 am

Firstly, adding init=/bin/sh to cmdline.txt makes the Pi boot with a very restricted environment. It is automatically logged in as the "root" super user. Also, the main file system is set to read-only mode, which means you can't change any files.

The command

Code: Select all

mount -o remount,rw /dev/mmcblk0p2 /
tells Linux to change the file system (on /dev/mmcblk0p2, which is the second partition of the SD card) to rw or read and write mode.

"mount" is the command to make a file system available.
"-o" means "with the following options"
The "remount,rw" options mean update the existing system with Read/Write access.
"/dev/mmcblk0p2" is the device name of the main file system.
"/" is where that file system is "mounted".

amitg1993
Posts: 17
Joined: Fri Jun 07, 2019 10:29 am

Re: forgot the password.

Thu Jul 11, 2019 7:33 am

rpdom wrote:
Thu Jul 11, 2019 6:40 am
Firstly, adding init=/bin/sh to cmdline.txt makes the Pi boot with a very restricted environment. It is automatically logged in as the "root" super user. Also, the main file system is set to read-only mode, which means you can't change any files.

The command

Code: Select all

mount -o remount,rw /dev/mmcblk0p2 /
tells Linux to change the file system (on /dev/mmcblk0p2, which is the second partition of the SD card) to rw or read and write mode.

"mount" is the command to make a file system available.
"-o" means "with the following options"
The "remount,rw" options mean update the existing system with Read/Write access.
"/dev/mmcblk0p2" is the device name of the main file system.
"/" is where that file system is "mounted".
ohkkk... thank you very much !!

epoch1970
Posts: 3318
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: forgot the password.

Thu Jul 11, 2019 7:37 am

... and you can contrast that with the command you tried at first:

Code: Select all

mount -o remount,rw /
Where the device name is missing. So to try and comply with the command, mount looks up file /etc/fstab which, by convention, contains information for mounts.

In your case, fstab found a device specification matching the “/“ filesystem, referred to as PARTUUID=...
For a reason I ignore, but possibly related to the very minimal environment you’re running off due to init=/bin/sh, mount was unable to make something of that information.

So we replaced that useless information with the name of the device holding the root (“/“) filesystem we, Raspbian users, all know by heart (more or less...): /dev/mmcblk0p2
With the long-form command, mount did not need lookup /etc/fstab, and executed the remount.

And after that, success was at hand. Well done, all.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

amitg1993
Posts: 17
Joined: Fri Jun 07, 2019 10:29 am

Re: forgot the password.

Thu Jul 11, 2019 11:54 am

epoch1970 wrote:
Thu Jul 11, 2019 7:37 am
... and you can contrast that with the command you tried at first:

Code: Select all

mount -o remount,rw /
Where the device name is missing. So to try and comply with the command, mount looks up file /etc/fstab which, by convention, contains information for mounts.

In your case, fstab found a device specification matching the “/“ filesystem, referred to as PARTUUID=...
For a reason I ignore, but possibly related to the very minimal environment you’re running off due to init=/bin/sh, mount was unable to make something of that information.

So we replaced that useless information with the name of the device holding the root (“/“) filesystem we, Raspbian users, all know by heart (more or less...): /dev/mmcblk0p2
With the long-form command, mount did not need lookup /etc/fstab, and executed the remount.

And after that, success was at hand. Well done, all.
oohkkk !!

Return to “General discussion”