How-to Reset root password

SLES10 (not sure of the SP level). I have googled this and found different ways to reset the root password but none has worked. The 2 ways i have tried is:
1)boot from SLES10 install DVD and select rescue system. Vim /etc/shadow and remove the second field after the word root::xxxx:::::::, then :wq to save and exit vim. Reboot server and at the grub prompt enter “single”. The following instructions are SLES should ask me to login to rescue but in fact the prompt asks me to enter the root login (i have tried no password, just pressing enter).
2)boot on knoppix live CD and basically follow the above steps and end at the same prompt
3)boot from install DVD, rescue system and passwd; deleted root password with passwd -d root (didn’t work) then tried passwd get some weird error about unknown auth mechanism

Can someone tell me how to correctly reset the root password?

[QUOTE=carnold6;3023]SLES10 (not sure of the SP level). I have googled this and found different ways to reset the root password but none has worked. The 2 ways i have tried is:
1)boot from SLES10 install DVD and select rescue system. Vim /etc/shadow and remove the second field after the word root::xxxx:::::::, then :wq to save and exit vim. Reboot server and at the grub prompt enter “single”. The following instructions are SLES should ask me to login to rescue but in fact the prompt asks me to enter the root login (i have tried no password, just pressing enter).
2)boot on knoppix live CD and basically follow the above steps and end at the same prompt
3)boot from install DVD, rescue system and passwd; deleted root password with passwd -d root (didn’t work) then tried passwd get some weird error about unknown auth mechanism

Can someone tell me how to correctly reset the root password?[/QUOTE]

With SLES 10 / SLES 11 you should be able to boot into the bash shell and reset the password directly (no other boot/rescue CD needed)

At the boot screen enter ’ init=/bin/bash ’ as extra boot option and let the system boot (assuming you are using the GRUB boot loader). This should bring you to a shell prompt with root mounted.

Enter ‘passwd’ and enter your new password twice.

reboot the system using - let it boot normally - and you should be able to login as root with the new set password.

Exact steps can be found here : http://www.susegeek.com/general/how-to-resetrecover-the-root-password-in-opensuse/

Hope that helps,
Willem

Anyway to get the usb keyboard to work in this mode? I don’t have PS/2 connections on this server, usb only. I am sitting at the bash prompt but my keyboard does not work. Is there some way to tell it to use usb?

Fish and chips… no, not that I know of.

Then it’s back to using the SLES 10 DVD.
Boot into rescue mode and when booted log into the console of the rescue mode.
Then mount the root partition of your system under /mnt
chroot to /mnt (so /mnt is not / and /mnt/etc containing the password and shadow file is under /etc)
run the passwd command to change the root password
reboot

find the exact procedure here : http://www.novell.com/support/php/search.do?cmd=displayKC&docType=kc&externalId=3003803&sliceId=1&docTypeID=DT_TID_1_1&dialogID=313122082&stateId=0%200%20313120375

Hope that helps,
Willem

Here is part of the problem, i can not seem to find the root partition. When i fdisk -l, i have sda1-sda6. If i mount sda1, that is the dell utility partition. Sda2 is Linux LVM. Sda3 has the “*” under the boot label. Sda4 is, under the “System” label, W95 Ext’d (LBA) and when i mount it, i get can not determine filesystem and it will not mount. Sda5 is swap and sda6 is Linux LVM.

carnold6 wrote:
[color=blue]

Here is part of the problem, i can not seem to find the root
partition. When i fdisk -l, i have sda1-sda6. If i mount sda1, that
is the dell utility partition. Sda2 is Linux LVM. Sda3 has the “*”
under the boot label. Sda4 is, under the “System” label, W95 Ext’d
(LBA) and when i mount it, i get can not determine filesystem and it
will not mount. Sda5 is swap and sda6 is Linux LVM.[/color]

If sda3 is your boot partition, then perhaps / is a LV in one of your
LVM partitions.

See if this Cool Solution helps:
Mounting a Root Partition in a Logical Volume
http://www.novell.com/coolsolutions/tip/19710.html


Kevin Boyle - Knowledge Partner
If you find this post helpful and are using the web interface,
show your appreciation and click on the star below…

With this command you can see the partition contained in your LV


fdisk -l -u /dev/vg1/lv1

