Subject: Re: disklabel lost (ARGH)
To: Technolord <>
From: Thilo Manske <Thilo.Manske@HEH.Uni-Oldenburg.DE>
List: port-i386
Date: 09/14/2000 12:31:17
On Thu, Sep 14 2000 at 11:31:27 +0200, Technolord wrote:
> I have lost my disklabel (better, FDISK deleted it) and I need to
> re-build it, without re-formatting everything if possible (I no longer
> have an internet connection and fetching the packages without one is
> impossible to me...!)
> Is there an easy way to re-build it without too much pain or, if I have
> to disklabel it, what is the command line to install a new label?
> disklabel -e -I says "no disk label, use -I to create one"....!!!
Yeah, that's pretty annoying...

1. Well, if it's a disk with everything in one partition that's pretty simple:

# disklabel <disk> > tempfile
edit tempfile, i.e. copy the "everything" partition (d) and name
it a, change fstype to 4.2BSD, etc...

Some people/skripts etc. like to start at the second track and not sector 0,
so if this doesn't work set adjust start and size. (The number of
sectors/track is in the disklabel).

# disklabel -R <disk> tempfile

(This is the only way to create a disklabel on a disk without disklabel

2. If not then you need to know the sizes of every partition.

a) That's no problem if you have a copy of the disklabel somewhere (A
hardcopy is always a good idea.)

b) If not: The daily script keeps three copies (two current and one
old) of the disklabel of every atached disk in /var/backups/ (named
disklabel.<disk>.*). Of course only, if you have let daily run at least

If /var is on your f*cked up disk I see two options:	

i) If it's in the root and root is the physically first partition on the
disk.  create a disklabel with a single partition as above, mount the
partition *read-only* (because the size is wrong, so a write may f*ck it up
even more.) and look for the file.

ii) The brutal-force method:
strings < /dev/<disk>d|grep -A 30 "^# /dev/r<disk>d$"
This greps the disk for the contents of the disklabel.* files.
You will probably see multiple copies, some of them may be old...

(<disk> is wd0|sd0|...)


Other ports don't use "d" as the "whole disk" partition (we are here on
port-i386), I haven't tried all methods (the grepping works, just tried it
:-), there might be some errors in the instructions -> use at your own disk.
(But since you don't have a valid disklabel anyway I don't think anything
can go worse by following my ideas :-).

Dies ist Thilos Unix Signature! Viel Spass damit.