Updated
Jul 25th, 2012
First Posted
Jul 25th, 2012

Diskutil

Diskutil is a utility you can use to build system disks and to create backups.

Syntax

diskutil action target An action must be specified, along with a target. One exception is the "list" command, which lists the available disk targets. Examples:
diskutil action target diskutil list diskutil show diskutil erase | mount | unmount disk diskutil build disk [ssd] diskutil backup disk [backup-name] [-v] [-vv] diskutil install disk
Full is the default backup-name; a full backup is the default setting for backup.

Setting up a new backup drive

First, list the disks available on the system, and take note of the Root drive, which is the main system disk.
On Freebsd 9.X, the disks are named sequentially ada0, ada1, etc: # diskutil list ada0 (Root): [152627 MB] WDC WD1600AAJS-08B4A0/01.03A01> Serial ATA II ada1 [152627 MB] WDC WD1600AAJS-00YZCA0/01.03B01> Serial ATA II
The main system disk (Root disk) is ada0. We will then prepare the first non-root disk ada1 for use as a backup drive, and then perform a manual backup.
# diskutil build ada1 This will complete erase the contents of ada1. Enter 'yes' to continue: yes # diskutil backup ada1
If you want to simply erase the drive: # diskutil erase ada1
To access the drive contents (for example, to recover an accidentally deleted file). In this example we copy our backed-up copy of rc.bwmgr, and then unmount the disk.
# diskutil mount ada1 # cp /ada1/etc/rc.bwmgr /etc/rc.bwmgr # diskutil unmount ada1

Backing up to USB HDD or Flash Drive

Backing up to a USB is a similar process, using da0 as the disk in most cases. Note that to backup your entire disk may require a large USB; make sure you have one that's big enough. The minimum is 2GB, and 4GB is recommended if you are storing a large number of stats rules.
# diskutil list ada0 (Root): [152627 MB] WDC WD1600AAJS-08B4A0/01.03A01> Serial ATA II da0 [3820 MB] USB Kingston DataTraveler G3 # diskutil erase da0 # diskutil build da0 # diskutil backup da0
Note that erasing your disk will wipe out your license, so do not erase a primary disk. You can use -v to show which files are being updated or -vv to show all files being checked. The -v and -vv options will substantially slow down the backup of a full system.

Installing from USB

Boot from the USB drive and set up your passwords and network settings at the prompts. Once that's done, list the available drives and choose your target.

List Available Disks

# diskutil list ada0 [152627 MB] WDC WD1600AAJS-00YZCA0/01.03B01> Serial ATA II da0 (Root): [3820 MB] USB Kingston DataTraveler G3

Build the Disk

# diskutil build ada0 This will completely erase the contents of ada0. Enter 'yes' to continue: yes Erasing ada0 ... 100+0 records in 100+0 records out 104857600 bytes transferred in 0.964744 secs (108689549 bytes/sec) formatting ada0

Install

# diskutil install ada0 Mounting disk ada0 Checking fstab Mounting ada0s1a: Creating missing directories... Mounting ada0s1e: Mounting ada0s1f: Starting transfer: install to ada0 Running post-install /usr/local/backup/install/post-backup.sh ada0... unmounting /ada0/usr unmounting /ada0/var unmounting /ada0 Finished transfer of install to ada0

Finishing the Installation

Once the install is finished, you may "halt" the machine.
# halt
Wait a few moments for any USB activity to cease, and then remove the USB drive and press any key to reboot. Your machine should now boot from the hard drive.
Add Comment

Next: Upgrading an Appliance from v4 to v5