This command does nothing on our box. /dev does not have vg* it does have vcs1-6. When running fdisk -l -u /dev/vcs1/lv1 also produces nothing. When booting, the grub menu gives only sles10 entries so it is not a dual boot. It has to be a vm installed in sda3, right?

carnold6 wrote:
[color=blue]

It has to be a vm installed in sda3, right?[/color]

I don’t know… You didn’t say what this system was.

Is this server hosting VM’s?

Are you using Xen?

Have you setup VM’s (DomU’s) to use a Logical Volume for storage? If
so, then one of them may very well be one of your VM’s.

If your system can boot, then the / partition has to be somewhere. If
you can eliminate various partitions you may be able to isolate the one
that contains /.

Do you know if / is a partition or a Logical Volume?

Can you post the output from the fdisk command? It will make it easier
for us to offer additional suggestions.

fdisk -l


Kevin Boyle - Knowledge Partner
If you find this post helpful and are using the web interface,
show your appreciation and click on the star below…

[QUOTE=KBOYLE;3041]carnold6 wrote:
[color=blue]

It has to be a vm installed in sda3, right?[/color]

I don’t know… You didn’t say what this system was.

Is this server hosting VM’s?

Are you using Xen?

Have you setup VM’s (DomU’s) to use a Logical Volume for storage? If
so, then one of them may very well be one of your VM’s.[/quote]
I did not setup this server, so i do not know the configuration. A client called and asked if i could reset their linux password and that was it.

[quote]If your system can boot, then the / partition has to be somewhere. If
you can eliminate various partitions you may be able to isolate the one
that contains /.[/quote]
It does boot, just can not login cause no one remembers the password

See above response. Tried to call and ask client. Awaiting a return call.

[quote]Can you post the output from the fdisk command? It will make it easier
for us to offer additional suggestions.[/quote]
Here is my translation as posted earlier:
fdisk -l, i have sda1-sda6. If i mount sda1, that is the dell utility partition. Sda2 is Linux LVM. Sda3 has the “*” under the boot label. Sda4 is, under the “System” label, W95 Ext’d (LBA) and when i mount it, i get can not determine filesystem and it will not mount. Sda5 is swap and sda6 is Linux LVM

I plugged the server drive into our SLES11 server via usb and ran:

fdisk -l

Disk /dev/sdb: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders, total 488281250 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa0000000

Device Boot Start End Blocks Id System
/dev/sdb1 63 112454 56196 de Dell Utility
/dev/sdb2 112640 16889855 8388608 8e Linux LVM
/dev/sdb3 * 16900380 17318069 208845 83 Linux
/dev/sdb4 17318070 488279609 235480770 f W95 Ext’d (LBA)
/dev/sdb5 17318133 20402549 1542208+ 82 Linux swap / Solaris
/dev/sdb6 20402613 488279609 233938498+ 8e Linux LVM

carnold6 wrote:
[color=blue]

Device Boot Start End Blocks Id System
/dev/sdb1 63 112454 56196 de Dell Utility
/dev/sdb2 112640 16889855 8388608 8e Linux LVM
/dev/sdb3 * 16900380 17318069 208845 83 Linux
/dev/sdb4 17318070 488279609 235480770 f W95 Ext’d
(LBA)
/dev/sdb5 17318133 20402549 1542208+ 82 Linux swap /
Solaris
/dev/sdb6 20402613 488279609 233938498+ 8e Linux LVM[/color]

sdb1 is ~27 MB Dell Utility

sdb2 is 4 GB LVM

sdb3 is 100 MB boot

sdb4 is ~112 GB extended partition

sdb5 is ~753 MB Linux swap

sdb6 is ~111 GB LVM

Let’s look at what we have and maybe we can determine where / is:

  1. sdb3 is the partition we boot from. It could be / but because it is
    only 100 MB I expect it is just a boot partition (/boot).

  2. sdb4 is an extended partition. It is just a container for sdb5 and
    sdb6 so we don’t have to worry about it.

  3. sdb1 and sdb4 are the Dell and swap partitions so they can be
    excluded.

  4. sdb2 and sdb6 are managed by LVM and likely contain one or more
    logical volumes.

Since that’s all there is, my guess would be that / is a LV on sdb2 or
sdb6.

If we know the names of the volume groups and logical volumes, we can
then mount the logical volumes. It’s been a while since I did this, and
I am unable to boot into rescue mode at this time to try it but here is
how to get the VG/LV names…

