Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Red Hat Enterprise Linux Server Cookbook

You're reading from   Red Hat Enterprise Linux Server Cookbook Over 60 recipes to help you build, configure, and orchestrate RHEL 7 Server to make your everyday administration experience seamless

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781784392017
Length 250 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Authors (2):
Arrow left icon
Jakub Gaj Jakub Gaj
Author Profile Icon Jakub Gaj
Jakub Gaj
William Leemans William Leemans
Author Profile Icon William Leemans
William Leemans
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Working with KVM Guests FREE CHAPTER 2. Deploying RHEL "En Masse" 3. Configuring Your Network 4. Configuring Your New System 5. Using SELinux 6. Orchestrating with Ansible 7. Puppet Configuration Management 8. Yum and Repositories 9. Securing RHEL 7 10. Monitoring and Performance Tuning Index

Adding disks on the fly

This recipe includes instructions on how to create different types of storage volumes. Storage volumes are dedicated storage sets aside for use by guests.

Getting ready

There is not a lot of preparation to be done in order to add disks to your guest, which is in contrast to adding CPUs and RAM.

You only need to ensure that the storage pool has enough free disk space to accommodate the new disk.

How to do it…

Similar to the recipe for creating guests, you'll need to create a disk first. This can be done as follows:

  1. Let's create a raw disk in the localfs-vm pool that is 30 GB big through the following command:
    ~]# virsh vol-create-as --pool localfs-vm --name rhel7_guest-vdb.raw --format raw --capacity 30G
    
  2. Look up the path of the newly created volume, as follows:
    ~]# virsh vol-list --pool localfs-vm |awk '$1 ~ /^rhel7_guest-vdb.raw$/ {print $2}'
    

    This will result in the path of your volume; here's an example:

    /vm/rhel7_guest-vdb.raw
    
  3. Attach the disk to the guest, as follows:
    ~]# virsh attach-disk --domain <guestname> --source <the above path> --target vdb --cache none --persistent –live
    

How it works…

Creating a disk using vol-create-as may take some time depending on the speed of your host's disks and the size of the guest's disks.

We will look up the path of the newly created volume as it is a required argument for the command that attaches the disk to the guest. In most cases, you won't need to do this as you'll know how your host is configured, but when you script this kind of functionality, you will require this step.

Adding a disk in this way will attach a disk using the virtio driver, which, as specified earlier, is optimized for use with KVMs.

There's more…

If, for some reason, the original guest doesn't support virtio drivers or you do not have the virtio controller, you can create this yourself. Store the XML configuration file as /tmp/controller.xml with the following contents:

<controller type='scsi' model='virtio' />

You can find this out by checking the host's XML file for the preceding statement.

Then, import the XML configuration file, as follows:

~]# virsh attach-device –domain <guestname> /tmp/controller.xml

This will allow you to create disks using virtio.

You have been reading a chapter from
Red Hat Enterprise Linux Server Cookbook
Published in: Dec 2015
Publisher:
ISBN-13: 9781784392017
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime