Installation guide
Pro ced u re 19 .1. Creat in g an d mou n t in g a lo g ical vo lu me o n a g u est wit h SELin u x
en ab led
1. Create a logical volume. This example creates a 5 gigabyte logical volume named
NewVolumeName on the volume group named volumegroup.
# lvcreate -n NewVolumeName -L 5G volumegroup
2. Format the NewVolumeName logical volume with a file system that supports extended
attributes, such as ext3.
# mke2fs -j /dev/volumegroup/NewVolumeName
3. Create a new directory for mounting the new logical volume. This directory can be anywhere
on your file system. It is advised not to put it in important system directories (/etc, /var,
/sys) or in home directories (/home or /root). This example uses a directory called
/virtstorage
# mkdir /virtstorage
4. Mount the logical volume.
# mount /dev/volumegroup/NewVolumeName /virtstorage
5. Set the correct SELinux type for a Xen folder.
semanage fcontext -a -t xen_image_t "/virtstorage(/.*)?"
Alternatively, set the correct SELinux type for a KVM folder.
semanage fcontext -a -t virt_image_t "/virtstorage(/.*)?"
If the targeted policy is used (targeted is the default policy) the command appends a line to
the /etc/selinux/targeted/contexts/files/file_contexts.local file which
makes the change persistent. The appended line may resemble this:
/virtstorage(/.*)? system_u:object_r:xen_image_t:s0
6. Label the device node (for example, /dev/volumegroup/NewVolumeName with the correct
label:
# semanage fcontext -a -t xen_image_t /dev/volumegroup/NewVolumeName
# restorecon /dev/volumegroup/NewVolumeName
19.3. SELinux
This sections contains topics to consider when using SELinux with your virtualization deployment.
When you deploy system changes or add devices, you must update your SELinux policy
accordingly. To configure an LVM volume for a guest, you must modify the SELinux context for the
respective underlying block device and volume group.
# semanage fcontext -a -t xen_image_t -f -b /dev/sda2
# restorecon /dev/sda2
Red Hat En t erp rise Lin ux 5 Virt ualizat ion Guid e
216