Creating OpenBSD Partitions


The install program will now guide you through creating partitions on your disk. This is perhaps the most complicated part of installing OpenBSD. Get out your scratch sheet where you wrote down how you wanted to divide your disk. You will need it here.

 You will now create an OpenBSD disklabel inside the OpenBSD MBR partition. The disklabel defines how OpenBSD splits up the MBR partition into OpenBSD partitions in which filesystems and swap space are created. The offsets used in the disklabel are ABSOLUTE, i.e. relative to the start of the disk, NOT the start of the OpenBSD MBR partition. 

A disklabel defines OpenBSD partitions within an MBR partition. The entire disk is designated as a single MBR partition, as we dedicated the disk to OpenBSD. A small chunk of the disk will be allocated to the Master Boot Record, however, and the installer tells you how many sectors it occupies.

 # using MBR partition 3: type A6 off 63 (0x3f) size 39179889 (0x255d671) Treating sectors 63-39179952 1 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) > 

One important fact here is that the installer tells you how many 1 sectors are available on the MBR partition. Because we have dedicated this disk to OpenBSD, we know that there are 39179953 sectors on this disk — remember, computers start numbering at zero! We can use all but the first 62 sectors.

You're now at a command prompt within OpenBSD's disklabel(8) tool. This tool has its own command set, which you can view by entering a question mark at the disklabel prompt. We're going to examine some of the basic commands here.

Understanding a Disklabel

The "p" command prints the disklabel as it currently appears. A disklabel contains two basic sets of information: some physical information about the disk and information about the partitioning of the MBR partition. Let's look at the physical information first. While it doesn't usually have a direct impact upon the installation process, you may need to know how to read it if something goes wrong.

 > p device: /dev/rwd0c 1 type: ESDI 2 disk: ESDI/IDE disk 3 label: SAMSUNG SV2011H 4 bytes/sector: 512 5 sectors/track: 63 6 tracks/cylinder: 16 sectors/cylinder: 1008 cylinders: 16383 total sectors: 39179952 7 free sectors: 39179889 8 rpm: 3600 9 

Your first entry is the disk's 1 device name, shown as /dev/rwd0c in this example. The middle of the name, wd0, is the disk name. The leading "r" means that we're addressing the disk in raw mode, while the tailing "c" means that we're examining the "c" partition. "c" is the OpenBSD partition name used for the whole MBR disk.

The type 2 is a general label describing the interface used by the disk. Any IDE disk will show up as ESDI (Enhanced Small Device Interface), while SCSI disks are labeled SCSI.

The disk 3 field shows what sort of disk is attached to this interface. In this case, it's an IDE disk, but we knew that from the device name already.

The label 4 displays the manufacturer's name and model number for the drive.

The 5 bytes per sector line shows how many bytes are in a single sector. Almost all drives put 512 bytes, or half a K, in a single sector.

