Formatting Media For Use With FreeBSD: A Tutorial
Prev |  | Next

# 4 Other Disk Operations

## 4.1 Adding Swap Space

As a system grows, its need for swap space can also grow. Although adding swap space to existing disks is very difficult, a new disk can be partitioned with additional swap space.

To add swap space when adding a disk to a system:

1. When partitioning the disk, edit the disklabel and allocate the amount of swap space to add in partition `b' and the remainder in another partition, such as `a' or `e'. The size is given in 512 byte blocks.

2. When newfsing the drive, do NOT newfs the `c' partition. Instead, newfs the partition where the non-swap space lies.

3. Add an entry to `/etc/fstab` as follows:

       /dev/ad0b                       none            swap    sw 0 0

   Change `/dev/ad0b` to the device of the newly added space.

4. To make the new space immediately available, use the `swapon` command.

       # swapon /dev/da0b
       swapon:  added /dev/da0b as swap space

## 4.2 Copying the Contents of Disks

Submitted By: Renaud Waldura (`<renaud@softway.com>`)

To move file from your original base disk to the fresh new one, do:

    # mount /dev/ad2 /mnt
    # pax -r -w -p e /usr/home /mnt
    # umount /mnt
    # rm -rf /usr/home/*
    # mount /dev/ad2 /usr/home

## 4.3 Creating Striped Disks using CCD

Commands Submitted By: Stan Brown (`<stanb@awod.com>`)

The Concatenated Disk Driver, or CCD, allows you to treat several identical disks as a single disk. Striping can result in increased disk performance by distributing reads and writes across the disks. See the ccd(4) and ccdconfig(8) manual pages or the CCD Homepage for further details.

You no longer need to build a special kernel to run ccd. When you run `ccdconfig`, it will load the KLD for you if the kernel does not contain CCD support.

You build CCDs on disk partitions of type 4.2BSD. If you want to use the entire disk, you still need to create a new partition. For example, `disklabel -e` might show:

    #        size   offset    fstype   [fsize bsize bps/cpg]
      c: 60074784        0    unused        0     0     0   # (Cyl.    0 - 59597)

You should not use partition c for the CCD, since it is of type unused. Instead, create a new partition of exactly the same size, but with type 4.2BSD:

    #        size   offset    fstype   [fsize bsize bps/cpg]
      c: 60074784        0    unused        0     0     0   # (Cyl.    0 - 59597)
       e: 60074784        0    4.2BSD        0     0     0   # (Cyl.    0 - 59597)

To create a new CCD, execute the following commands. This describes how to add three disks together; simply add or remove devices as necessary. Remember that the disks to be striped must be identical.

    # cd /dev ; sh MAKEDEV ccd0

    # disklabel -r -w da0 auto
    # disklabel -r -w da1 auto
    # disklabel -r -w da2 auto

    # disklabel -e da0
    Add partition e with type 4.2BSD
    # disklabel -e da1
    Add partition e with type 4.2BSD
    # disklabel -e da2
    Add partition e with type 4.2BSD

    # ccdconfig ccd0 273 0 /dev/da0e /dev/da1e /dev/da2e

    # newfs /dev/ccd0c

The value 273 is the stripe size. This is the number of disk sectors (of 512 bytes each) in each block of data on the CCD. It should be at least 128 kB, and it should not be not be a power of 2.

Now you can mount and use your CCD by referencing device `/dev/ccd0c`.

A more powerful and flexible alternative to CCD is Vinum. See the Vinum Project home page for further details.

Prev | Home | Next
Making Compatibility Mode Disks |  | Credits