StoreDocumentationSpecialsLatest PostsContactOther Stuff
Last Update: Feb 28th, 2024

Diskutil

Details

Description

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 burn imgfile
diskutil install package [file]
diskutil copydisk
diskutil copyimage imgfile
diskutil erase | mount | unmount disk
diskutil build disk [ssd] [efi]
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, 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.

Comment Policy Add Comment

Next: Upgrading an Appliance from v4 to v5