|
|
动态挂载硬盘
! y7 \ p0 y s g" P; L! p; ^
" O- s; ]# Y; g9 W3 J" zvirsh list
9 C/ _" U. f5 Z6 x% Q% k. h3 S; J9 Q Id Name State
6 M! R/ G' I" _" ]7 u0 t8 z2 ^---------------------------------4 ?% G8 u% Y9 ^. u8 v; Y7 K. ` e
6 Z5 e- j* _5 c9 j# v; b {
9 Windows2019_x86 running+ l, y3 _$ M0 d
% ?" r6 u' t& U7 G# f$ M% b
/ T9 L$ ]/ R. w
+ s. M7 ~; U& p3 |# E0 T编辑挂在硬盘xml( Z% v& n3 m$ O, R' z9 u$ s) ^5 m+ I
vim attach.xml 9 r8 P8 x8 g/ ]+ \2 h& X' v
<disk type='file' device='disk'>
# a; l* k% e/ N, g1 C6 ` <driver name='qemu' type='qcow2'/>
9 L2 c* P) |% [4 {& x1 J# W4 u <source file='/usr/src/CloudbaseInitSetup_1_1_2_x86.msi.iso'/>
+ e1 y, P' T4 s. ?$ Y <target dev='sdc' bus='virtio'/>' r \0 ]0 b) q
</disk>
: w7 t" Q" b# m" Q& f! B) j1 _1 O$ v0 t' o$ x
$ L0 s/ n0 c W0 o _
使用命令挂载
( {$ Q, [; B8 E5 F5 @' \
8 l5 c! u- o8 v5 xsudo virsh attach-device Windows2019_x86 attach.xml
7 f& w$ @, q* s+ n/ B; X* y1 p9 T6 C# v y' `. |& _
$ ]& V @1 B& [5 T" J5 W' B- w) W5 p6 n' g4 m
virsh attach-device Windows2019_x86 attach.xml
+ e5 d% q6 m1 x) z3 L r* Yerror: Failed to attach device from attach.xml
$ o* H: l) h6 S. \7 y# t5 q" eerror: internal error: unable to execute QEMU command 'blockdev-add': Image is not in qcow2 format, B7 g9 D: `+ ~
5 Z3 m9 J7 a5 ^3 L' m2 M$ G
- e8 a: _* x+ c& V3 t; [修改
# d! ]6 g1 m3 Tvim attach.xml 9 o# u$ A2 D8 O, e7 w9 R
<disk type='file' device='disk'>% s2 B' w% y% g/ ?1 c) [- [) x
<driver name='qemu' type='raw'/>9 R1 B8 {9 F6 A! A9 j+ A: F
<source file='/usr/src/CloudbaseInitSetup_1_1_2_x86.msi.iso'/>
/ d9 L& n9 @) R- K4 @! L <target dev='sdc' bus='virtio'/>
" Z! P: o4 Y2 W! w' `</disk>6 ]8 [+ U2 N5 r4 `( i4 |0 `+ @3 u
) a% _$ v% b/ s! o* M
" R" F& p W# ^8 \/ `* sroot@compute01:/usr/src# virsh attach-device Windows2019_x86 attach.xml 5 m5 _$ i7 o7 `0 p9 L5 ~
Device attached successfully/ o7 D( p) z K6 V
( H; w4 g: K$ x& U v5 k6 a& Z$ O
为了马上识别到文件信息:* U: m! |6 R$ z6 i; P0 c$ A' o
, M/ y9 Z9 ?4 S8 S$ F
<disk type='file' device='cdrom'>% G3 B G0 h% u
<driver name='qemu' type='raw'/>* c# \% s) k; I8 m8 O5 _# K/ x
<source file='/usr/src/CloudbaseInitSetup_1_1_2_x86.msi.iso'/>0 U$ I! V( V! F
<target dev='sdc' bus='sata'/>
' _( x/ V& t' _4 Q9 u <readonly/>8 ~) D! g% p& {, X( p5 A r2 \5 q
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
! r/ q+ K% W# c$ A$ k. I </disk># u2 A [% U6 s
/ w! c0 `: a' K. n0 k% R' C) r- I6 {: o$ B1 r
|
|