Writing an Installation Image to Flash Media¶
Flash Media includes USB drives, Compact Flash cards, and SD cards.
Decompress the Image¶
The most common indication that a file is compressed is its extension, if the filename ends in .gz, .bz2, .zip, or similar then it is likely compressed. If so, decompress it using an appropriate utility:
Using 7-Zip
Right click the downloaded img.gz file.
Click 7-zip.
Click Extract Here.
Use the gunzip
command line utility to decompress the image:
gunzip /path/to/file
Use the gzip
command line utility to decompress the image:
gzip -d /path/to/file
Use the gzip
command line utility to decompress the image:
gzip -d /path/to/file
Connect the Flash Drive to the Workstation¶
Start by connecting the drive to the workstation where the downloaded image resides.
Locate the device name that the system designates for the drive:
The drive will be named after a single uppercase letter, e.g. D. Use Explorer or examine the system control panel and look at the available disks for one matching the drive.
The device name may look like /dev/diskX where X is a decimal
digit. Run diskutil list
from a command prompt or use the GUI tool
Disk Utility.
Note
If the disk is named diskX then the device to pass to the writing utility is actually rdiskX which is must faster for these types of low-level operations.
The device name may look like /dev/sdX where X is a lowercase
letter. Look for messages about the drive attaching in the system log
files or by running dmesg
.
Note
Also make sure the located name refers to the device itself rather than a partition on the device. For example, /dev/sdb1 is the first partition on the disk, so it would be writing to a partition on the device and the drive may not end up being bootable. In that case use /dev/sdb instead so the entire disk is written.
The device name may look like /dev/daX where X is a decimal digit.
Look for messages about the drive attaching in the system log files or by
running dmesg
.
Cleaning The Target Disk¶
Optionally, but recommended, is to get a fresh start and wipe all of the partitions from the disk, as sometimes the target drive already has a partition and cannot be written to properly. This can be done a few different ways:
Warning
By choosing the wrong destination one of the system hard disks could be erased. Check and recheck the disk selection before writing an image.
The Disk Management interface in Windows is one way to delete the partitions from a disk but often it has the operation disabled. The simplest and most reliable method is to use diskpart.
Start a command prompt as Administrator.
Run diskpart.
Type list disk to show the disks connected to the system. One of them will be the target USB flash drive.
Type select disk *n* where n is the disk number of the target USB flash drive from the list in the previous command output.
Type clean to remove the partitions from the disk.
The full diskpart session can be seen here:

Warning
By choosing the wrong destination one of the system hard disks could be erased. Check and recheck the disk selection before writing an image.
The dd command is by far the easiest way to erase the disk’s partition table:
$ sudo dd if=/dev/zero of=/dev/sdz bs=1m count=1
Warning
By choosing the wrong destination one of the system hard disks could be erased. Check and recheck the disk selection before writing an image.
The dd command is by far the easiest way to erase the disk’s partition table:
$ sudo dd if=/dev/zero of=/dev/sdz bs=1M count=1
Warning
By choosing the wrong destination one of the system hard disks could be erased. Check and recheck the disk selection before writing an image.
The dd command is by far the easiest way to erase the disk’s partition table:
$ sudo dd if=/dev/zero of=/dev/sdz bs=1M count=1
Write the Image¶
Now it is time to write the image to the flash drive. The exact procedure varies by Operating System.
Warning
The operations in this section will completely overwrite any existing content on the flash drive so be sure that any files previously stored on the drive are backed up elsewhere.
In order to write an image to a drive from a Windows workstation, it is recommended to use a GUI tool such as Etcher. You can also use Rufus or Win32 Disk Imager as listed below.
Using Rufus
Rufus is a simple but powerful utility that helps format and create bootable USB flash drives, such as USB keys/pendrives, memory sticks.
Download Memstick pfSense image.
Extract the .img file from the .gz archive first.
Select your USB under Device.
Under Create bootable disk using click on the CD-ROM icon.
Select the extracted .img file that you downloaded.
Click Start and wait for image to be copied to USB.
Using Win32 Disk Imager
Win32 Disk Imager is a Free and easy-to-use program to write disk images in Windows. It also only lists removable drives in its GUI which prevents accidentally overwriting a permanent disk.
Start Win32 Disk Imager, and ensure it is running as Administrator.
Click the folder icon (1).
Navigate to the location of the downloaded image file.
Select the image file.
Choose the target drive (2).
Click Write (3).
Wait for the image to finish writing, and a Write Successful dialog will appear.
Warning
The operations in this section will completely overwrite any existing content on the flash drive so be sure that any files previously stored on the drive are backed up elsewhere.
Write the image to the drive using the dd
command. It takes this
general form:
diskutil unmountDisk <usb_disk_device_name>
dd if=<image_file_name> of=<usb_disk_device_name>
diskutil eject <usb_disk_device_name>
For example:
diskutil unmountDisk /dev/rdisk3
sudo dd if=file1.img of=/dev/rdisk3 bs=4m
diskutil eject /dev/rdisk3
The bs=X
is optional and tells dd
to perform reads and writes on
4 MB blocks of data at a time. The default block size used by dd
is
512 bytes. Specifying a larger block size can significantly increase the
writing speed which will result in faster image writing.
Warning
The operations in this section will completely overwrite any existing content on the flash drive so be sure that any files previously stored on the drive are backed up elsewhere.
Write the image to the drive using the dd
command from a shell logged
in as a user with sudo access or the root user directly. It takes this
general form:
sudo dd if=<image_file_name> of=<usb_disk_device_name>
For example:
sudo dd if=file1.img of=/dev/sdb bs=4M
The bs=X
is optional and tells dd
to perform reads and writes on
4 MB blocks of data at a time. The default block size used by dd
is
512 bytes. Specifying a larger block size can significantly increase the
writing speed which will result in faster image writing.
If a warning is printed about “trailing garbage” is may be safely ignored, as it is from the file’s digital signature.
Warning
The operations in this section will completely overwrite any existing content on the flash drive so be sure that any files previously stored on the drive are backed up elsewhere.
Write the image to the drive using the dd
command. It takes this
general form:
dd if=<image_file_name> of=<usb_disk_device_name>
For example:
sudo dd if=file1.img of=/dev/da1 bs=4m
The bs=X
is optional and tells dd
to perform reads and writes on
4 MB blocks of data at a time. The default block size used by dd
is
512 bytes. Specifying a larger block size can significantly increase the
writing speed which will result in faster image writing.
If a warning is printed about “trailing garbage” is may be safely ignored, as it is from the file’s digital signature.