The next few lines, where disklabel prints out 6 the sectors per track, the tracks per cylinder, the sectors per cylinder, and the number of cylinders on the drive, can be confusing. Hard drives have expanded dramatically over the years; many different sorts of hardware perform some sort of "translation" to make the hard drive work as you would expect. This means that by the time this information reaches the disklabel program, the hardware, the BIOS, or both may have altered it repeatedly. You cannot trust that these values reflect the physical design of the disk. (If you're interested in the workings of disk translation, take a look at the INSTALL.chs document in the i386 directory of the distribution directory.) Fortunately, you don't need to do anything with them.

The fields that tell you the 7 total sectors on the disk and the 8 number of free sectors are accurate, however. The whole purpose of the translations that the hardware performs is to give an accurate sector count, after all!

Finally the 9 rpm field tells you the rpm (revolutions per minute) of the disk.

All of the above cannot be changed without changing the underlying hardware. The following section, which displays the actual OpenBSD partitioning of the disk, can and must be altered.

 16 partitions: 1 #       2 size   3 offset   4 fstype   [ 5 fsize 6 bsize   7 cpg]   c: 39179952         0    unused         0     0 > 

The first line shown here says that you can have up to 1 16 OpenBSD partitions on this hard drive.

The comment line 2 shows what each of the six columns beneath it mean.

The first 1 gives a partition letter. A unique letter identifies each partition on a disk. As we said earlier, the "c" partition represents the whole drive.

The 2 size is the number of sectors the partition takes up. In our example, the "c" partition takes up 39179952 sectors. This includes the sectors occupied by the Master Boot Record — remember, "c" is the whole disk.

The 3 offset column shows how far from the beginning of the disk this partition begins. As the "c" partition is the whole disk, it has an offset of zero.

The 4 fstype column shows the file system type the partition has.

The last three columns describe fragmentation behavior of the file system and are not meant to be changed by anyone. The OpenBSD file system is highly fragmentation resistant. If you're curious, start reading at newfs(8) and its related manual pages. If you're an advanced user, the installer does give you a chance to alter these — but you really shouldn't unless you know exactly what you're doing and why.

Under 5 fsize, you will see the fragment size for any file fragments on the disk, in bytes.

The 6 b size is the size of a block on disk, in bytes.

Finally, 7 cpg shows the number of cylinders per cylinder group.

Anytime you feel confused in the disk partitioning process, print your current disklabel and compare it to your notes on how you want the partitioning to look.

Now that you can see what the disk partitioning looks like, let's add a partition or four.

Adding Partitions

This IDE drive is 20GB, and I want to divide it as follows.

  • 500MB root

  • 500MB swap

  • 10GB /usr

  • 9GB /var

I don't have a /home partition on this drive; I plan to put it on one of the SCSI drives.

To add a partition, enter "a". This will drop you into an interactive dialog.

The important thing to remember here is that partitions are created on the disk in the order that you create them in the disklabel. You want your root partition to be first on the disk, so you need to create it first. (Remember, if you put your root partition further in the disk you might break the 8GB limit!)

 > a partition: [a] 

Traditionally, the first partition on a disk is the "a" partition. Hit ENTER to take the default.

 offset: [63] 

The offset is the number of sectors from the beginning of the disk this partition begins. Remember, sectors 0–62 are used by the Master Boot Record. The installer is smart enough to know this, and presents a default that picks up where the last partition left off. Hit ENTER to accept it.

 size: [39179889] 500M 

By default, the installer presents you with the number of sectors remaining on the disk as your partition size. This is useful for the very last partition on the disk, but it's not what you want to use here.

The default unit here is in sectors. Rather than having to convert the partition size you want into sectors, however, the installer recognizes the following abbreviations for sizes:

  • b for bytes

  • c for cylinders

  • k for kilobytes

  • m for megabytes

  • g for gigabytes

Here, we tell the system to create a 500MB partition. Partitions can only be created along cylinder boundaries, so the installer will round it off to the nearest cylinder unless you happen to enter a value that exactly matches a cylinder.

 FS type: [4.2BSD] 

You can either choose a 4.2BSD file system, or "swap." The installer knows that the "a" traditionally needs a file system, so it defaults.

 mount point: [none] / > 

We want this first partition to be our root partition, so enter a slash. The partition is created, and you are dropped back to the disklabel prompt. Swap space is next on the list.

 > a 1 partition: [b] 2 offset: [1024128] 3 size: [38155824] 500M 4 Rounding to nearest cylinder: 1024128 5 FS type: [swap] 6 

This looks almost exactly like our first example. We 1 tell disklabel to add a partition. As it's our second partition, it defaults to 2 partition b. It begins at an 3 offset just after where your previous partition ends. We have to 4 enter a size, which is the first non-default choice we enter. Disklabel automatically 5 rounds this off to a suitable cylinder boundary. The "b" partition is traditionally swap space, so disklabel defaults to 6 creating this as swap space. Swap space doesn't have a mount point, so we're done.

Our next mount point has a couple of minor surprises, however.

 > a partition: [d] 1 offset: [2048256] size: [37131696] 10G Rounding to nearest cylinder: 20971440 FS type: [4.2BSD] 2 mount point: [none] /usr 3 > 

Here, the automatic partition lettering has skipped "c" and gone to 1 "d." What gives? Remember, the "c" partition represents the entire disk, so "d" is the next available letter. Because "b" is the traditional swap space, disklabel defaults to making this partition (and all subsequent partitions) 2 a standard OpenBSD file system. Finally, we have to tell disklabel where we want this partition 3 mounted.

Our last partition on this disk, /var, is the easiest to create of all.

 > a partition: [e] offset: [23019696] size: [16160256]   1 FS type: [4.2BSD] mount point: [none] /var 2 > 

Disklabel knows which partition letter to assign, and the offset, and it even knows how many 1 sectors are left on the hard drive! All we have to do is assign a 2 mount point.

Now that you've completely filled the disk, use the "p" command to print your edited disklabel. The top of the disklabel is unchanged, but our partition table looks considerably different.

 > p ... 16 partitions: #        size   offset    fstype   [fsize bsize   cpg]   a:  1024065       63    4.2BSD     1024  8192    16  # /   b:  1024128  1024128      swap   c: 39179952        0    unused        0     0   d: 20971440  2048256    4.2BSD     1024  8192    16  # /usr   e: 16160256 23019696    4.2BSD     1024  8192    16  # /var > 

All of our partitions are visible here, along with comments recording which partition we intended to assign them to. You can check your work here.

Writing a Label to the Disk

Once you are satisfied with your work, hit "q" to write your edited disklabel on the disk. If you don't like your work, you can hit "z" to quit disklabel without writing any changes.

 > q Write new label?: [y] 

You'll get one last chance to change your mind. Once you write a new disklabel, recovering any data on the disk will become extremely difficult! You should have backed up any vital data on this disk before starting the install, but this is a good time to confirm you didn't, say, microwave the backup tape. Hit ENTER to continue.

 The root filesystem will be mounted on wd0a. wd0b will be used for swap space. Mount point for wd0d (size=10485720k), none or done? [/usr] 

You have a final chance to set the mount point for your partitions. The mount point you chose is in the default, but if you want to rearrange things, you can do it here. Hit ENTER to go on. The installer will cycle through all of the partitions on the disk, asking you to confirm their mount points.

 Mount point for wd0e (size=8080128k), none or done? [/var] Mount point for wd0d (size=10485720k), none or done? [/usr] done 

When you have confirmed all of your mount points, the installer starts asking you where you want to mount your disks again at the beginning of the list! This might seem annoying, but think about it. If you realized on your last partition that you had made an error on the mount point, you might need to rearrange earlier partitions. Enter "done" to end the loop, and proceed to the next disk.




Absolute Openbsd(c) Unix for the Practical Paranoid
Absolute OpenBSD: Unix for the Practical Paranoid
ISBN: 1886411999
EAN: 2147483647
Year: 2005
Pages: 298

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net