Our new partition should end on a cylinder boundary. This means that it will end on some cylinder, head 254, sector 63. But which cylinder?
Here, you have to resort to some basic math. No, stop screaming; it isn’t that bad: Just get out your calculator. This hard drive has 2,591 cylinders and can hold about 20GB, or 20,000MB. Each cylinder holds roughly the same amount of data. 20,000MB divided by 2591 cylinders equals a little over 7.719MB/cylinder. Dividing the desired partition size in megabytes by the actual MB/cylinder ratio shows that we need 1,036 cylinders for OpenBSD. The first partition goes through partition 891. 891 + 1036 = 1,927, so our OpenBSD partition will end on cylinder 1,927.
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!)
Traditionally, the first partition on a disk is the “a” partition. Hit ENTER to take the default.
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.
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.
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.
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 tell disklabel to add a partition. As it’s our second partition, it defaults to partition b. It begins at an offset just after where your previous partition ends. We have to enter a size, which is the first non-default choice we enter. Disklabel automatically rounds this off to a suitable cylinder boundary. The “b” partition is traditionally swap space, so disklabel defaults to 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 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 sectors are left on the hard drive! All we have to do is assign a 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.