- 积分
- 16843
在线时间 小时
最后登录1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
virsh 在线添加设备cdrom或者iso镜像
U+ y h- V% R6 {virsh domblklist Windows2019_x86 8 `) s: t7 l: Q# K
Target Source3 z! E) J# G: B& N! q+ V7 A& r
----------------------------------------------------------------
6 ~- H3 }0 g" J1 ~& R vda /usr/src/Windows2019-x86.qcow2
" A( a! k: R# q sda /usr/src/cn_windows_server_2019_x64_dvd_2d80e042.iso
/ [8 [' i% p' S) p% b( ]
5 E5 f& i+ i% z. d+ H/ U. M9 q" w$ F! u8 |+ G. Z
0 Y. Y1 y4 s) q9 J: kvirsh attach-disk Windows2019_x86 --target sdb --type cdrom /usr/src/virtio-win-0.1.225.iso --mode readonly @4 V, N$ t0 q C8 X, l& W" z7 p
error: Failed to attach disk
0 _* x+ f D" `0 herror: Operation not supported: cdrom/floppy device hotplug isn't supported
5 C( L9 ?3 |% |' c- O/ h
+ ^+ R: g4 M4 M" ^0 T- r. ]! N! K% J- {0 i* }+ r! |
% l! E4 M; I( x. J6 ?root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso sdb --cache none --subdriver cdrom --config --persistent
& _$ z1 J- s; d7 L, {5 W; `) c0 Oerror: Failed to attach disk0 h/ Z: p' N, @. Q( \4 k
error: unsupported configuration: unknown driver format value 'cdrom'
5 Y9 E- H R) D' ]2 m& c% B/ g, z8 Y$ y
root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso sdb --cache none --subdriver qcow2 --config --persistent & E# w; Z. g$ i+ c/ E
error: Failed to attach disk
t3 R6 k R) X0 _0 d# X5 ?error: internal error: No more available PCI slots
- v# L) p2 V4 U# @) S& _+ v' _' W
4 b* A; N8 M2 F& broot@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso vdc --cache none --subdriver qcow2 --config --persistent
: H; ~% {/ K- N* K/ l3 aerror: Failed to attach disk" M0 h% n c. x. F/ Z( b( q: j
error: internal error: unable to execute QEMU command 'blockdev-add': Image is not in qcow2 format+ ^# N- y5 W7 m/ Q% ]
4 W" F8 X# O+ I( L3 k
root@compute01:/usr/src# virsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso vdc --cache none --subdriver raw --config --persistent [. [9 s$ k# l0 J6 L7 |- }
Disk attached successfully5 V1 A% v0 p+ c2 ^
; U! \' e" P2 I, L. L- d2 v" b
% Z" ^8 A! c: r6 _; E3 ]4 b9 n @. J* G: n$ z4 \7 c# g! R
root@compute01:/usr/src# virt-install --name=Windows2019_x86 --ram 8192 --vcpus=4 --disk path=/usr/src/Windows2019-x86.qcow2,format=qcow2,size=15,bus=virtio --accelerate --cdrom /usr/src/cn_windows_server_2019_x64_dvd_2d80e042.iso --vnc --vncport=5906 --vnclisten=0.0.0.0 --network bridge=br0,model=virtio --noautoconsole --disk path=/usr/src/virtio-win-0.1.225.iso,device=cdrom# P% |: K) `6 |2 x+ |+ Q
0 J! p! c- P0 u2 }Starting install...5 j7 u' O- L4 ^) G6 u1 J- q/ w
ERROR Cannot get interface MTU on 'br0': No such device
3 n8 l" e3 h* b& h8 G* {Domain installation does not appear to have been successful.
' u! f; g+ N7 h$ bIf it was, you can restart your domain by running:
& h$ Y- W& S7 d1 g! a virsh --connect qemu:///system start Windows2019_x86
7 p# `7 ]4 ]# y# s$ K0 }: |# ?otherwise, please restart your installation.7 a: z0 ^8 ~+ u# J6 z; h) z
root@compute01:/usr/src# ; U* A. d) I. P3 U7 O2 o
root@compute01:/usr/src# # W8 g6 S- b2 Y. k8 {
root@compute01:/usr/src# netplan apply
/ `; k7 N) m1 J- ?4 }* A7 j! W% s% }. M/ o& F
** (generate:8799): WARNING **: 13:35:59.651: `gateway4` has been deprecated, use default routes instead./ G' D$ G1 A2 _
See the 'Default routes' section of the documentation for more details.
8 B5 {4 A; X! ~) v5 v" ^, ~) y! B/ o/ X2 {' k/ H
** (process:8797): WARNING **: 13:36:01.040: `gateway4` has been deprecated, use default routes instead.
6 _ ]. v: o6 o, O N# wSee the 'Default routes' section of the documentation for more details.. A: b; ^) N4 P
! W: N& ^3 G' h1 ^" W/ r" y
** (process:8797): WARNING **: 13:36:01.052: `gateway4` has been deprecated, use default routes instead." E, E! q- ~' T1 r; q% d2 ]4 r: a
See the 'Default routes' section of the documentation for more details.
2 ~) O3 D3 i. M: Q" [' u5 b& K) g+ q1 ~ m
** (process:8797): WARNING **: 13:36:01.589: `gateway4` has been deprecated, use default routes instead.
$ F3 r& w {% [2 }1 z! VSee the 'Default routes' section of the documentation for more details. I2 Z6 S& S( q, }7 v
N1 S1 I4 @! B) n** (process:8797): WARNING **: 13:36:01.589: `gateway4` has been deprecated, use default routes instead.
+ M% B+ k) E8 m: |: ?See the 'Default routes' section of the documentation for more details.
9 ^4 l' r! k# Y! |& A1 iroot@compute01:/usr/src# . h( V) K+ ]4 s* G- P& q5 p' \/ @7 l
root@compute01:/usr/src# 8 v- O3 o: E' d3 l- q
root@compute01:/usr/src# virt-install --name=Windows2019_x86 --ram 8192 --vcpus=4 --disk path=/usr/src/Windows2019-x86.qcow2,format=qcow2,size=15,bus=virtio --accelerate --cdrom /usr/src/cn_windows_server_2019_x64_dvd_2d80e042.iso --vnc --vncport=5906 --vnclisten=0.0.0.0 --network bridge=br0,model=virtio --noautoconsole --disk path=/usr/src/virtio-win-0.1.225.iso,device=cdrom9 G/ N. U& b$ C: S7 O8 S* D
+ E/ T$ D9 ~) ?Starting install...+ c9 h# e3 p/ Q0 l7 \. T
Creating domain... | 0 B 00:00:00 : {* I" Q, ?" o3 ]
/ w8 A2 a/ Q/ h9 iDomain is still running. Installation may be in progress.$ {; c! a' p' G4 o8 |
You can reconnect to the console to complete the installation process.
, E8 R$ y* A- m: K, Rroot@compute01:/usr/src# - x+ ^; [- _0 x @. j' O i; ?
% l) O- r1 r: G
在线添加光盘
l& D. _5 I5 `. q% N+ N+ }2 Dvirsh attach-disk Windows2019_x86 /usr/src/virtio-win-0.1.225.iso/ vdd
; b$ v3 ?# z1 M5 T D: }) G8 F; r" {# f$ D+ j
其他方法:2 d; L4 Z( o" `" W
@$ K+ {+ B( x0 C. `1 K0 z! H
; W+ o' [- R4 U' s( q
再次使用 virsh dumpxml sles12-sp3 可以看到iso文件加载:
; I# s& K/ O" }0 l4 ~- {! G0 Y$ c5 T3 D8 G, t* x2 o5 }3 d
<disk type='file' device='cdrom'>+ [* z$ e% h% e
<driver name='qemu' type='raw'/>
: O; K* g# x0 G! t! ~- O1 k5 ^: S <source file='/var/lib/libvirt/images/SLE-12-SP3-Server-DVD-x86_64-GM-DVD1.iso' index='3'/>
% D4 D$ e, B5 ]+ [8 _8 K6 T" i: c4 z <backingStore/>1 c$ ^0 ^ F' P" D" X' e" Z
<target dev='sda' bus='sata'/>
7 q1 i9 h& S9 p3 y: @( [3 c. ? <readonly/>, x. c# Q( w" [5 n. t3 C
<alias name='sata0-0-0'/>
, d. v' z6 n& d" V% x* g <address type='drive' controller='0' bus='0' target='0' unit='0'/>5 J" V' W/ r7 a5 Z y% P+ m. s
</disk>
$ l- @5 B" N r# X9 L如果要卸载这个iso文件,则创建一个相同结构的xml文件 detach_iso.xml ,但是保持 <source/> 行删除:
) n4 Y- T. E7 b; a3 \6 T+ v4 a) `! Q% Q/ @8 b* ^
<disk type='file' device='cdrom'># ~- C8 _( O/ i' ~1 x! g# g
<driver name='qemu' type='raw'/>
, t0 E O0 E+ n& |- @; `& y* ~ <backingStore/>
2 W& E9 D3 j4 F* B L' | <target dev='sda' bus='sata'/>
$ i1 H( J! {, R) B <readonly/>9 h) j! T3 A/ X9 ]
<alias name='sata0-0-0'/>
$ s6 \9 m' b O$ ]0 N3 Y4 B5 n$ W- I <address type='drive' controller='0' bus='0' target='0' unit='0'/>5 H) T4 c$ b" I# W3 j+ O$ h
</disk>; }- \( \* k: |
然后执行设备更新:
! q& _: P, o% e% B9 p0 \! D% r/ ?8 J9 M: N* W
virsh update-device sles12-sp3 detach_iso.xml5 N4 ^, F; c' Q5 L7 F$ b# e" s
此时提示:
! z' w5 C! f) T( J
) c! d5 o+ Q2 y/ o9 [, {; jDevice updated successfully
a+ e& Y- F, F" B再检查虚拟机配置,就看到iso文件已经卸载了。( o# W" B1 s+ x9 T+ x4 o p' `! \1 h
3 P. z5 I% S6 T
|
|