About my problem

Matthew Seaman m.seaman at infracaninophile.co.uk
Wed May 14 02:38:33 PDT 2003

On Wed, May 14, 2003 at 02:18:22AM -0500, Teilhard Knight wrote:
> For those who do not know what I am talking about, this is what is
> happening to me:
> I have compiled my kernel. Everything seems to be all right, 
> except that on boot it cannot mount root.
> It displays: "mounting root from ufs:ad2s2a", and a failure message.
> Now, I am left at boot with an inquire for a manual root filesystem
> specification., like this:
> <fstype><device> mount <device> using filesystem <fstype>
> eg. ufs:/dev/da0s1a
> ? List valid disk boot devices
> <empty line> abort manual imput
> mountroot>
> The HD where FreeBSD is installed is ad2 in my previous kernel and in
> this new one it is ad1. I have now found out that this is the source of
> the problem. I checked the partition table, and the slices are called
> ad2s2a ---> ad2s2g. If this is the case, no way I can mount root on a
> disk called ad1 with those slices.
> So, I'll pose a different question. Do you know of a possible way I can
> make my new kernel to spot my HD as ad2? To me this is the only solution
> possible.

Hmmm... It's not impossible to recover from the situation you're in
without having to do anything unaesthetic, like re-installing.  It is,
however, fairly tricky and requires use of some quite unfriendly

Your aim is simply to edit /etc/fstab and change all references to ad2
over to ad1.  Since the fstab is not correct for your current machine,
you can't boot to multiuser mode.  You can, however, boot to single
user mode with the root partition you tell the kernel as above.  After
power-on, interrupt the 10 second count down, and at the boot loader
prompt type:

    set root_disk_unit=1
    boot /kernel -s

This should get you to the single user prompt, but with the root
partition mounted read-only.  In order to remount the root partition
read-write, you need to do two things.  First, run fsck(8) to clean up
the file system and then run mount(8).  Catch22 is that both of those
commands will use /etc/fstab as a database of filesystems to work on,
unless you take care to avoid that.  Assuming that your root partition
is on /dev/ad1s1a, run:

    # fsck /dev/ad1s1a
    # mount -u -o rw -t ufs /dev/ad1s1a /

(Basically, you need to supply all required arguments to mount(8), to
stop it going to /etc/fstab to try and look them up.)

Now you've got the root partition mounted read-write, you can edit the
/etc/fstab file.  The tricky bit is that you only have the commands in
/bin available to do the editing with (assuming that you've used the
usual /, /usr partition layout).  That means that you now have to get
down and dirty with ed(1) --- the Unix editor of last resort.  This
command was originally designed for use on a teletype printer, so it
doesn't show you a listing of the whole file and let you navigate
around it in a natural way.  The command syntax is a bit intimidating
to the uninitiated too.  You can see the ed(1) man page at


Try this:

Nb. You type the lines marked '<--' in the ed session.

    # cd /etc
    # cp fstab fstab.bak
    # ed fstab
    448                            (--> ed outputs the size of the file here)
                                   (<-- hit return, to get the ? prompt)
    ?                              (--> ed output)
    ,s/ad2/ad1/g                   (<-- substitute 'ad1' for 'ad2' everywhere)
    ,w                             (<-- write out the changed file)
    448                            (--> ed tells you the modified file size)
    q                              (<-- quit ed)
    # cat fstab

Check the new contents of the fstab file for sanity.  If you're happy,
then try and fsck and mount all your filesystems:

    # fsck -p
    # mount -a

If that works satisfactorily, you're done, and you can just type

    # reboot

and the system *should* come up smoothly.


Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20030514/f5c6054b/attachment.bin

More information about the freebsd-questions mailing list