# Solved: Lost root password - no method works

## apeshansky

Hi,

I am trying to reset root password on Gentoo box (that I did not setup).  I tried adding 

```
real_init=single
```

 to GRUB kernel line, but then I get 

```
Give root password for maintenance (or type Control-D to continue):
```

 I also tried adding

real_init=/bin/bash (/bin/sh is a symlink to /bin/bash), real_init=/bin/bb and real_init=/bin/busybox (these are the only shells I see in /bin), but this just is ignored and system starts with runlevel 3.  I also tried init=, but this is simply ignored.

I tried to boot from LiveCD (minimal CD), but any attempt to 

```
chroot /mnt/gentoo /bin/bash
```

gives 

```
chroot: cannot run command '/bin/bash': No such file or directory
```

I suspect this is because the computer has (misconfigured) RAID and so cannot mount /root.  When I tried to manually mount /dev/sda3, I get 

mount: unknown filesystem type 'linux_raid_member'

message, also fdisk shows /dev/sd[ab] all different sizes and type 83 Linux instead of expected fd raid autodetect.  When the system boots, I do see messages about RAID (with some complains about degradation; I'll address these once I can get root access).

As I see it, I have  a couple of options left (unless some kind soul here will help me to get it boot single w/out root password  :Very Happy:  ):Try to mount RAID in live CD and edit /etc/passwdTry to copy all custom PHP/shell script code and Postgres database (backups? What backups?   :Surprised:  ) using user-level account, reinstall Gentoo, recreate custom software

So any wise words?

----------

## xaviermiller

Hello,

Did you tried booting an other linux (liveCD/USB), then chroot that partition, then change the password ?

----------

## apeshansky

 *XavierMiller wrote:*   

> Hello,
> 
> Did you tried booting an other linux (liveCD/USB), then chroot that partition, then change the password ?

 

Yes, I did - same problem: cannot mount existing / with message

mount: unknown filesystem type 'linux_raid_member'

I also forgot to mention that there is no sudo on the box.

----------

## rh1

What LiveCd did you try? Maybe it doesn't have raid support? How about using systemrescuecd which i'm sure has raid/lvm,ect.. support on it.

----------

## jburns

Did you try adding the word single to the end of the kernel line instead of real_init=single.

----------

## apeshansky

 *rh1 wrote:*   

> What LiveCd did you try? Maybe it doesn't have raid support? How about using systemrescuecd which i'm sure has raid/lvm,ect.. support on it.

 

I used Gentoo minimal install CD (and also full Ubuntu desktop CD).  Both do have RAID support (I even did 

```
modprobe raid[01]
```

 to ensure that modules load), but if I understand this correctly, need some information to mount RAID.  (But what do I know - I am just a n00b, so I am asking my betters   :Embarassed:  )

I do have user-level access to the box I need to get in, so if the information is there somewhere, I'll get it (provided it is world-readable).

Thanks.

----------

## NeddySeagoon

apeshansky,

Press e at the grub menu and add  

```
init=/bin/bash
```

to the kernel line, or change it to that if there is an init= statement.

Then boot.

It will come up with just the root filesystem, and the kernel and nothing else. You will be root.

run

```
/bin/passwd
```

 you need to use full pathnames as there is no environment set.

Shutdown with 

```
/sbin/shutdown -h now
```

----------

## apeshansky

 *jburns wrote:*   

> Did you try adding the word single to the end of the kernel line instead of real_init=single.

 

Yes; it is ignored, and the box boots into runlevel 3.

Thanks.

----------

## apeshansky

 *NeddySeagoon wrote:*   

> apeshansky,
> 
> Press e at the grub menu and add  
> 
> ```
> ...

 

A-ha!  There was 

```
init=linuxrc
```

(or some such - the box is at the different location) parameter, but I did not touch it, hoping additional init= down the line will override it.  I'll try this.

Thank you.

----------

## NeddySeagoon

apeshansky,

Oh dear, you need to be at the console to do that, as no services are started.

----------

## apeshansky

 *NeddySeagoon wrote:*   

> apeshansky,
> 
> Oh dear, you need to be at the console to do that, as no services are started.

 

Yes, of course.  I meant "as soon as I get my hands on this sucker   :Very Happy:  "

----------

## apeshansky

 *NeddySeagoon wrote:*   

> apeshansky,
> 
> Press e at the grub menu and add  
> 
> ```
> ...

 

Well, what would you know: this did not work either.   :Sad: 

Caveat: I was not at the console, but I believe the guy I talked to did everything properly.  I had him to do it twice with written keypress-by-keypress instructions and me on the phone.

The system started at runlevel 3 with normal login prompt.

The original grub parameters are:

```
kernel /kernel-genkernel-x86_64-2.6.17-gentoo-r8 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/evms/root doscsi doevms2

initrd /initramfs-genkernel-x86_64-2.6.17-gentoo-r8
```

Any ideas?  Please?  Pretty please with sugar on top?    :Razz: 

----------

## NeddySeagoon

apeshansky,

Ah, ok - passing parameters to the initrd is doomed to fail.  It won't have bash.

Using init=/bin/bb or init=/bin/busybox  will get you a root shell in the initrd.

What you can do from there is fairly limited.  You should be able to mount root but its much harder.

Its easier to boot a CD that hass all the bits you need to miunt the root filesystem.

Boot normally then 

```
df -T
```

will tell you the filesystems in use, in case you have a rare one, like rieser4.

Oh ... you have root on evms.  (real_root=/dev/evms/root), so its not simple at all

----------

## apeshansky

 *NeddySeagoon wrote:*   

> apeshansky,
> 
> Ah, ok - passing parameters to the initrd is doomed to fail.  It won't have bash.
> 
> Using init=/bin/bb or init=/bin/busybox  will get you a root shell in the initrd.

 

Sorry, this did not work either (see my original message).  Unless I need to add

```
init=/bin/bb
```

to initrd line?  I only tried parameters in kernel line.

 *NeddySeagoon wrote:*   

> What you can do from there is fairly limited.  You should be able to mount root but its much harder.
> 
> Its easier to boot a CD that has all the bits you need to mount the root filesystem.
> 
> Boot normally then 
> ...

 

Don't I know that!

I think the only way short of reinstalling is to manually enter commands needed to mount root from liveCD prompt, but where are these commands?  Some configuration file on the box?

I suspect that just adding "doscsi doevms2" to liveCD boot won't help - will it?

----------

## NeddySeagoon

apeshansky,

It might.  look at the help on the liveCD boot screen. I don't remember if the liveCDs ever supported evms.

It looks like they did/do.  This wiki page looks useful.

Be careful you do not do any steps that are destructive to your data.

Googling for

```
 evms +gentoo
```

finds other hits too.  I have never used evms myself.

----------

## apeshansky

 *NeddySeagoon wrote:*   

> apeshansky,
> 
> It might.  look at the help on the liveCD boot screen. I don't remember if the liveCDs ever supported evms.
> 
> It looks like they did/do.  This wiki page looks useful.
> ...

 

OK, I did it!

For the posterity:

1. Boot from live CD; select 

```
gentoo-nofb doscsi doevms2
```

to activate evms.

2. Once in, start evms in command mode

```
evms
```

3. Answer "no" (default) to the question about volume <something>

4. Give evms command to mount your root volume (in my case /dev/evms/root) as 

```
Mount: /dev/evms/root, /mnt/gentoo
```

5. Exit evms with exit or quit.

6. Do 

```
chroot /mnt/evms /bin/bash
```

and change root password.

That did it!

----------

## mokia

I know. The topic is masked as solved, but I have the same problem for a while.

kernel hanged, and asked the root password.

```
Give root password for maintenance (or type Control-D to continue):
```

type root password, and its not working.

It was a keymap problem.

kernel used the en qwerty

and my system default was hu qwertz

so z y numbers and special characters are not on the right place.

After typing root password in qwery-s geometry the system let me in.

----------

## apeshansky

 *mokia wrote:*   

> I know. The topic is masked as solved, but I have the same problem for a while.
> 
> kernel hanged, and asked the root password.
> 
> ```
> ...

 

Well, I am pretty sure my problem was quite different.  To recap: root password unknown, boot used initframs, so all

```
init=/bin/bash
```

(or other shell) parameters in grub where ignored, 

```
real_init=/bin/bash
```

brought same prompt for root password, and attempts to mount existing root while booted from CD were rejected because of use of evms (LVM).

I am pretty sure I saw another thread with the same problem the quoted poster was having.

----------

## mokia

Well i'm only replied to this topic  *GPL wrote:*   

> in the hope that it will be useful

 

In future for someone. 

For gogling and searching users.  :Very Happy: 

So sorry, but my attention was fixed on "Give root password for maintenance (or type Control-D to continue):"

And simply swapped in my mind "unknown" wit "not working" 

Pls excuse my mistake.

----------

## cwr

The easiest way I've found to reset the root password is to boot off a CD,

mount the / partition, and edit the relevant /etc/passwd to remove the

first 'x' in root's entry.  Then boot normally and log in _without_ a root

password, and reset the password from there.

Will

----------

