Forgotten Password

Holt Sorenson hso@nosneros.net
Mon, 11 Oct 2004 01:31:41 +0000


On Sun, Oct 10, 2004 at 01:59:43PM -0700, Stephen Schroder wrote:
 > I can't boot from the Linux floppy disc.  For some reason, maybe because 
 > I am dual booting with Windows, or because when I was setting up my 
 > system I did not include the floppy drive as an option for booting (if I 
 > was even given that option) the floppy drive does not function, even if 
 > I choose Windows.

It's likely your BIOS has your hard drive in the boot order before
your floppy disk and cdrom.

This should be changed so that you can boot from your floppy
or cd whether or not the hard drive is bootable.

My previous message was a bit terse. Given what your familiarity
with linux seems to be after these messages I'm going to recommend
that you not follow my or anyone else's advice to use the init=/bin/bash
kernel parameter at boot. Depending on your distro (theoretically
debian, given this is bad) your version, what filesystem you're using,
and what's in your fstab and lilo.conf there are a couple different
permutations on the particular commands that you'll have to use to
get to the point where you can do anything from the root prompt
you'll get. Also, the root prompt you'll be getting isn't started
by login, so some of the key bindings that you're possibly used to
probably won't work. There's also numerous ways in which you can
shoot yourself in the proverbial foot. So, let's start over again.

Download the latest knoppix:
ftp://ftp.webtrek.com/pub/mirrors/knoppix/KNOPPIX_V3.6-2004-08-16-EN.iso

Burn it to CD and then start up your machine with it in the drive.

It will prompt you with 'BOOT:'

Press Enter (or if you wait for a bit, it will start booting).

Once knoppix is done booting, you'll have x-windows in front of
you. Close the knoppix info window.

Down at the bottom of the screen, there will be a terminal icon on the
menu bar. Use it to start up a terminal. When you get a shell,
become root using 'su -'.

Now type 'fdisk -l'.

All the hard disks in your machine with their partitions will be
listed. You'll have to read through the output to determine
what partition you'll be mounting in a second. You're looking
for a line that has Linux in the last (aka System) column. It's
possible there are multiple lines like this. If there are, you'll
have to mount each of them until you find the one that has
/etc in it. The examples below also assume IDE hard drives. If
you have SCSI hard drives the name of the devices will be 'sd'
instead of 'hd'.

Count the number of Linux partitions and make mount points
for each of them. The example assumes that you have found
3 Linux partitions:

mkdir -p /mnt/hd{1,2,3}

Now mount each partition:
mount /dev/hda1 /mnt/hd1
mount /dev/hda2 /mnt/hd2
mount /dev/hda3 /mnt/hd3

(The number of the partition and the mount point, don't have to be
the same).

Next type:
find /mnt/hd* \( -name passwd -o -name shadow \)

find should display where it finds the passwd (and, if
configured, the shadow) file(s). You're interested
in the portion /mnt/hd<some_number>, as you're going
to use it for the next step.

Assuming find shows that it found the passwd file in
/mnt/hd1/etc/passwd, type:

chroot /mnt/hd1 /bin/bash

Now type:
passwd root

and then change the password.

Type exit to leave the chroot'd shell.

sync the filesystem data in memory to the disk using:
sync;sync;sync

Unmount each of the partitions:
umount /mnt/hd1
umount /mnt/hd2
umount /mnt/hd3

If the chroot doesn't work, find doesn't find passwd or shadow,
or something else goes wrong, you probably need to just re-install.

If you have data on one of the linux partitions that you want
to to keep, you should copy it out of the mount points above
onto a floppy, usb key, or something before you re-install.

Once you're all done, you can reset your computer and eject
the cd before it starts be boot sequence again.

Hopefully if all goes well, you'll be back into your system.

-Holt