Show Table of Contents
13.3.2. Adding Hard Drives and Other Block Devices to a Guest
System administrators have the option to use additional hard drives to provide increased storage space for a guest, or to separate system data from user data.
Procedure 13.2. Adding physical block devices to guests
- This procedure describes how to add a hard drive on the host physical machine to a guest. It applies to all physical block devices, including CD-ROM, DVD and floppy devices.Physically attach the hard disk device to the host physical machine. Configure the host physical machine if the drive is not accessible by default.
- Do one of the following:
- Create the additional storage by writing a
diskelement in a new file. In this example, this file will be known asNewStorage.xml. The following example is a configuration file section which contains an additional device-based storage container for the host physical machine partition/dev/sr0:<disk type='block' device='disk'> <driver name='qemu' type='raw' cache='none'/> <source dev='/dev/sr0'/> <target dev='vdc' bus='virtio'/> </disk> - Follow the instruction in the previous section to attach the device to the guest virtual machine. Alternatively, you can use the
virsh attach-diskcommand, as shown:# virsh attach-disk Guest1 /dev/sr0 vdc
Note that the following options are available:- The
virsh attach-diskcommand also accepts the--config,--type, and--modeoptions, as shown:#
virsh attach-disk Guest1 /dev/sr0 vdc --config --type cdrom --mode readonly - Additionally,
--typealso accepts--type diskin cases where the device is a hard drive.
- The guest virtual machine now has a new hard disk device called
/dev/vdcon Linux (or something similar, depending on what the guest virtual machine OS chooses) orD: drive(for example) on Windows. You can now initialize the disk from the guest virtual machine, following the standard procedures for the guest virtual machine's operating system. Refer to Procedure 13.1, “Adding file-based storage” and Procedure 13.1, “Adding file-based storage” for an example.Warning
When adding block devices to a guest, make sure to follow security considerations. This information is discussed in more detail in the Red Hat Enterprise Linux Virtualization Security Guide which can be found at https://access.redhat.com/site/documentation/.Important
Guest virtual machines should not be given write access to whole disks or block devices (for example,/dev/sdb). Guest virtual machines with access to whole block devices may be able to modify volume labels, which can be used to compromise the host physical machine system. Use partitions (for example,/dev/sdb1) or LVM volumes to prevent this issue.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.