So assuming we're talking about FreeBSD it really isn't too hard. Though some familiarity with the command line environment is definitely recommended. Still...
Boot using whatever boot media you have. What I usually do is grab a
disc1 ISO image and then burn that to CDR, which I then use to boot my stuff. I prefer this method because the installation disk also contains a fairly complete live environment, including manualpages (documentation).
Tell it to start the live cd and then log on as
root, you don't need a password.
Next: determine where your original installation is located. You can do this using
sysctl kern.disks
which gives you an overview of all storage media, then you can verify with
gpart show
:
Code:
peter@zefiris:/home/peter $ sysctl kern.disks
kern.disks: ada2 ada1 ada0 cd1 cd0
peter@zefiris:/home/peter $ gpart show ada0
=> 40 312450656 ada0 GPT (149G)
40 256 1 freebsd-boot (128K)
296 312450400 2 freebsd-zfs (149G)
Well... that
definitely looks like a valid FreeBSD environment to me, including a boot setup.
So... under normal circumstances you have 2 options; you're using ZFS or UFS, and this should be visible when using
gpart (you'd be looking at a partition type of
freebsd-ufs or the above).
Next step: gaining access to your system. Which can be tricky because there are also many partition schemes, two of the most commonly used being MBR or GPT. The easiest way to determine what we need is using
/dev. Above I can see that I want to access the 2nd partition of my
ada0 disk. So:
Code:
peter@zefiris:/home/peter $ ls /dev/ada0*
/dev/ada0 /dev/ada0p1 /dev/ada0p2
There's no way around it: I need
/dev/ada0p2. If I were using GPT I'd be looking at an entry such as
ada0s2. No need to remember all that theory: just peek in
/dev to see what you need.
Now... if the filesystem is UFS then things are decently easy:
# mount /dev/ada0p2 /mnt
. This would make your system accessible under
/mnt.
So, to clear out your root password the easiest way I can think off is what
Bobi B. already suggested:
# chroot /mnt
and then simply run
# passwd
. Simply escape (control-d), umount the system just to be safe using:
# umount /mnt
and then reset.
When working with ZFS things become a bit more tricky. Start by using:
# zpool import
to load the required kernel modules and to see if it lists any ZFS pools. If so use something like this:
zpool import -fNR /mnt zroot
. This assuming your pool was actually called
zroot.
Now check that you can actually access the available filesystems by using:
zfs list
, this should show you all your defined stuff. Assuming you let the installer handle everything you'd be looking for:
zroot/default/ROOT. Mount it:
# zfs mount zroot/default/ROOT
, from the top of my head (meaning: I'm 70% certain) this should make the filesystem available under
/mnt.
Just verify that
/mnt/etc exists, and when it does use the same
chroot operation as mentioned earlier.
That should deal with it.