disk_create
Description:
public bool disk_create (string filename, string format, int64 size, DiskCreate? optargs) throws Error
create a blank disk image
Create a blank disk image called filename (a host file) with format format
(usually raw
or qcow2
). The
size is size
bytes.
If used with the optional backingfile
parameter, then a snapshot is created on top of the backing file. In this case, size
must be passed as @-1. The size of the snapshot is the same as the size of the backing file, which is discovered automatically. You are
encouraged to also pass backingformat
to describe the format of backingfile
.
If filename refers to a block device, then the device is formatted. The size
is ignored since block devices have an intrinsic
size.
The other optional parameters are:
preallocation
If format is raw
, then this can be either off
(or sparse
) or full
to create a sparse or fully allocated file respectively. The default is off
.
If format is qcow2
, then this can be off
(or sparse
), metadata
or full
.
Preallocating metadata can be faster when doing lots of writes, but uses more space. The default is off
.
compat
qcow2
only: Pass the string 1.1 to use the advanced qcow2 format supported by qemu ≥ 1.1.
clustersize
qcow2
only: Change the qcow2 cluster size. The default is 65536 (bytes) and this setting may be any power
of two between 512 and 2097152.
Note that this call does not add the new disk to the handle. You may need to call guestfs_session_add_drive_opts
separately.
Parameters:
this |
A GuestfsSession object |
optargs |
a GuestfsDiskCreate containing optional arguments |
Returns:
true on success, false on error |