Disklabels are created to allow an efficient interface between your disk and the disk drivers contained within the kernel. Labels hold certain information about your disk, like your drive geometry and information about your filesystems. This is then used by the bootstrap program to load the drive and to know where filesystems are contained on the drive. Labels are also used in conjunction with the filesystems to create a more efficient environment. You can read more in-depth information about disklabel by reading the disklabel(5) man page.
As an additional gain, using disklabel helps overcome architecture limitations on disk partitioning. For example, on i386, you can only have 4 primary partitions. (Partitions that other operating systems, such as Windows NT or DOS can see.) With disklabel(8), you use one of these 'primary' partitions to store *all* of your OpenBSD partitions (eg. 'swap', '/', '/usr' and '/var'). And you still have 3 more partitions available for other OSs!
One of the major parts of OpenBSD's install is your initial creation of labels. This comes (for i386 users) directly after using fdisk(1). During the install you use disklabel to create your separate labels which will contain your separate mountpoints. During the install, you can set your mountpoints from within disklabel(8), but this isn't completely necessary considering you will be prompted later to confirm you choices. But it does make your install go just a little smoother.
Since this is during the install you won't have any existing labels, and they will need to be created. The first label you will create is the label 'a'. This label SHOULD be your where / will be mounted. You can see recommended partitions that should be created and their sizes by reading faq4.3. For servers it is recommended that you create at least these label's separately. For desktop users creating one mountpoint at / will probably suffice. When initially creating your root partition ( 'a' label ), keep in mind that you will need SOME space left for your swap label. Now that the basics have been explained, here is an example of using disklabel during an install. In this first example it is assumed that OpenBSD will be the only operating system on this computer, and that a full install will be done.
If this disk is shared with other operating systems, those operating systems should have a BIOS partition entry that spans the space they occupy completely. For safety, also make sure all OpenBSD file systems are within the offset and size specified in the 'A6' BIOS partition table. (By default, the disklabel editor will try to enforce this). If you are unsure of how to use multiple partitions properly (ie. seperating /, /usr, /tmp, /var, /usr/local, and other things) just split the space into a root and swap partition for now. # using MBR partition 3: type A6 off 63 (0x3f) size 4991553 (0x4c2a41) Treating sectors 63-16386300 as the OpenBSD portion of the disk. You can use the 'b' command to change this. Initial label editor (enter '?' for help at any prompt) > d a > a a offset:  <Enter> size:  64M Rounding to nearest cylinder: 131040 FS type: [4.2BSD] <Enter> mount point: [none] / fragment size:  <Enter> block size:  <Enter> cpg:  <Enter> > a b offset:  <Enter> size:  64M Rounding to nearest cylinder: 131040 FS type: [swap] <Enter>
At this point we have created a 64M root partition mounted at /, and a 64Meg swap partition. Notice that the offset starts at sector 63. This is what you want. When it comes to the size, disklabel will show your size in sectors, however, you don't need to enter sizes in the same format. Like the example above you can enter sizes in the manner of 64 Megabytes = 64M and 2 Gigabytes = 2G. Disklabel will then round to the nearest cylinder. In the example above you will also notice that disklabel assumes that label 'b' will be a swap. This is a correct assumption as the GENERIC kernel is set to look for swap on label 'b', and you should just follow this guideline and use 'b' as your swap area.
The next example will take you through the creation of two more labels. This means that it's not a complete install, as the size of these won't be enough to install OpenBSD to its fullest. Showing the creation of all the partitions would just be repetitive.
> a d offset:  <Enter> size:  64M Rounding to nearest cylinder: 131040 FS type: [4.2BSD] <Enter> mount point: [none] /tmp fragment size:  <Enter> block size:  <Enter> cpg:  <Enter> > a e offset:  <Enter> size:  64M Rounding to nearest cylinder: 131040 FS type: [4.2BSD] <Enter> mount point: [none] /var fragment size:  <Enter> block size:  <Enter> cpg:  <Enter>
In the above example, there are two things you might notice. One being that the offset is automatically figured out for you to be the next in order. When doing an install of this sort, you won't need to mess with changing the offsets at all. Another difference you might notice will be that label 'c' has been skipped. This is done for a reason, which is that label 'c' is a label that represents the whole disk. For this reason you shouldn't deal with label 'c' in any way.
Once all your labels have been created all that's left to do is write the labels to disk, and move on in the installation process. To write everything and quit disklabel (and continue with the install) do:
> w > q
*NOTE* - For user's with large drives. If your bios isn't able to support a drive of that size OpenBSD cannot support it either. Otherwise OpenBSD should be able to handle your drive just fine. If you are in a situation where your bios doesn't support your drive, you can try Maxtor EZ-Drive or other similar overlay product.
Once your system is installed, you shouldn't need to use disklabel too often. But some times you will need to use disklabel are when adding, removing or restructuring your disks. One of the first things you will need to do is view your current disklabel. To do this simply type:
# disklabel wd0 >----- Or whatever disk device you'd like to view # using MBR partition 3: type A6 off 64 (0x40) size 16777152 (0xffffc0) # /dev/rwd0c: type: ESDI disk: label: TOSHIBA MK2720FC flags: bytes/sector: 512 sectors/track: 63 tracks/cylinder: 16 sectors/cylinder: 1008 cylinders: 2633 total sectors: 2654064 rpm: 3600 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0 # milliseconds track-to-track seek: 0 # milliseconds drivedata: 0 16 partitions: # size offset fstype [fsize bsize cpg] a: 2071440 65583 4.2BSD 1024 8192 16 # (Cyl. 65*- 2120) b: 65520 63 swap # (Cyl. 0*- 65) c: 2654064 0 unused 0 0 # (Cyl. 0 - 2632) j: 512001 2137023 4.2BSD 1024 8192 16 # (Cyl. 2120*- 2627*)
The above command simply allows you to view the existing disklabel, and assuring that you dont mess anything up. ( Which we all need sometimes. ) But to be able to make changes you must use the -E option with disklabel like so:
# disklabel -E wd0
This will bring you to a prompt, the same as the one that you used during the OpenBSD install. Probably the single most important command at this prompt is '?'. This will give you a list of possible options pertaining to disklabel. You can even view the entire disklabel(8) man page with the 'M' command. From this prompt, you will do all of your adding, deleting and changing of partitions. For additional information read the disklabel(8) man page.
First be sure to check the fdisk main page. fdisk(8)
Fdisk is a program to help with the maintenance of your partitions. This program is used at install time to set up your OpenBSD partition (this partition can contain several labels, each with filesystems/swap/etc.). It can divide space on your drives and set one active. This program will usually be used in Single User Mode ( boot -s ). Fdisk also sets the MBR on your various hard disks.
For installation purposes, most times you'll only need ONE OpenBSD partition, and then using disklabel to put a swap and a filesystem on it.
To just view your partition table using fdisk just use:
# fdisk fd0Which will give an output similar to this:
Disk: fd0 geometry: 80/2/18 [2880 sectors] Offset: 0 Signatures: 0xAA55,0x0 Starting Ending #: id cyl hd sec - cyl hd sec [ start - size] ---------------------------------------------------------------------- *0: A6 0 0 1 - 79 1 18 [ 0 - 2880] OpenBSD 1: 00 0 0 0 - 0 0 0 [ 0 - 0] unused 2: A7 0 0 2 - 79 1 18 [ 1 - 2879] NEXTSTEP 3: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
In this example we are viewing the fdisk output of floppy drive. We can see the OpenBSD partition (A6) and its size. The * tells us that the OpenBSD partition is a bootable partition.
In the previous example we just viewed our information. What if we want to edit our partition table? Well, to do so we must use the -e flag. This will bring up a command line prompt to interact with fdisk.
# fdisk -e wd0 Enter 'help' for information fdisk: 1> help help Command help list manual Show entire OpenBSD man page for fdisk reinit Re-initialize loaded MBR (to defaults) disk Edit current drive stats edit Edit given table entry flag Flag given table entry as bootable update Update machine code in loaded MBR select Select extended partition table entry MBR print Print loaded MBR partition table write Write loaded MBR to disk exit Exit edit of current MBR, without saving changes quit Quit edit of current MBR, saving current changes abort Abort program without saving current changes fdisk: 1>
It is perfectly safe in fdisk to go in and explore, just make sure to answer N to saving the changes and *DON'T* use the write command.
Here is an overview of the commands you can use when you choose the -e flag.
Well once you get your disk installed PROPERLY you need to use fdisk(8) (i386 only) and disklabel(8) to set up your disk in OpenBSD.
For i386 folks, start with fdisk. Other architectures can ignore this.
# fdisk -i sd2This will initialize the disk's "real" partition table for exclusive use by OpenBSD. Next you need to create a disklabel for it. This will seem confusing.
# disklabel -e sd2 (screen goes blank, your $EDITOR comes up) type: SCSI ...bla... sectors/track: 63 total sectors: 6185088 ...bla... 16 partitions: # size offset fstype [fsize bsize cpg] c: 6185088 0 unused 0 0 # (Cyl. 0 - 6135) d: 1405080 63 4.2BSD 1024 8192 16 # (Cyl. 0*- 1393*) e: 4779945 1405143 4.2BSD 1024 8192 16 # (Cyl. 1393*- 6135)First, ignore the 'c' partition, it's always there and is for programs like disklabel to function! For normal operations, fsize should always be 1024, bsize should always be 8192, and cpg should always be 16. Fstype is 4.2BSD. Total sectors is the total size of the disk. Say this is a 3 gigabyte disk. Three gigabytes in disk manufacturer terms is 3000 megabytes. So divide 6185088/3000 (use bc(1)). You get 2061. So to make up partition sizes for a, d, e, f, g, ... just multiply X*2061 to get X megabytes of space on that partition. The offset for your first new partition should be the same as the "sectors/track" reported earlier in disklabel's output. For us it is 63. The offset for each partition afterwards should be a combination of the size of each partition and the offset of each partition (Except the C partition, since it has no play into this equation.)
Or, if you just want one partition on the disk, say you will use the whole thing for web storage or a home directory or something, just take the total size of the disk and subtract the sectors per track from it. 6185088-63 = 6185025. Your partition is
d: 6185025 63 4.2BSD 1024 8192 16
If all this seems needlessly complex, you can just use disklabel -E to get the same partitioning mode that you got on your install disk! There, you can just use "96M" to specify "96 megabytes". (Or, if you have a disk big enough, 96G for 96 gigs!) Unfortunately, the -E mode uses the BIOS disk geometry, not the real disk geometry, and often times the two are not the same. To get around this limitation, type 'g d' for 'geometry disk'. (Other options are 'g b' for 'geometry bios' and 'g u' for geometry user, or simply, what the label said before disklabel made any changes.)
That was a lot. But you are not finished. Finally, you need to create the filesystem on that disk using newfs(8).
bsd# newfs wd1a
Or whatever your disk was named as per OpenBSD's disk numbering scheme. (Look at the output from dmesg(1) to see what your disk was named by OpenBSD.)
Now figure out where you are going to mount this new partition you just created. Say you want to put it on /u. First, make the directory /u. Then, mount it.
mount /dev/wd1a /u
Finally, add it to /etc/fstab
/dev/wd1a /u ffs rw 1 1
What if you need to migrate an existing directory like /usr/local? You should mount the new drive in /mnt and use cpio -pdum to copy /usr/local to the /mnt directory. Edit the /etc/fstab file to show that the /usr/local partition is now /dev/wd1a (your freshly formatted partition.) Example:
Reboot into single user mode..boot -s Move the existing /usr/local to /usr/local-backup (or delete it if you feel lucky) and create an empty directory /usr/local. Then reboot the system, and whala!! the files are there!
(Note: if you are looking to swap to a file because you are getting "virtual memory exhausted" errors, you should try raising the per-process limits first with csh's unlimit(1), or sh's ulimit(1).)
After the release of OpenBSD 2.5 came swapctl(8), which made dealing with swap devices much easier. If you are on an OpenBSD 2.5 system, exchange swapctl with swapon, and use pstat -s to list swap devices. Swapping to a file doesn't require a custom built kernel, although that can still be done, this faq will show you how to add swap space both ways.
Swapping to a file is easiest and quickest way to get extra swap area's setup. This is not for users who are currently using Softupdates. (Which isn't enabled by default). To start out, you can see how much swap you are currently have and how much you are using with the swapctl(8) utility. You can do this by using the command:
ericj@oshibana> swapctl -l Device 512-blocks Used Avail Capacity Priority swap_device 65520 8 65512 0% 0
This shows the devices currently being used for swapping and their current statistics. In the above example there is only one device named "swap_device". This is the predefined area on disk that is used for swapping. (Shows up as partition b when viewing disklabels) As you can also see in the above example, that device isn't getting much use at the moment. But for the purposes of this document, we will act as if an extra 32M is needed.
The first step to setting up a file as a swap device is to create the file. It's best to do this with the dd(1) utility. Here is an example of creating the file /var/swap that is 32M large.
ericj@oshibana> sudo dd if=/dev/zero of=/var/swap bs=1k count=32768 32768+0 records in 32768+0 records out 33554432 bytes transferred in 20 secs (1677721 bytes/sec)
Once this has been done, we can turn on swapping to that device. Use the following command to turn on swapping to this device
ericj@oshibana> sudo chmod 600 /var/swap ericj@oshibana> sudo swapctl -a /var/swap
Now we need to check to see if it has been correctly added to the list of our swap devices.
ericj@oshibana> swapctl -l Device 512-blocks Used Avail Capacity Priority swap_device 65520 8 65512 0% 0 /var/swap 65536 0 65536 0% 0 Total 131056 8 131048 0%
Now that the file is setup and swapping is being done, you need to add a line to your /etc/fstab file so that this file is configured on the next boot time also. If this line is not added, your won't have this swap device configured.
ericj@oshibana> cat /etc/fstab /dev/wd0a / ffs rw 1 1 /var/swap /var/swap swap sw 0 0
This is a more permanent solution to adding more swap space. To swap to a file permanently, first make a kernel with vnd0c as swap. If you have wd0a as root filesystem, wd0b is the previous swap, use this line in the kernel configuration file (refer to compiling a new kernel if in doubt):
config bsd root on wd0a swap on wd0b and vnd0c dumps on wd0b
After this is done, the file which will be used for swapping needs to be created. You should do this by using the same command as in the above examples.
ericj@oshibana> sudo dd if=/dev/zero of=/var/swap bs=1k count=32768 32768+0 records in 32768+0 records out 33554432 bytes transferred in 20 secs (1677721 bytes/sec)
Now your file is in place, you need to add the file to you /etc/fstab. Here is a sample line to boot with this device as swap on boot.
ericj@oshibana> cat /etc/fstab /dev/wd0a / ffs rw 1 1 /dev/vnd0c none swap sw 0 0
At this point your computer needs to be rebooted so that the kernel changes can take place. Once this has been done it's time to configure the device as swap. To do this you will use vnconfig(8).
ericj@oshibana> sudo vnconfig -c -v vnd0 /var/swap vnd0: 33554432 bytes on /var/swap
Now for the last step, turning on swapping to that device. We will do this just like in the above examples, using swapctl(8). Then we will check to see if it was correctly added to our list of swap devices.
ericj@oshibana> sudo swapctl -a /dev/vnd0c ericj@oshibana> swapctl -l Device 512-blocks Used Avail Capacity Priority swap_device 65520 8 65512 0% 0 /dev/vnd0c 65536 0 65536 0% 0 Total 131056 8 131048 0%
Over the last few years Kirk McKusick has been working on something called "soft updates". This is based on an idea proposed by Greg Ganger and Yale Patt that imposing a partial ordering on the buffer cache operations would permit the requirement for synchronous writing of directory entries to be removed from the FFS code. Thus, a large performance increase of disk writing performance.
To enable Softupdates your kernel must have option
NOTE: This option is on by default after the release of OpenBSD 2.7 and will be default in 2.8. However, you still must enable it on a per disk partition basis.
then you need to boot into single-user mode:
boot> boot -s [snip] bsd# tunefs -s enable <raw device> bsd# reboot -n
This means that your MBR (Master Boot Record) was not installed properly or that your BIOS' idea of the hard disk geometry is not compatible with your current MBR. To solve this, first try to reinstall the OpenBSD boot blocks. To do so use fdisk(8) and installboot(8).
First, to get up and running, you will need to use your boot disk as a bootstrap. After you put the install disk in, and before it loads the kernel and ramdisk, you get a boot> prompt from the floppy disk. Use it to boot OpenBSD off of your hard disk.
booting... OpenBSD boot 1.2.3 probing hd0 fd0... boot> boot hd0a:/bsdNow that you are booted, and assuming you have dedicated your entire hard disk to OpenBSD, re-initialize the Master Boot Record with fdisk(8). (If you have partitions on your hard disk for operating systems other then OpenBSD, you cannot use installboot anyways, you must look at another option such as OS-BS, described below.)
# fdisk -i wd0Now, you need to write the boot blocks again.
# cp /usr/mdec/boot /boot # /usr/mdec/installboot -v /boot /usr/mdec/biosboot wd0Finally, reboot and test it out.
If this doesn't work you still have a few more options. So, luck hasn't run out yet. The first is to use a bootloader such as OS-BS. The OpenBSD cd has the os-bs bootloader included in the tools directory. If you didn't purchase a CD-ROM, you can download os-bs from any of the OpenBSD ftp sites. The file to grab is pub/OpenBSD/2.8/tools/osbs135.exe
Also, take some time to look through the OS-BS web pages at http://www.prz.tu-berlin.de/~wolf/os-bs.html
There are also other commercial bootloaders or lilo that you can use for multi-booting.
Here is a simple outline of how to get lilo onto your system.
For further instructions read INSTALL.linux
RAMDISK images (boot floppies) do not ship with the dmesg utility.
They do, however, have the
/kern filesystem mounted. To copy
the dmesg information to a file, do a:
# cat /kern/msgbuf >mydmesg
Boot disks also have 'more' to page through the output:
Older versions of MS-DOS can only deal with disk geometries of 1024 cylinders
or less. Since virtually all modern disks have more than 1024
cylinders, most SCSI BIOS chips (which come on the SCSI controller card)
and IDE BIOS (which is part of the rest of the PC BIOS)
have an option (sometimes the default) to "translate" the real disk
geometry into something that fits within MS-DOS' ability.
However, not all BIOS chips "translate" the geometry in
the same way. If you change your BIOS (either with a new motherboard
or a new SCSI controller), and the new one uses a
different "translated" geometry, you will be unable to load the
second stage boot loader (and thus unable to load the kernel).
(This is because the first stage boot loader contains a list of the blocks
that comprise /boot in terms of the original "translated" geometry.)
If you are using IDE disks, and you make changes to your BIOS settings,
you can (unknowingly) change its translation also (most IDE BIOS offer 3 different
translations.) To fix your boot block so that you can boot normally,
just put a boot floppy in your hard drive, and at the boot prompt,
type "b hd0a:/bsd" to force it to boot from the first hard disk (and not the
floppy). Your machine should come up normally. You now need
to update the first stage boot loader to see the new geometry
(and re-write the boot block accordingly).
Our example will assume your boot disk is sd0 (but for IDE it would be wd0, etc..):
# cd /usr/mdec; ./installboot /boot biosboot sd0
If installboot complains that it is unable to read the BIOS geometry, at the boot> prompt you may issue the "machine diskinfo" (or "ma di" for short) command to print the information you need. Feed the "heads" and "secs" values to installboot's -h and -s flags, respectively, so that the modified installboot command is the following:
# cd /usr/mdec; ./installboot -h <heads> -s <secs> /boot biosboot sd0
If a newer version of bootblocks are required, you will need to compile these yourself. To do so simply:
# cd /sys/arch/i386/stand/ # make && make install # cd /usr/mdec; cp ./boot /boot # ./installboot /boot biosboot sd0 (or whatever device your hard disk is)
If you plan on running what might be called a production server, it is advisable to have some form of backup in the event one of your fixed disk drives fails.
This information will assist you in using the standard dump(8)/restore(8) utilities provided with OpenBSD. A more advanced backup utility called "Amanda" is also available for backing up multiple servers to one tape drive. In most environments dump(8)/restore(8) is enough. However if you have a need to backup multiple machines to one tape, Amanda might be worth investigating in the future.
The device examples in this document are for a configuration that uses both SCSI disks and tape. In a production environment, SCSI disks are recommended over IDE due to the way in which they handle bad blocks. That is not to say this information is useless if you are using an IDE disk or other type of tape drive, your device names will simply differ slightly. For example sd0a would be wd0a in an IDE based system.
Backing up to tape requires knowledge of where your file systems are mounted. You can determine how your filesystems are mounted using the "mount" command at your shell prompt. You should get output similar to this:
shell# mount /dev/sd0a on / type ffs (local) /dev/sd0h on /usr type ffs (local)
In this example, the root (/) filesystem resides physically on sd0a which indicates SCSI fixed disk 0, partition a. The /usr filesystem resides on sd0h, which indicates SCSI fixed disk 0, partition h.
Another example of a more advanced mount table might be:
shell# mount /dev/sd0a on / type ffs (local) /dev/sd0d on /var type ffs (local) /dev/sd0e on /home type ffs (local) /dev/sd0h on /usr type ffs (local)
In this more advanced example, the root (/) filesystem resides physically on sd0a. The /var filesystem resides on sd0d, the /home filesystem on sd0e and finally /usr on sd0h.
To backup your machine you will need to feed dump the name of each fixed disk partition. Here is an example of the commands needed to backup the simpler mount table listed above:
# /sbin/dump -0au -f /dev/nrst0 /dev/rsd0a # /sbin/dump -0au -f /dev/nrst0 /dev/rsd0h # mt -f /dev/rst0 rewind
For the more advanced mount table example, you would use something similar to:
# /sbin/dump -0au -f /dev/nrst0 /dev/rsd0a # /sbin/dump -0au -f /dev/nrst0 /dev/rsd0d # /sbin/dump -0au -f /dev/nrst0 /dev/rsd0e # /sbin/dump -0au -f /dev/nrst0 /dev/rsd0h # mt -f /dev/rst0 rewind
You can review the dump man page to learn exactly what each command line switch does. Here is a brief description of the parameters used above:
Finally which partition to backup (/dev/rsd0a, etc)
The mt command is used at the end to rewind the drive. Review the mt man page for more options (such as eject).
If you are unsure of your tape device name, use dmesg to locate it. An example tape drive entry in dmesg might appear similar to:
st0 at scsibus0 targ 5 lun 0: <ARCHIVE, Python 28388-XXX, 5.28>
You may have noticed that when backing up, the tape drive is accessed as device name "nrst0" instead of the "st0" name that is seen in dmesg. When you access st0 as nrst0 you are accessing the same physical tape drive but telling the drive to not rewind at the end of the job and access the device in raw mode. To back up multiple file systems to a single tape, be sure you use the non-rewind device, if you use a rewind device (rst0) to back up multiple file systems, you'll end up overwriting the prior filesystem with the next one dump tries to write to tape. You can find a more elaborate description of various tape drive devices in the dump man page.
If you wanted to write a small script called "backup", it might look something like this:
echo " Starting Full Backup..." /sbin/dump -0au -f /dev/nrst0 /dev/rsd0a /sbin/dump -0au -f /dev/nrst0 /dev/rsd0d /sbin/dump -0au -f /dev/nrst0 /dev/rsd0e /sbin/dump -0au -f /dev/nrst0 /dev/rsd0h echo echo -n " Rewinding Drive, Please wait..." mt -f /dev/rst0 rewind echo "Done." echo
If scheduled nightly backups are desired, cron(8) could be used to launch your backup script automatically.
It will also be helpful to document (on a scrap of paper) how large each file system needs to be. You can use df -h to determine how much space each partition is currently using. This will be handy when the drive fails and you need to recreate your partition table on the new drive.
Restoring your data will also help reduce fragmentation. To ensure you get all files, the best way of backing up is rebooting your system in single user mode. File systems do not need to be mounted to be backed up. Don't forget to mount root (/) r/w after rebooting in single user mode or your dump will fail when trying to write out dumpdates. Enter bsd -s at the boot> prompt for single user mode.
After you've backed up your file systems for the first time, it would be a good idea to briefly test your tape and be sure the data on it is as you expect it should be.
You can use the following example to review a catalog of files on a dump tape:
# /sbin/restore -tvs 1 -f /dev/rst0
This will cause a list of files that exist on the 1st partition of the dump tape to be listed. Following along from the above examples, 1 would be your root (/) file system.
To see what resides on the 2nd tape partition and send the output to a file, you would use a command similar to:
# /sbin/restore -tvs 2 -f /dev/rst0 > /home/me/list.txt
If you have a mount table like the simple one, 2 would be /usr, if yours is a more advanced mount table 2 might be /var or another fs. The sequence number matches the order in which the file systems are written to tape.
The example scenario listed below would be useful if your fixed drive has failed completely. In the event you want to restore a single file from tape, review the restore man page and pay attention to the interactive mode instructions.
If you have prepared properly, replacing a disk and restoring your data from tape can be a very quick process. The standard OpenBSD install/boot floppy already contains the required restore utility as well as the binaries required to partition and make your new drive bootable. In most cases, this floppy and your most recent dump tape is all you'll need to get back up and running.
After physically replacing the failed disk drive, the basic steps to restore your data are as follows:
Boot from the OpenBSD install/boot floppy. At the menu selection, choose Shell. Write protect and insert your most recent back up tape into the drive.
Using the fdisk(8) command, create a primary OpenBSD partition on this newly intalled drive. Example:
shell# fdisk -e sd0
See fdisk FAQ for more info.
Using the disklabel command, recreate your OpenBSD partition table inside that primary OpenBSD partition you just created with fdisk. Example:
shell# disklabel -E sd0
(Don't forget swap, see disklabel FAQ for more info)
Use the newfs command to build a clean file system on each partition you created in the above step. Example:
shell# newfs /dev/rsd0a shell# newfs /dev/rsd0h
Mount your newly prepared root (/) file system on /mnt. Example:
shell# mount /dev/sd0a /mnt
Change into that mounted root file system and start the restore process. Example:
shell# cd /mnt shell# restore -rs 1 -f /dev/rst0
You'll want this new disk to be bootable, use the following to write a new MBR to your drive. Example:
shell# fdisk -i sd0
In addition to writing a new MBR to the drive, you will need to install boot blocks to boot from it. The following is a brief example:
shell# cp /usr/mdec/boot /mnt/boot shell# /usr/mdec/installboot -v /mnt/boot /usr/mdec/biosboot sd0
Your new root file system on the fixed disk should be ready enough so you can boot it and continue restoring the rest of your file systems. Since your operating system is not complete yet, be sure you boot back up with single user mode. At the shell prompt, issue the following commands to unmount and halt the system:
shell# umount /mnt shell# halt
Remove the install/boot floppy from the drive and reboot your system. At the OpenBSD boot> prompt, issue the following command:
boot> bsd -s
The bsd -s will cause the kernel to be started in single user mode which will only require a root (/) file system.
Assuming you performed the above steps correctly and nothing has gone wrong you should end up at a prompt asking you for a shell path or press return. Press return to use sh. Next, you'll want to remount root in r/w mode as opposed to read only. Issue the following command:
shell# mount -u -w /
Once you have remounted in r/w mode you can continue restoring your other file systems. Example:
(simple mount table) shell# mount /dev/sd0h /usr; cd /usr; restore -rs 2 -f /dev/rst0 (more advanced mount table) shell# mount /dev/sd0d /var; cd /var; restore -rs 2 -f /dev/rst0 shell# mount /dev/sd0e /home; cd /home; restore -rs 3 -f /dev/rst0 shell# mount /dev/sd0h /usr; cd /usr; restore -rs 4 -f /dev/rst0
You could use "restore rvsf" instead of just rsf to view names of objects as they are extracted from the dump set.
Finally after you finish restoring all your other file systems to disk, reboot into multiuser mode. If everything went as planned your system will be back to the state it was in as of your most recent back up tape and ready to use again.
To mount a disk image (ISO images, Disk images created with dd, etc) in OpenBSD you must configure a vnd(4) device. For example, If you have an ISO image located at /tmp/ISO.image, you would take the following steps to mount the image.
# vnconfig svnd0 /tmp/ISO.image # mount -t cd9660 /dev/svnd0c /mnt
Notice that, since this image is a CD image you must specify type of cd9660 when mounting it. This is true, no matter what type, e.g. you must use type ffs when mounting disk images.
To unmount the image use the following commands.
# umount /mnt # vnconfig -u svnd0
For more information, refer to the vnconfig(8) man page.
[Back to Main Index] [To Section 13.0 - IPsec]