vzvol — ZFS zvol management utility
vzvol [-s|--size size] [-u|--user name] [-v|--volume name]
[--pool] [-t|--type raw|virtualbox] [--file-system filesystem]
[--import .img] [-p] [--format type zpool/zvol] [--delete zpool/zvol]
[--list] [-f]
vzvol is a shell-script designated to help automate the process of
creating a ZFS zvol for use as a storage unit for virtualization or testing.
vzvol was originally created to allow you to back a light
.VMDK file with a zvol for use with VirtualBox. However, additional
functionality has been added over time to make vzvol a general-use
program.
-s, --size value=10G
Set the size of the zvol. Values should include a unit suffix like
M (Megabytes) or G (Gigabytes). Defaults to 10G if unspecified.
-u, --user name
Set the user under which we grant permissions for the zvol. If unused,
your user will automatically be detected.
-v, --volume name
Name of zvol.
-p, --pool
Override the logic to choose the zpool you want your zvol on. By default,
this script selects the first zpool available, unless your first pool is
“bootpool” (this script will default to the second listed pool, usually
“zroot” in a default install on FreeBSD).
-t, --type behaviour
Set the disk type behaviour. The following types are accepted:
-t virtualbox
The default behaviour. vzvol will create a shim VMDK in
your HOME to point to the created zvol.
-t raw
Create a raw, normal zvol with no shim, in the default location
of /dev/zvol/poolname/volumename.
--file-system type
Setting this flag allows you to format the zvol with your choice of
filesystem. The default for vzvol is to not create a filesystem on the new
zvol. Acceptable type values are listed below:
Filesystems with support in FreeBSD:
--file-system zfs
Creates a ZFS filesystem, using the name set in --volume as the
pool name. Requires zfs-utils on Linux.
--file-system ufs
Create a FreeBSD-compatible UFS2 filesystem. Unsupported on Linux.
--file-system fat32
Create an MS-DOS compatible FAT32 filesystem
Filesystems which require sysutils/e2fsprogs on FreeBSD:
--file-system ext2
Create a Linux-compatible ext2 filesystem.
--file-system ext3
Create a Linux-compatible ext3 filesystem.
--file-system ext4
Creates a Linux-compatible ext4 filesystem.
Filesystems which require sysutils/xfsprogs:
--file-system xfs
Create an XFS filesystem.
--import source
Import the contents of a downloaded disk image to your newly created zvol.
This is useful when using a pre-installed VM image, such as
https://github.com/UN/FreeBSD-On-Linode.
-p
Used with --import to show a progress bar for image data importation to the
vzol. Requires that sysutils/pv be installed.
-f
Used to force import or deletion
--format type zvol
Reformat a zvol created by vzvol, using the same options and arguments as
--file-system.
Example:
vzvol --format xfs zroot/smartos
--delete zvol
Delete the zvol you specify. If a .VMDK file is associated with the zvol,
the .VMDK will also be deleted. You MUST specify the zpool the zvol resides
on. You can get this information from running “vzvol --list” or
“zfs list -t volume”.
Example:
vzvol --delete zroot/smartos11
- --list
List all zvols on your system, the type, any associated .VMDK files,
how much space on disk is used by the zvol, the maximum size of the zvol
capacity, and the filesystem, if vzvol can determine it. Imported images
will list FS as “imported”, and any zvol that doesn't have “custom:FS” set
will report “unknown”.
This script is released under the 2-clause BSD license. © 2017, 2018
RainbowHackerHorse <https://github.com/RainbowHackerHorse/vzvol>