First scan the disk to find the Volume Groups:

server:~ # lvm pvscan
PV /dev/sdc    VG vg200   lvm2 [1.33 TB / 0    free]
PV /dev/sdb1   VG vg100   lvm2 [488.26 GB / 143.26 GB free]
Total: 2 [1.81 TB] / in use: 2 [1.81 TB] / in no VG: 0 [0   ]

The name of the volume group is shown immediately after the “VG”
(e.g.vg200). There may be more than one volume group shown.

To see the logical volumes in a volume group, the volume group must be
activated with the vgchange command. For substitute the
Volume Group name returned by your pvscan command. (e.g. vg200).

server:~ # lvm vgchange -ay <Volume Group>

Now, we scan for Logical Volumes with the lvscan command.

server:~ # lvm lvscan
ACTIVE            '/dev/vg200/v200' [1.33 TB] inherit

In this example we see the logical volume name is v200. Your LV name is
probably different but We now have the information needed to mount the
volume.

Finally we can mount the LV using the information returned by the
lvscan command. For example:

server:~ # mount /dev/vg200/v200 /mnt

Of course you would substitute your own volume group and logical volume
name. If the name of the LV used for / is not obvious, you may have to
unmount the volume and try another one from the same or a different
Volume Group.

When you are finished working with a particular Volume Group you should
deactivate it so it is no longer accessible:

server:~ # lvm vgchange -an <Volume Group>

Note the difference from the first time: “-an” will deactivate; “-ay”
will activate.

This is pretty much from memory and few reference documents. I hope it
helps.


Kevin Boyle - Knowledge Partner
If you find this post helpful and are using the web interface,
show your appreciation and click on the star below…

Many thanks for that!! A good memory you have there, I might add!!
The results from your post=mounted /dev/system/root_lv ?there were 7 logical drives.)
From here I chroot to /mnt and ran passwd and this gave me a unknown user. From here I cd’d to etc and then. Then vim shadow. Removed the entry between the first and second “:”. Reboot and enter root as username and press enter for password, authentication failed. This may be a ldap server? Is it possible to have root and password in ldap? Maybe this is why I was getting the unknown user running passwd.

carnold6 wrote:
[color=blue]

authentication failed.[/color]

Perhaps Magis31 can help. I have no experience in this area.

Glad I was able to help you find /. :slight_smile:


Kevin Boyle - Knowledge Partner
If you find this post helpful and are using the web interface,
show your appreciation and click on the star below…

[QUOTE=KBOYLE;3058]carnold6 wrote:
[color=blue]

authentication failed.[/color]

Perhaps Magis31 can help. I have no experience in this area.

Glad I was able to help you find /. :slight_smile:
[/QUOTE]

Ok, another approch (slighly). Simply editing /etc/shadow and rebooting will not work on SLES due to higher security settings that have been configured in the authentication modules.

  1. As a first, place the disk back (if not already done so) in the server it belongs to and boot using the SLES DVD with rescue mode selected.

  2. Enter the console of rescue mode and mount the root of the system’s disk you are trying to reset the password for under /mnt

  3. Activate the LVM system & mount the root under /mnt

#vgscan
#vgchange -a y system
#mount /dev/[VGSYSTEM NAME]/[LV ROOT VOLUME NAME] /mnt

  1. Let’s check root’s user id is indeed defined as 0

cat /etc/passwd|grep root

root:x:0:0:root:/root:/bin/bash

  1. As you are editing the shadow file and not using the passwd command, you don’t need to chroot. (Just the mount for system’s root under /mnt)

#vi /mnt/etc/shadow

IMPORTANT: remove the set encrypted password value and leave 8 :'s without any values inbetween

make sure to use :w! (to force the write) and then :q to exit, then check if the values have been written as intended

  1. Check if /mnt/etc/shadow contains what you entered

cat /mnt/etc/shadow|grep root

root::::::::

again NOTE : there are 8 : after root

  1. Now reboot the system and boot into single user mode (enter " init 1 " as boot option at the Linux boot screen)

  2. When booted login as root (without password)

  3. run the passwd command and enter the new desired password

  4. reboot… and hopefully…

…that does the trick!

-Willem

Magic31, thank you soooo much! That worked. 7 logical drives all named /opt_lv, /home_lv, /etc_lv and so on!!! This was installed with a winblows disc that allows you to install different OS’s.
KBoyle, thank you for all your help!

