LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 08-31-2012, 01:04 AM   #1
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
RHEL6 KVM: Add dir based pool volume to guest: CLI HOWTO?


Hi Guys,

have created a dir based pool eg Section 11.1.3.2 https://access.redhat.com/knowledge/...age_Pools.html and 2 volumes within using 12.1 (vol create) & 12.2 (clone vol) from same docco.

Results
Code:
# virsh pool-list --details
Name             State    Autostart  Persistent   Capacity  Allocation  Available
---------------------------------------------------------------------------------
default          running  yes        yes         834.81 GB    12.56 GB  822.25 GB
dir_pool_images  running  yes        yes         834.81 GB    12.56 GB  822.25 GB

# virsh vol-list --details default
Name     Path                             Type  Capacity  Allocation
--------------------------------------------------------------------
vm1.img  /var/lib/libvirt/images/vm1.img  file  20.00 GB     6.13 GB
vm2.img  /var/lib/libvirt/images/vm2.img  file  20.00 GB     6.13 GB

# virsh vol-list --details dir_pool_images
Name  Path                            Type  Capacity  Allocation
----------------------------------------------------------------
vol1  /var/lib/libvirt/dir_pool/vol1  file   9.31 GB     9.31 GB
vol2  /var/lib/libvirt/dir_pool/vol2  file   9.31 GB     8.00 KB
1st 2 are working vms, 2nd 2 are new storage volumes.

QN: How (cli only) can I assign theses vols to the running vms?
 
Old 09-01-2012, 08:03 PM   #2
barghota
Member
 
Registered: Jul 2003
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Debian, FreeBSD
Posts: 94

Rep: Reputation: 38
From 'man virsh';

Quote:
attach-disk domain-id source target optional --driver driver --subdriver subdriver --type type --mode mode --persistent --sourcetype soucetype
Attach a new disk device to the domain. source and target are paths for the files and devices. driver can be file, tap or phy depending on the kind of access. type can indicate cdrom or floppy as alternative to the disk default, although this use only replaces the media within the existing virtual cdrom or floppy device; consider using update-device for this usage instead. mode can specify the two specific mode readonly or shareable. persistent indicates the changes will affect the next boot of the domain. sourcetype can indicate the type of source (block|file)
So,

# virsh machine01 /var/lib/libvirt/dir_pool/vol2 vde
# virsh machine01 /var/lib/libvirt/images/vm1.img vdf

vd[ef]: where the disk will appear under /dev on the guest

Or however you would like to attach them.
 
Old 09-02-2012, 11:02 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Original Poster
Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Tried a few variations; no joy
Code:
 virsh attach-disk vm1 /var/lib/libvirt/dir_pool/vol1 vde
error: Failed to attach disk
error: internal error unable to execute QEMU command '__com.redhat_drive_add': Device 'drive-virtio-disk4' could not be initialized


virsh attach-disk  vm1 /var/lib/libvirt/dir_pool/vol1 vde   --sourcetype dir
error: Unknown source type: 'dir'

virsh attach-disk  vm1 /var/lib/libvirt/dir_pool/vol1 vde   --sourcetype file
error: Failed to attach disk
error: internal error unable to execute QEMU command '__com.redhat_drive_add': Device 'drive-virtio-disk4' could not be initialized

 virsh attach-disk  vm1 /var/lib/libvirt/dir_pool/vol1 vdb --type file
error: Failed to attach disk
error: internal error unknown disk device 'file'


virsh attach-disk vm1 /var/lib/libvirt/dir_pool/vol1 vde   --type dir
error: Failed to attach disk
error: internal error unknown disk device 'dir'
 
Old 09-02-2012, 11:49 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Original Poster
Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Ok; can't make attach-disk work; open to WORKING solns if anyone has them; it should be do-able.

In the meantime, edited vm
Code:
virsh edit vm1

then add stanza

    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/dir_pool/vol1'/>
      <target dev='vdb' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>
NB: don’t add bus field & address type rec; these are auto generated.
This works for anyone else who reads this, then you just restart vm, login and fdisk as usual.

PS I amended the container dir ownership/perms to match vm images dir
Code:
drwx--x--x. 2 root root  4096 Aug 30 11:56 images
drwx--x--x. 2 root root  4096 Aug 30 15:31 dir_pool

Last edited by chrism01; 09-02-2012 at 11:50 PM.
 
Old 09-04-2012, 05:23 AM   #5
barghota
Member
 
Registered: Jul 2003
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Debian, FreeBSD
Posts: 94

Rep: Reputation: 38
Chris,

Instead of 'vde' try 'hde' or 'sde', maybe your libvirtd version doesn't support it, what version is it?
 
Old 09-04-2012, 11:54 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Original Poster
Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Code:
 rpm -qa|grep virt
libvirt-python-0.9.10-21.el6.x86_64
virt-manager-0.9.0-14.el6.x86_64
libvirt-client-0.9.10-21.el6.x86_64
python-virtinst-0.600.0-8.el6.noarch
virt-viewer-0.5.2-9.el6.x86_64
virt-what-1.11-1.1.el6.x86_64
libvirt-0.9.10-21.el6.x86_64
virt-top-1.0.4-3.13.el6.x86_64
Anyway, as you can see from above, it accepts vdb happily in the xml & inside the VM
Code:
df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       16G  6.2G  8.5G  43% /
tmpfs                 939M     0  939M   0% /dev/shm
/dev/vda1             485M   32M  429M   7% /boot
/dev/vdb1             9.2G  149M  8.6G   2% /data
 
Old 09-05-2012, 06:06 AM   #7
barghota
Member
 
Registered: Jul 2003
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Debian, FreeBSD
Posts: 94

Rep: Reputation: 38
Can you post the log file?
 
Old 09-09-2012, 11:31 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Original Poster
Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
OK; just created a new vm and dir pool vol and it worked fine
Code:
virsh attach-disk vm3 /var/lib/libvirt/dir_pool/vol3 vdb
don't know why, but I'm not complaining

Maybe I had the previous vms shutdown at the time because I thought you had to do that?? Just guessing really...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
RHEL6 KVM Host / guest network doesn't chrism01 Linux - Virtualization and Cloud 2 08-19-2012 09:33 PM
Howto connect physical NIC's to a firewall guest only in qemu-kvm environment JaRuKat Linux - Networking 0 11-04-2011 06:54 PM
Creating LVM based guest in KVM vzxen Linux - Virtualization and Cloud 5 10-13-2010 05:07 AM
LXer: HowTo: Install configure KVM Virtualization & run Guest OSes in openSUSE LXer Syndicated Linux News 0 10-01-2008 03:50 AM
howto add a dir to the path? vegetassj2 Linux - Newbie 11 08-16-2006 02:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 03:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration