lost and found ( for me ? )

KVM : add a storage to running VMs by “virsh attach-disk” command



# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Linux Mint 12 Lisa"
# uname -ri
3.0.0-16-generic x86_64

# libvirtd --version
libvirtd (libvirt) 0.9.2

# virt-manager --version
0.9.0

# kvm --version
QEMU emulator version 0.14.1 (qemu-kvm-0.14.1), Copyright (c) 2003-2008 Fabrice Bellard


start a VM ( this VM is openfiler 2.99 )
virsh # start filer01


The VM , fieler01 , has three storage devices , sda , sdb and sdc.
[root@filer01 ~]# dmesg | grep sd[a-z] | grep -i attach
sd 0:0:0:0: [sda] Attached SCSI disk
sd 0:0:1:0: [sdb] Attached SCSI disk
sd 1:0:1:0: [sdc] Attached SCSI disk


add one more storage via virsh

on the KVM host , create a storage file for that VM
# qemu-img create -f raw filer01-data1.img 1G


on the KVM host , add that storage as “/dev/sdd” to that running VM
virsh # attach-disk --driver file filer01 /var/disk1/libvirt/images/filer01-data1.img sdd
error: Failed to attach disk
error: internal error unsupported driver name 'file' for disk '/var/disk1/libvirt/images/filer01-data1.img'


nnn , error ,,

Let’s check libvirt.log.

/var/log/libvirt/libvirtd.log
error : qemuDomainAttachDeviceDiskLive:3994 : internal error unsupported driver name 'file' for disk '/var/disk1/libvirt/images/filer01-data1.img'


nnnn , I’m not familiar with virsh command…

How about this ?
virsh # attach-disk filer01 /var/disk1/libvirt/images/filer01-data1.img sdd --type disk
Disk attached successfully


I could add the storage ( /dev/sdd )
[root@filer01 ~]# dmesg | grep sd[a-z] | grep -i attach
sd 0:0:0:0: [sda] Attached SCSI disk
sd 0:0:1:0: [sdb] Attached SCSI disk
sd 1:0:1:0: [sdc] Attached SCSI disk
sd 2:0:3:0: [sdd] Attached SCSI disk


The following is an excerpt of xml file of the VM to which I added a storage via virsh attach-disk
   <disk type='block' device='disk'>
     <driver name='qemu' type='raw'/>
     <source dev='/var/disk1/libvirt/images/filer01-data1.img'/>
     <target dev='sdd' bus='scsi'/>
     <alias name='scsi0-0-3'/>
     <address type='drive' controller='0' bus='0' unit='3'/>
   </disk>


The following is via virt-manager
   <disk type='file' device='disk'>
     <driver name='qemu' type='raw'/>
     <source file='/var/disk1/libvirt/images/filer01-data.img'/>
     <target dev='hdd' bus='ide'/>
     <alias name='ide0-1-1'/>
     <address type='drive' controller='0' bus='1' unit='1'/>
   </disk>


let’s create a partition on /dev/sdd

warning … partition table is GPT …
[root@filer01 ~]# fdisk /dev/sdd

WARNING: GPT (GUID Partition Table) detected on '/dev/sdd'! The util fdisk doesn't support GPT. Use GNU Parted.


change the partition table to msdos from gpt
[root@filer01 ~]# parted /dev/sdd
GNU Parted 1.8.8
Using /dev/sdd
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
Warning: The existing disk label on /dev/sdd will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? Yes
New disk label type?  [gpt]? msdos
(parted) quit
Information: You may need to update /etc/fstab.


Ok , no warning message
[root@filer01 ~]# fdisk /dev/sdd

Command (m for help): q

[root@filer01 ~]#

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.