root password lost

hi
i use suse 13.2 and i lost my root password.
i use btrfs and my hard drive is encrypted (i know this password).

my fstab:

devtmpfs                    8116040         0    8116040   0% /dev
tmpfs                       8122920     67632    8055288   1% /dev/shm
tmpfs                        162460      2328     160132   2% /run
tmpfs                       8122920         0    8122920   0% /sys/fs/cgroup
/dev/mapper/system-root    20971520  16433444    3536860  83% /
tmpfs                        812296      1204     811092   1% /tmp
/dev/mapper/system-root    20971520  16433444    3536860  83% /.snapshots
/dev/mapper/system-root    20971520  16433444    3536860  83% /var/log
/dev/sdb5                  45225008  11253180   32895608  26% /music
/dev/sda2                    417792     66096     350676  16% /boot
/dev/mapper/system-root    20971520  16433444    3536860  83% /var/tmp
/dev/mapper/system-root    20971520  16433444    3536860  83% /var/spool
/dev/sda1                    159564      4916     154648   4% /boot/efi
/dev/mapper/system-root    20971520  16433444    3536860  83% /var/opt
/dev/mapper/system-root    20971520  16433444    3536860  83% /var/lib/mailman
/dev/mapper/system-root    20971520  16433444    3536860  83% /var/lib/named
/dev/mapper/system-root    20971520  16433444    3536860  83% /var/lib/pgsql
/dev/mapper/system-root    20971520  16433444    3536860  83% /var/crash
/dev/mapper/system-root    20971520  16433444    3536860  83% /usr/local
/dev/mapper/system-root    20971520  16433444    3536860  83% /srv
/dev/mapper/system-root    20971520  16433444    3536860  83% /opt
/dev/mapper/system-home   226398208 112065936  112833200  50% /home
/dev/sdc5                 961270996 262360216  697917644  28% /run/media/collinm/8fa0251f-fdd4-459e-8763-846a8287db89

i can boot on a use live disk or something like that but how to mount my encrypted partition to reset my root password?

Rule 1: before you encrypt a disk, make sure that you know how to manually decrypt and access from live media.
Rule 2: after you encrypt a disk, practice the manual method occasionally.

In any case, here’s what you probably need to do:


# cryptsetup luksOpen /dev/sdXY cr_lvm
# vgchange -a y
# mount /dev/mapper/system-root /mnt
##### the next few are probably not needed for changing password
# mount /dev/sda2 /mnt/boot
# mount /dev/mapper/system-home /mnt/home
# mount --bind /dev /mnt/dev
# mount --bind /sys /mnt/sys
# mount --bind /proc /mnt/proc

I gave the full list of mounts for more complex problems. For changing password, you probably only need to mount the root file system. Also, I don’t use “btrfs”. I’m assuming that the various subvolumes will be automatically mounted. If not, you might have to use additional mount commands for some of those.

In the first command I gave, change “/dev/sdXY” to whatever partition is encrypted.

When all is mounted:


# chroot /mnt
# passwd

and you should be prompted for the new password (twice).

On 2015-07-08 05:56, nrickert wrote:
> When all is mounted:
>
> Code:
> --------------------
>
> # chroot /mnt
> # passwd
>
> --------------------
>
> and you should be prompted for the new password (twice).

root only gets asked once. At least it was so the last time I tried.
The rationale was that he can change it again just as easily… he is
root, after all :slight_smile:


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))