dd
command. Sparse files are not recommended due to data integrity and performance issues. Sparse files are created much faster and can used for testing but should not be used in production environments.
# dd if=/dev/zero of=/var/lib/libvirt/images/FileName.img bs=1M seek=4096 count=0
# dd if=/dev/zero of=/var/lib/libvirt/images/FileName.img bs=1M count=4096
Guest1
and the file is saved in the users home directory.
# virsh dumpxmlGuest1
> ~/Guest1
.xml
Guest1.xml
in this example) in a text editor. Find the <disk>
elements, these elements describe storage devices. The following is an example disk element:
<disk type='file' device='disk'> <driver name='virtio' cache='none'/> <source file='/var/lib/libvirt/images/Guest1.img'/> <target dev='sda'/> </disk>
<disk>
element. Ensure you specify a device name for the virtual block device attributes. These attributes must be unique for each guest configuration file. The following example is a configuration file section which contains an additional file-based storage container named FileName.img
.
<disk type='file' device='disk'> <driver name='virtio' cache='none'/> <source file='/var/lib/libvirt/images/Guest1.img'/> <target dev='sda'/> </disk> <disk type='file' device='disk'> <driver name='virtio' cache='none'/> <source file='/var/lib/libvirt/images/FileName.img'/> <target dev='sdb'/> </disk>
# virsh create Guest1.xml
FileName.img
as the device called /dev/sdb
. This device requires formatting from the guest. On the guest, partition the device into one primary partition for the entire device then format the device.
n
for a new partition.
# fdisk /dev/sdb Command (m for help):
p
for a primary partition.
Command action e extended p primary partition (1-4)
1
.
Partition number (1-4): 1
Enter
.
First cylinder (1-400, default 1):
Enter
.
Last cylinder or +size or +sizeM or +sizeK (2-400, default 400):
t
.
Command (m for help): t
1
.
Partition number (1-4): 1
83
for a linux partition.
Hex code (type L to list codes): 83
Command (m for help):w
Command (m for help):q
ext3
file system.
# mke2fs -j /dev/sdb1
# mount /dev/sdb1 /myfiles