I have made an entry in /etc/disktab
, but
when I try to label the drive the following happens:
mips# disklabel -w /dev/sd1 sea32550N disklabel: ioctl DIOCWDINFO: Operation not supported by deviceWhat am I doing wrong?
Answer:
Doing this using disklabel
(and fdisk
) is probably
harder than using sysinstall
. The following should work to
put FreeBSD-2.0.5 on the whole of an empty disk assuming that
the disktab
entry is correct.
disklabel -r -w /dev/rsd1 sea32550N ^^ ^The first
-r
is essential for writing new labels and using
the raw device instead of the block device is good technique. To
be ``empty'' the disk should have 0's at critical points on the
first two sectors. In particular, the 2 byte signature at the
end of the first sector must not be 0xaa55
or the disk will
be interpreted as having a slice (partition) table and it will be
difficult to write to it where you want unless the slice table is
initialized correctly. All bootable hard disks will have the
0xaa55
signature so they won't be empty. Empty disks may be
created by copying zeros over the first 2 sectors:
dd if=/dev/zero of=/dev/rsd1 bs=1k count=1
Note that this will (appear to) destroy all data on the disk.
The above is not the best method. Normally you will have a slice table or a label that you want to preserve or modify slightly. This can be done using
fdisk -u /dev/rsd1 # install or change slice table disklabel -r -w sd1 sea32550N # install label ^no /dev/r
fdisk
is unintuitive and has poor error handling so it is
difficult to change slice tables using it. However, to install a
new slice table on an empty drive you just have to accept all the
defaults except for ``n'' to write at the end.
Note that the sd1
drive in the above is different from
/dev/rsd1
. disklabel
modifies path names that
don't start with a slash by prefixing /dev/r
and
suffixing the ``raw'' partition letter. sd1
thus means
/dev/rsd1c
, i.e., the ``c
'' partition on the first
BSD slice on drive sd1
, i.e., the whole of the first BSD
slice on drive sd1, while /dev/rsd1
is the whole of
drive sd1. Thus ``disklabel ... sd1
'' will fail if
there is no FreeBSD slice, while ``disklabel /dev/rsd1
''
will print the in-core label for the whole drive. Oops, this
assumes that slices are enabled by the 0xaa55 signature. If
slices aren't enabled, then /dev/rsd1c means the whole drive. In
practice, slices have to be enabled to make the disk bootable.
If there are no BSD slices, then /dev/rsd1c
will be
empty instead of unconfigured and attempts to label sd1
will
fail with a bogus error message about /dev/rsd1c
not
existing.
/dev/sd1
didn't exist in previous versions of FreeBSD or
386BSD so your ``disklabel -w /dev/sd1 ...
'' would have
printed a less confusing error message before failing.
The disklabel I'm trying is sea32550N|Seagate 32550N:\ :ty=winchester:dt=SCSI:se#512:nc#3510:nt#11:ns#108:\ :rm#7200:\ :pa#2433024:oa#0:ta=4.2BSD:\ :pc#4169880:oc#0:Note that
ns
has to be < 64 in the slice table. I would use
nt#22:ns#54
. This only matters if you don't accept
fdisk
's default (bogus) slice table. You have to use a
valid table if you want multiple slices, or the first slice
starting at a nonzero offset. Starting a nonempty slice at
offset 0 is invalid so sysinstall
doesn't support creating
such slices.