Last modified: Mar. 7, 2010
Contents
1 - Summary
2 - Console set to secure
3 - Console set to insecure
1 - Summary
This guide will show how to reset the root password in case you forgot it.
This has been tested in FreeBSD 7.0, 7.1, 7.2 and 8.0.
2 - Console set to secure
This method works where the console is set to secure in the /etc/ttys file.
When booting into single-user mode it doesn't prompt for the root password.
Do the following to boot into single-user mode. Press 6 go to a loader prompt
and then type the following.
OK boot -s
Press [Enter] to get to the shell.
Enter full pathname of shell or RETURN for /bin/sh:
Run fsck to check the consistency of the file systems.
# fsck -p
/dev/da0s1a: FILE SYSTEM CLEAN; SKIPPING CHECKS
/dev/da0s1a: clean, 171108 free (2388 frags, 21090 blocks, 0.9% fragmentation)
/dev/da0s1h: FILE SYSTEM CLEAN; SKIPPING CHECKS
/dev/da0s1h: clean, 218673572 free (28 frags, 27334193 blocks, 0.0% fragmentation)
/dev/da0s1g: FILE SYSTEM CLEAN; SKIPPING CHECKS
/dev/da0s1g: clean, 5077067 free (27 frags, 634630 blocks, 0.0% fragmentation)
/dev/da0s1d: FILE SYSTEM CLEAN; SKIPPING CHECKS
/dev/da0s1d: clean, 5077074 free (42 frags, 634629 blocks, 0.0% fragmentation)
/dev/da0s1f: FILE SYSTEM CLEAN; SKIPPING CHECKS
/dev/da0s1f: clean, 4947765 free (5173 frags, 617824 blocks, 0.1% fragmentation)
/dev/da0s1e: FILE SYSTEM CLEAN; SKIPPING CHECKS
/dev/da0s1e: clean, 253006 free (158 frags, 31606 blocks, 0.1% fragmentation)
Mount all the file systems.
# mount -a
Reset the password for the root user.
# passwd root
Changing local password for root
New Password: ********
Retype New Password: ********
Reboot the system and log in with the root account using the new password.
# shutdown -r now
3 - Console to to insecure
This method works where the console is set to insecure in the /etc/ttys file.
When booting into single-user mode it does prompt for the root password. Boot
from the installation CD. Select a country at the Country Selection menu and
hit [Enter]. Select the Fixit option from the sysinstall Main Menu. Select the
CDROM/DVD option to use the "live" filesystem CDROM/DVD. Eject the installation
CD and insert the FreeBSD live filesystem CD/DVD and press [Enter].
Get a list of the disks.
Fixit# sysctl kern.disks
kern.disks: da0
Get information about the hard disk.
Fixit# dmesg | grep "^\da0" | uniq
da0 at twa0 bus 0 target 0 lun 0
da0: <AMCC 9500S-8 DISK 2.06> Fixed Direct Access SCSI-3 device
da0: 100.000MB/s transfers
da0: 476816MB (976519168 512 byte sectors: 255H 63S/T 60785C)
Run fsck to check the consistency of the / file system.
Fixit# fsck -y -t ufs /dev/da0s1a
fstab: /etc/fstab:0: No such file or directory
fstab: /etc/fstab:0: No such file or directory
** /dev/da0s1a
** Last Mounted on /
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
1847 files, 82707 used, 171108 free (2388 frags, 21090 blocks, 0.9% fragmentation)
***** FILE SYSTEM IS CLEAN *****
Mount the / file system with read and write access.
Fixit# mount -w -t ufs /dev/da0s1a /mnt
View information about the file systems.
Fixit# cat /mnt/etc/fstab
# Device Mountpoint FStype Options Dump Pass#
/dev/da0s1b.eli none swap sw 0 0
/dev/da0s1a / ufs rw 1 1
/dev/da0s1h /data ufs rw 2 2
/dev/da0s1g /home ufs rw 2 2
/dev/da0s1d /tmp ufs rw 2 2
/dev/da0s1f /usr ufs rw 2 2
/dev/da0s1e /var ufs rw 2 2
/dev/acd0 /dvd cd9660 ro,noauto 0 0
Mount the /usr file system with read access.
Fixit# mount -r -t ufs /dev/da0s1f /mnt/usr
Change the root directory to point to /mnt and run the passwd command for the
root user.
Fixit# /mnt/usr/sbin/chroot /mnt /usr/bin/passwd root
Changing local password for root
New Password: ********
Retype New Password: ********
Exit the fixit session.
Fixit# exit
Eject the FreeBSD fixit CDROM/DVD and insert the installation CD. Select Exit
at the menu and Exit Install at the sysinstall Main Menu. Eject the
installation CD and select Yes to reboot.
|