[OmniOS-discuss] add second storage device in KVM?

Jorge Schrauwen sjorge+ml at blackdot.be
Wed Oct 1 17:32:33 UTC 2014


Hi Johan,

Just add another line like this:
-drive file=$HDD2,if=virtio,index=1 \

Were you increment the index value. Does not need to be more complicated 
than it has to be right :)

Regards

Jorge


On 2014-10-01 19:29, Johan Kragsterman wrote:
> Hi!
> 
> Funny, I never thought about this until now:
> 
> How do I add a second storage device in a KVM VM?
> 
> It came up now, when I installed FreeNAS 9.3 beta as a VM, and wanted
> to add storage pools.
> 
> I looked at my start script, and of coarse I could do some
> experimenting, but perhaps there are also other people on this list
> that want to know this too.
> 
> My script looks like this:
> 
> 
> root at omni:~# cat /usr/bin/freenas.sh
> #!/usr/bin/bash
> 
> # on omnios command is /usr/bin/qemu-system-x86_64
> 
> # configuration
> NAME="freenas"
> NUM=5
> VNIC0=freenas0
> HDD=/dev/zvol/rdsk/mainpool/vm/freenas/os
> CD=/mainpool/nfs/iso/freenas.iso
> MEM=8192
> 
> # don't change below here!
> 
> TLN=`expr 7000 + $NUM`
> mac0=`dladm show-vnic -po macaddress $VNIC0`
> 
> /usr/bin/qemu-system-x86_64 \
> -name $NAME \
> -boot cd \
> -enable-kvm \
> -vnc 0.0.0.0:$NUM \
> -smp cores=2,threads=2,sockets=1 \
> -m $MEM \
> -no-hpet \
> -localtime \
> -drive file=$HDD,if=virtio,index=0 \
> -drive file=$CD,media=cdrom,if=ide,index=2 \
> -net nic,vlan=0,name=net0,model=virtio,macaddr=$mac0 \
> -net vnic,vlan=0,name=net0,ifname=$VNIC0,macaddr=$mac0 \
> -vga std \
> -cpu host \
> -pidfile /mainpool/vm/freenas/pids/$NAME.pid \
> -monitor telnet:localhost:$TLN,server,nowait,nodelay \
> -daemonize
> 
> if [ $? -gt 0 ]; then
>     echo "Failed to start VM"
>     exit
> fi
> 
> port=`expr 5900 + $NUM`
> public_nic=$(dladm show-vnic|grep vnic0|awk '{print $2}')
> public_ip=$(ifconfig $public_nic|grep inet|awk '{print $2}')
> 
> echo "Started VM: $NAME"
> echo "VNC available at: host IP ${public_ip} port ${port}"
> echo "QEMU Monitor, do: # telnet localhost $TLN. Note: use Control ]
> to exit monitor before quit!
> "
> root at omni:~#
> 
> 
> The nics are numbered, are the storage devices also numbered?
> 
> In linux the can "hot add" via virsh. Can't find any docs from linux
> that are useful for me...
> 
> 
> 
> Best regards from/Med vänliga hälsningar från
> 
> Johan Kragsterman
> 
> Capvert
> 
> _______________________________________________
> OmniOS-discuss mailing list
> OmniOS-discuss at lists.omniti.com
> http://lists.omniti.com/mailman/listinfo/omnios-discuss


More information about the OmniOS-discuss mailing list