[QUOTE=carnold6;3119]Magic31, thank you soooo much! That worked. 7 logical drives all named /opt_lv, /home_lv, /etc_lv and so on!!! This was installed with a winblows disc that allows you to install different OS’s.
KBoyle, thank you for all your help![/QUOTE]

Good to hear! And glad it worked.

And, you’ve now created one thread with many different options for others to try if facing something similar :slight_smile:

Also to answer/note, yes, the partitioning you showed earlier kind of shows this was not an install done by someone with a deeper Linux background… or forced to do it in this manner for some reason or other (leaving that extended & Windows partition on there like that).

I usually stick to partitioning with two primary (non LVM) partitions for /boot, and / (root). Then stick the rest (including swap) in LVM where there are at least two VG’s to clearly split the OS mounts (like /var itself in VGSYS) and other type data in the other (like /var/yourapplication in VGDATA). That on a side note…

-Willem

[QUOTE=carnold6;3043]I plugged the server drive into our SLES11 server via usb and ran:
Device Boot Start End Blocks Id System
/dev/sdb1 63 112454 56196 de Dell Utility # this is the dell partition, we don’t need it
/dev/sdb2 112640 16889855 8388608 8e Linux LVM # this is an LV, probably root
/dev/sdb3 * 16900380 17318069 208845 83 Linux # this should be the /boot
/dev/sdb4 17318070 488279609 235480770 f W95 Ext’d (LBA) # extended partition
/dev/sdb5 17318133 20402549 1542208+ 82 Linux swap / Solaris # swap
/dev/sdb6 20402613 488279609 233938498+ 8e Linux LVM[/QUOTE] # data partition?

Boot with SLES10 CD → Rescue System

mkdir /mnt/system
lvscan # will give you the physical volume(s) in the volume group and the lv names
vgchange -ay volumegroupname
mount /dev/volumegroupname/root-lv-name /mnt/system
mount /dev/sdb3 /mnt/system/boot

probably not needed, but anyway:

mount /dev/volumegroupname/another-lv-name /mnt/system/where-it-belongs

mount -o bind /dev /mnt/system/dev
mount -t sysfs none /mnt/system/sys
mount -t proc none /mnt/system/proc

chroot /mnt/system

now within the installed system:

passwd

then exit from chroot, umount everything, and reboot.

sorry, missed the newer messages in “More replies below current depth…” :slight_smile:

[QUOTE=carnold6;3052]Many thanks for that!! A good memory you have there, I might add!!
The results from your post=mounted /dev/system/root_lv ?there were 7 logical drives.)
From here I chroot to /mnt and ran passwd and this gave me a unknown user.[/QUOTE]
Have you had a look at the passwd file? Is there an entry for “root” (should be, even on an LDAP system).

If things get to time-intensive - add another entry to the /etc/passwd file with a different name, ie “root2”, uid 0, gid 0, no password, shell and home dir as needed. you should then be able to log in as that user when the system is up.

Or remove the indicator value in the password field of the root user entry in /etc/passwd, this may allow you to log in as root without password when in single-user mode, too.

If you want to verify the location of the root partition, just to be sure you’re editing the right files: When in rescue mode, mount the boot partition (partition 3 in your case, iirc) and check GRUB’s “grub/menu.lst” file - your “kernel” lines ought to have a “root” parameter naming the proper LV.

Regards,
Jens

At the boot screen enter ’ init=/bin/bash ’ as extra boot option and let the system boot (assuming you are using the GRUB boot loader). This should bring you to a shell prompt with root mounted.

If under xen environment. this way was worked under my sles11sp2.

xen-dom0:/etc/xen/vm # cp my-domu my-domu-rescue ← backup
xen-dom0:/etc/xen/vm # cat my-domu-rescue
:
extra=" init=/bin/bash" <---- change this line
:
xen-dom0:/etc/xen/vm # xm create -c my-domu-rescue

from yast2(GUI) > Virt-Manager > open MyVm screen

$ passwd

new-root-passwd
retype new-root-passwd
$

but noway to accept ‘shutdown -h 0’ command so I did ‘xm destroy myvm’ and

xen-dom0:/etc/xen/vm # xm create -c my-domu

root password was reset successfully.


#xm create -c myvm extra= single
require root password under sles11sp2.

I hope work fine for everybody.