[FAQ Index] [To Section 12 - Platform-Specific Questions]
First be sure to read the disklabel(8) man page.
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 FAQ 4, Space Needed. For servers it is recommended that you create at least these labels 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. separating /, /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: [63] <Enter> size: [16386237] 64M Rounding to nearest cylinder: 131040 FS type: [4.2BSD] <Enter> mount point: [none] / fragment size: [1024] <Enter> block size: [8192] <Enter> cpg: [16] <Enter> > a b offset: [131103] <Enter> size: [16255197] 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: [262143] <Enter> size: [16124157] 64M Rounding to nearest cylinder: 131040 FS type: [4.2BSD] <Enter> mount point: [none] /tmp fragment size: [1024] <Enter> block size: [8192] <Enter> cpg: [16] <Enter> > a e offset: [393183] <Enter> size: [15993117] 64M Rounding to nearest cylinder: 131040 FS type: [4.2BSD] <Enter> mount point: [none] /var fragment size: [1024] <Enter> block size: [8192] <Enter> cpg: [16] <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
Once your system is installed, you shouldn't need to use disklabel too often. But some times you will need to use disklabel 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, ensuring that you don't 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.
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 partition 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, use:
# fdisk sd0
Which will give an output similar to this:
Disk: sd0 geometry: 553/255/63 [8883945 Sectors]
Offset: 0 Signature: 0xAA55
Starting Ending LBA Info:
#: id C H S - C H S [ start: size ]
------------------------------------------------------------------------
*0: A6 3 0 1 - 552 254 63 [ 48195: 8835750 ] OpenBSD
1: 12 0 1 1 - 2 254 63 [ 63: 48132 ] Compaq Diag.
2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
In this example we are viewing the fdisk output of the first SCSI 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)
setpid Set the identifier of a given table entry
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. In the below example we're adding a third SCSI drive to the system.
# 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! Fstype for OpenBSD 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).
# newfs sd2a
Or whatever your disk was named as per OpenBSD's disk numbering scheme. (Look at the output from dmesg(8) 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/sd2a /u
Finally, add it to /etc/fstab(5).
/dev/sd2a /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(5) file to show that the /usr/local partition is now /dev/sd2a (your freshly formatted partition.) Example:
/dev/sd2a /usr/local ffs rw 1 1
Reboot into single user mode with 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 voila, 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).)
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 the easiest and quickest way to get extra swap space setup. The file must not reside on a filesystem which has SoftUpdates enabled (they are disabled by default). To start out, you can see how much swap you currently have and how much you are using with the swapctl(8) utility. You can do this by using the command:
$ 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.
$ 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
$ sudo chmod 600 /var/swap $ 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.
$ 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.
$ 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.
$ 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 your /etc/fstab. Here is a sample line to boot with this device as swap on boot.
$ 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).
$ 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.
$ sudo swapctl -a /dev/vnd0c $ 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%
Soft Updates is based on an idea proposed by Greg Ganger and Yale Patt and developed for FreeBSD by Kirk McKusick. SoftUpdates imposes a partial ordering on the buffer cache operations which permits the requirement for synchronous writing of directory entries to be removed from the FFS code. Thus, a large performance increase is seen in disk writing performance.
The potential of background fsck(8), using Soft Updates is not yet realised in OpenBSD, so fsck(8) is still required after an unclean shutdown. This may be changed in future versions.
To use Soft Updates, your kernel must have
option FFS_SOFTUPDATES
compiled in, this is already in place on GENERIC.
Enabling soft updates must be done with a mount-time option. When mounting a partition with the mount(8) utility, you can specify that you wish to have soft updates enabled on that partition. Below is a sample /etc/fstab(5) entry that has one partition sd0a that we wish to have mounted with soft updates.
/dev/sd0a / ffs rw,softdep 1 1
Note to sparc users: Do not enable soft updates on sun4 or sun4c machines. These architectures support only a very limited amount of kernel memory and cannot use this feature. However, sun4m machines are fine.
While OpenBSD includes an MBR, you are not obliged to use it, as virtually any MBR can boot OpenBSD. The MBR is manipulated by the fdisk(8) program, which is used both to edit the partition table, and also to install the MBR code on the disk.
OpenBSD's MBR announces itself with the message:
Using drive 0, partition 3.
showing the disk and partition it is about to load the PBR from.
In addition to the obvious, it also shows a trailing period ("."), which
indicates this machine is capable of using LBA translation to boot.
If the machine were incapable of using LBA translation, the above
period would have have been replaced with a semicolon (";"), indicating
CHS translation:
Using Drive 0, Partition 3;
Note that the trailing period or semicolon can be used as an indicator
of the "new" OpenBSD MBR, introduced with OpenBSD 3.5.
The PBR is installed by installboot, which is further described later in this document. The PBR announces itself with the message:
Loading...
printing a dot for every file system block it attempts to load.
Again, the PBR shows if it is using LBA or CHS to load, if it has
to use CHS translation, it displays a message with a semicolon:
Loading;...
The older (pre v3.5) biosboot(8) showed the message "reading
boot...".
boot(8) is an interactive program. After it loads, it attempts to locate and read /etc/boot.conf, if it exists (which it does not on a default install), and processes any commands in it. Unless instructed otherwise by /etc/boot.conf, it then gives the user a prompt:
probing: pc0 com0 com1 apm mem[636k 190M a20=on]
disk: fd0 hd0+
>> OpenBSD/i386 BOOT 2.06
boot>
It gives the user (by default) five seconds to start giving it other
tasks, but if none are given before the timeout, it starts its default
behavior: loading the kernel, bsd, from the root partition of
the first hard drive.
The second-stage boot loader probes (examines) your system hardware,
through the BIOS (as the OpenBSD kernel is not loaded).
Above, you can see a few things it looked for and found:
Using drive 0, partition 3. <- MBR
Loading.... <- PBR
probing: pc0 com0 com1 apm mem[636k 190M a20=on] <- /boot
disk: fd0 hd0+
>> OpenBSD/i386 BOOT 2.06
boot>
booting hd0a:/bsd 4464500+838332 [58+204240+181750]=0x56cfd0
entry point at 0x100120
[ using 386464 bytes of bsd ELF symbol table ]
Copyright (c) 1982, 1986, 1989, 1991, 1993 <- Kernel
The Regents of the University of California. All rights reserved.
Copyright (c) 1995-2003 OpenBSD. All rights reserved. http://www.OpenBSD.org
OpenBSD 3.6 (GENERIC) #59: Fri Sep 17 12:32:57 MDT 2004
...
You may install the OpenBSD MBR on your hard disk using the fdisk program. Boot from your install media, choose "Shell" to get a command prompt:
# fdisk -u wd0
You may also install a specific MBR to disk using fdisk:
# fdisk -u -f /usr/mdec/mbr wd0
which will install the file /usr/mdec/mbr as your system's
MBR.
This particular file on a standard OpenBSD install happens
to be the standard MBR that is also built into fdisk, but any other
MBR could be specified here.
OpenBSD supports an individual file system of up to 231-1, or 2,147,483,647 sectors, and as each sector is 512 bytes, that's a tiny amount less than 1T.
Of course, the ability of file system and the abilities of particular hardware are two different things. A new 250G IDE hard disk will not work on older (pre >137G standards) interfaces, and some very old SCSI adapters have been seen to have problems with more modern drives, and some older BIOSs will hang when they encounter a modern sized hard disk. You must respect the abilities of your hardware, of course.
For this reason, the entire /bsd file (the kernel) must be located on the disk within the boot ROM addressable area. This means that on some older i386 systems, the root partition must be completely within the first 504M, but newer computers may have limits of 2G, 8G, 32G, 128G or more. It is worth noting that many relatively new computers which support larger than 128G drives actually have BIOS limitations of booting only from within the first 128G. You can use these systems with large drives, but your root partition must be within the first 128G.
Note that it is possible to install a 40G drive on an old 486 and load OpenBSD on it as one huge partition, and think you have successfully violated the above rule. However, it might come back to haunt you in a most unpleasant way:
Why? Because when you copied "over" the new /bsd file, it didn't overwrite the old one, it got relocated to a new location on the disk, probably outside the 504M range the BIOS supported. The boot loader was unable to fetch the file /bsd, and the system hung.
To get OpenBSD to boot, the boot loaders (biosboot(8) and /boot in the case of i386) and the kernel (/bsd) must be within the boot ROM's supported range, and within their own abilities. To play it safe, the rule is simple:
the entire root partition must be within the computer's BIOS (or boot ROM) addressable space.
Some non-i386 users think they are immune to this, however most platforms have some kind of boot ROM limitation on disk size. Finding out for sure what the limit is, however, can be difficult.
This is another good reason to partition your hard disk, rather than using one large partition.
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 drive (or use a
bootable CD-ROM) 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 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 through ports 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(8) command at your shell prompt. You should get output similar to this:
# 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:
# 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(8) 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(1) 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 installed drive. Example:
# 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:
# 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:
# newfs /dev/rsd0a # newfs /dev/rsd0h
Mount your newly prepared root (/) file system on /mnt. Example:
# mount /dev/sd0a /mnt
Change into that mounted root file system and start the restore process. Example:
# cd /mnt # 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:
# 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:
# cp /usr/mdec/boot /mnt/boot # /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:
# umount /mnt # 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:
# mount -u -w /
Once you have remounted in r/w mode you can continue restoring your other file systems. Example:
(simple mount table) # mount /dev/sd0h /usr; cd /usr; restore -rs 2 -f /dev/rst0 (more advanced mount table) # mount /dev/sd0d /var; cd /var; restore -rs 2 -f /dev/rst0 # mount /dev/sd0e /home; cd /home; restore -rs 3 -f /dev/rst0 # 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.
DMA IDE transfers, supported by pciide(4) are unreliable with many combinations of hardware. Until recently, most "mainstream" operating systems that claimed to support DMA transfers with IDE drives did not ship with that feature active by default due to unreliable hardware. Now many of these same machines are being used for OpenBSD.
OpenBSD is aggressive and attempts to use the highest DMA Mode it can configure. This will cause corruption of data transfers in some configurations because of buggy motherboard chipsets, buggy drives, and/or noise on the cables. Luckily, Ultra-DMA modes protect data transfers with a CRC to detect corruption. When the Ultra-DMA CRC fails, OpenBSD will print an error message and try the operation again.
wd2a: aborted command, interface CRC error reading fsbn 64 of 64-79 (wd2 bn 127; cn 0 tn 2 sn 1), retrying
After failing a couple times, OpenBSD will downgrade to a slower (hopefully more reliable) Ultra-DMA mode. If Ultra-DMA mode 0 is hit, then the drive downgrades to PIO mode.
UDMA errors are often caused by low quality or damaged cables. Cable problems should usually be the first suspect if you get many DMA errors or unexpectedly low DMA performance. It is also a bad idea to put the CD-ROM on the same channel with a hard disk.
If replacing cables does not resolve the problem and OpenBSD does not successfully downgrade, or the process causes your machine to lock hard, or causes excessive messages on the console and in the logs, you may wish to force the system to use a lower level of DMA or UDMA by default. This can be done by using UKC or config(8) to change the flags on the wd(4) device.
The root partition can be directly mirrored by OpenBSD using the "Autoconfiguration" option of RAIDframe.
Many OpenBSD platforms include support for various hardware RAID products. The options vary by platform, see the appropriate hardware support page (listed here).
Another option available for many platforms is one of the many products which make multiple drives act as a single IDE or SCSI drive, and are then plugged into a standard IDE or SCSI adapter. These devices can work on virtually any hardware platform that supports either SCSI or IDE.
Some manufacturers of these products:
(Note: these are just products that OpenBSD users have reported using -- this is not any kind of endorsement, nor is it an exhaustive list.)An often asked question on the mail lists is "Are the low-cost IDE or SATA RAID controllers (such as those using Highpoint, Promise or Adaptec HostRAID chips) supported?". The answer is "No". These cards and chips are not true hardware RAID controllers, but rather BIOS-assisted boot of a software RAID. As OpenBSD already supports software RAID in a hardware-independent way, there isn't much desire among the OpenBSD developers to implement special support for these cards.
Almost all on-board SATA or IDE "RAID" controllers are this software-based style, and will typically work fine as as an SATA or IDE controller using the standard IDE driver (pciide(4)), but are not going to work as a hardware RAID system on OpenBSD.
When a partition is created with newfs(8), some of the available space is held in reserve from normal users. This provides a margin of error when you accidently fill the disk, and helps keep disk fragmentation to a minimum. Default for this is 5% of the disk capacity, so if the root user has been carelessly filling the disk, you may see up to 105% of the available capacity in use.
If the 5% value is not appropriate for you, you can change it with the tunefs(8) command.
[FAQ Index] [To Section 12 - Platform-Specific Questions]