|
|
在centos7.2系统上安装xen服务 r b4 R1 t5 {4 o v# K
0 @" H0 J1 R5 |8 Y; {4 b$ R, A
" T1 \, Y8 h8 h- g2 C w; O* A1 v" t. _4 i- I& h. z) Q
[root@localhost ~]# cat /etc/centos-release" P6 W4 K1 ?' L
CentOS Linux release 7.2.1511 (Core)
* P a, s( M, V8 F) ~% U
6 q8 |) `# a" _* l0 n; }调整selinux
3 w# B N5 d7 |3 V- q2 W, K' c5 @1 I' Y/ c) V9 F/ B4 p* U
SELINUX=disabled
; A% P3 n" t% q! @9 J m
2 Z& g k+ z* r( n* v
, E' ~. h. g5 |$ S6 b9 ?. R% H7 F
, C) {" _# f4 x. a2 j% M首先配置yum源:6 _, ?# q2 |2 t' Z X! I6 H/ G
_" V8 l7 A7 R9 R% N; Q
; o% s8 `* B! {7 P+ E5 H+ ~[base]. Q7 r- ^' w7 q5 B" z
name=CentOS-$releasever - Base1 _) j% d/ l u; x+ Z, M2 B8 x
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra( s1 A% d1 }, S" U
baseurl=https://mirrors.aliyun.com/centos-vault/7.2.1511/os/x86_64/( C! X: ] C; t. l' s' R, C+ U ]' b
gpgcheck=1 I% z/ _* P5 i1 |0 x) o; _
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
& V6 r( V' J7 E U) n
1 |9 Q& H1 N* K4 m. N#released updates
3 p! D; s) h& n. K. E0 m0 p[updates]
% ~1 M' k0 W8 ^+ x% z$ mname=CentOS-$releasever - Updates
3 {" w) }" S f. G" X#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra: n! \! s7 p7 E
baseurl=https://mirrors.aliyun.com/centos-vault/7.2.1511/updates/x86_64/; Y6 D% A/ G4 U; Q3 F
gpgcheck=10 n. T/ k# b- n3 A; I, f1 n
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-76 q" S+ U K% T$ p& a+ K* i
) [2 N4 h% F3 @* F( l: i% @3 t* ?+ i#additional packages that may be useful
) j2 [9 Y& o. S8 z# Q, d* y2 B7 y) w' B- i
#additional packages that extend functionality of existing packages
}2 P2 k! `; o+ [[centosplus]. k% S3 F. n6 w& p& j% Y9 A
name=CentOS-$releasever - Plus
. i& o5 B- k* M1 Q4 f#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
! Y" I: ], @$ }. R9 Z: K1 kbaseurl=https://mirrors.aliyun.com/centos-vault/7.2.1511/centosplus/x86_64/
; _0 a7 A+ Y7 k/ E: w4 m+ dgpgcheck=1, d& f; K$ s1 {+ w
enabled=0
3 Q5 P1 W$ _" N# g$ ^7 F" F6 ?5 g3 f, |gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7/ y' O) Z+ R% A9 r
1 P e" i- A m. T" ^# q; ^* s5 ]( I# \( p
安装基础软件5 }: W) m; z0 O( N. N( c
yum install -y vim ; o4 [. d8 r* g$ i! Y+ y5 M
yum install lrzsz -y# G0 X- u' u; H8 F: ^ ]
- s4 z: Q+ M+ Y& L, n( S/ m
) e7 Y( ?4 t; P0 f
. P9 b q9 a6 }7 n4 r3 c! S1.下载xen的 源代码. t$ s; N2 {1 G# q% \2 R$ T! f' K) F4 c
https://xenproject.org/downloads ... roject-4-10-series/
9 T2 b" T- B. ]. P5 n- l8 k
; @* C7 |8 ?1 j6 Q, J ,解压 ; I$ G: v2 }5 j9 F- Q- x
# t. n, S2 V4 B! ^2 j& X- Q
* k7 Z1 i& Z( L6 o; v
4 S% z" [: ^6 u9 X2 u% ~% ?
7 u6 l/ _3 X1 ~4 L
tar -zxvf xen-4.10.0.tar.gz
- r- ^: Y$ h1 V2 \! Hunzip xen-RELEASE-4.10.0.zip
d% l3 N5 B5 y4 d2 o9 Z; j) J$ d8 [7 F! D0 S, z# ~2 [( e/ `8 @6 |
9 _, }0 n0 E$ \4 e0 \# Kcd xen-RELEASE-4.10.0+ d+ {. J- f" ~( X0 T& n
. Y3 U" o/ o$ H5 d/ o8 a
#make help ) }5 k3 [. K& ^. `2 h
9 m* f4 t% b5 w' o
1 S8 o5 |! _, _" K
! }* |/ Y5 c8 n) q+ V4 t
* O+ X4 t# E; i& S& E. B4 D+ Y3 \( u$ B. Y G7 ~" R/ \: Z6 k( ~
[url=]dev86-0.16.21-2.el7.x86_6 ...[/url]- ^1 X3 w9 m9 @+ U( g$ Z3 H) R
安装软件:, ?$ _( a" }7 x, M3 h& t, ?
9 r. g1 U5 K8 s! Ryum install dev86-0.16.21-2.el7.x86_64.rpm -y * c! o5 j d; n! R: W" G- J" I9 R
1 N* |, Y! }- v! V; n5 [1 K+ N
Dependencies Resolved
/ \! F0 v# ^% l7 o' D" j
% E' u8 Q, w) g$ Q H==============================================================================================================================================================$ B* l1 M& C3 t5 C2 l" \
Package Arch Version Repository Size
6 n) z! o, t. t( }==============================================================================================================================================================4 X5 c5 C/ A! f6 {& d; f9 q6 q+ S( }& W
Installing:1 s$ Y6 U6 l* \: v, \1 f
dev86 x86_64 0.16.21-2.el7 /dev86-0.16.21-2.el7.x86_64 991 k+ w* p/ b" [6 ^* }9 [8 G
& {+ [; D7 z4 h8 }% M/ `2 y O1 m7 E% N: o: U; b% n) v1 E% Q" C
Installing : dev86-0.16.21-2.el7.x86_64 1/1 % A* y: x) u( e' l6 V, u
Verifying : dev86-0.16.21-2.el7.x86_64 1/1 Q8 K, T+ a, u' W) K
2 [, p' g2 Z C Y4 u( I9 s
Installed:9 h+ |: G9 s; V" G
dev86.x86_64 0:0.16.21-2.el7
6 _% K& g) b- U
' f o3 h( E1 EComplete!
7 i8 Q6 r* w9 y% i6 T y/ o; I
: D1 N! L0 v1 r( C1 |" `
: ]$ D9 ^9 ] i' C0 j6 @##yum install lzma* h5 G3 \8 {/ i; n& I# Z2 @( b! F+ a' ?
Loaded plugins: fastestmirror6 H9 V$ m! V- Y8 r5 h
Loading mirror speeds from cached hostfile
& e) X0 s9 z. T6 ]Resolving Dependencies/ y% _3 R( c0 W
--> Running transaction check
X5 V- _( R; |3 M---> Package xz-lzma-compat.x86_64 0:5.1.2-12alpha.el7 will be installed4 X4 v$ ~2 y0 r _- A
--> Finished Dependency Resolution) `$ l& h5 ~# Q, g+ j) W+ x% q6 U1 H
X( T- u- B2 x& X% E$ QDependencies Resolved% ^1 R" [' {: K) U0 o9 ^9 n/ F# t E
. |: G* P' Y% F- y==============================================================================================================================================================8 _7 d8 R5 y4 J$ X
Package Arch Version Repository Size; Z: [/ I& p. a. E; t( l% \+ E
==============================================================================================================================================================/ h" v- C$ _; Y
Installing:/ a- Q4 _7 f$ }1 y6 Z( U* N, M
xz-lzma-compat x86_64 5.1.2-12alpha.el7 base 18 k
* X7 t; l; a5 G, }$ r" r* J; a0 e
, p) w- k1 ]5 b; G- p% tTransaction Summary
+ _9 L% E, y& ~, `+ y; Z8 D( X==============================================================================================================================================================
, ~3 ^7 i3 R! h3 M- a# GInstall 1 Package
( ~6 @( b) U5 }/ ^6 N2 ]+ L f: ?( F. n
* H9 M4 ?3 ]" }* S4 @
Running transaction
: G$ s4 @7 n0 [& `" e Installing : xz-lzma-compat-5.1.2-12alpha.el7.x86_64 1/1 - l/ a: y7 E# i& ~6 |* B! N8 r; \- m
Verifying : xz-lzma-compat-5.1.2-12alpha.el7.x86_64 1/1 . Q! K' y/ F% h
. \4 T& w# p- n
Installed:
$ v+ P' L. T$ R4 p. C# \9 X xz-lzma-compat.x86_64 0:5.1.2-12alpha.el7 % a% l! Z( L7 J% s
# K0 B& O6 ~* d4 G4 g( CComplete!
4 m \+ W3 z1 t& ~/ h) V5 Y' Q8 e& w4 S9 ]. u6 `" N1 ]% } i4 B
- @& W+ u" O/ S' g4 c) `8 s##yum install -y xz-devel python-devel iasl acpica-tools libuuid-devel libuuid libcurl-devel ncurses-devel glib2-devel pixman-devel wget ftp yajl yajl-devel zlib-devel zlib libstdc++-devel glibc-devel.i686 glibc-devel patch$ A: O& G8 H4 l( K
) L4 `. J7 s2 ~
yum install -y xz-devel python-devel iasl acpica-tools libuuid-devel libuuid libcurl-devel ncurses-devel glib2-devel pixman-devel wget ftp yajl yajl-devel zlib-devel zlib libstdc++-devel glibc-devel.i686 glibc-devel patch lzma git( x* P% \3 X0 L' X
& h; f* A5 T" g& \#yum install -y gcc gcc-c++ git patch texinfo python-devel acpica-tools libuuid-devel ncurses-devel glib2 glib2-devel libaio-devel openssl-devel yajl-devel glibc-devel glibc-devel.i686 pixman-devel bc
! \( z- d( u& E3 L) R6 r9 j, l/ A4 d, u! a
#yum groupinstall "Development Tools" -y$ Y$ m% R* y9 r7 ^# l( N- E
8 ~. q5 f: d( g- L! F2 y, P
注:在安装的时候会出现一些错误,原因是一些工具软件没有安装,提示什么没有,使用yum install dev86(等等)安装就可以了。
* X. p6 J0 _+ ]1 m# u5 H
* t7 W# A7 B- W/ E8 `#make dist-xen dist-tools
, |* O; J! O' K. N4 E! P+ H第二种:5 G; h% `, f* E0 S% i
#make dist
% h5 L& d# A0 v6 E1 l: L9 n" T1 w& q+ H }9 B% B s
P! H5 M4 ^, s5 F
running install, y" C) q: ~& ^3 k/ N$ y0 J8 b, [
running build
7 Q8 w/ X( z/ g- ?- w$ Z1 }running build_py+ g& \& `. j& B2 H* ?
running build_ext
) m* I7 {3 `: U. trunning build_scripts
1 j+ y% B$ L1 X2 Brunning install_lib9 ~/ H, H# y3 q' t( @# T
creating /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub6 r, X: r0 D% w5 [% ^
copying build/lib.linux-x86_64-2.7/grub/ExtLinuxConf.py -> /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub
# J. q! p9 l, g9 P0 I5 pcopying build/lib.linux-x86_64-2.7/grub/GrubConf.py -> /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub
+ J. w& \8 b7 f1 M' g) j; Ocopying build/lib.linux-x86_64-2.7/grub/LiloConf.py -> /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub
4 x5 C- d+ U! w( L6 acopying build/lib.linux-x86_64-2.7/grub/__init__.py -> /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub+ q+ u( `' G; i3 X; s
copying build/lib.linux-x86_64-2.7/fsimage.so -> /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages" K4 I B( d7 r/ M- O
byte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/ExtLinuxConf.py to ExtLinuxConf.pyc
% S0 v9 X& o5 m) H* Qbyte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/GrubConf.py to GrubConf.pyc
- Y3 _: [, C, l% k4 [5 i8 Bbyte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/LiloConf.py to LiloConf.pyc. X( c# ]( s$ b# K6 R4 ?' s
byte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/__init__.py to __init__.pyc+ k) _: J. v( }. e8 }
running install_scripts
, t" f; S; V$ C) ccopying build/scripts-2.7/pygrub -> /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib/xen/bin. h, @! _9 Z* f- a* g5 D+ o! S
changing mode of /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib/xen/bin/pygrub to 7553 f- J2 I. L! m$ Z7 k
running install_egg_info/ I+ f# v( ]& b) x8 v; J
Writing /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/pygrub-0.3-py2.7.egg-info) Q/ }7 j9 ~3 e, w
writing list of installed files to 'build/installed_files.txt'8 F6 B: }) s8 B+ L1 }
set -e; if [ /usr/local/bin != /usr/local/lib/xen/bin -a \- O5 n; C% q& A6 d! k4 g) r
"`readlink -f /usr/src/xen-RELEASE-4.10.0/dist/install//usr/local/bin`" != \
4 E( X* U6 G# [0 {# v1 h' t "`readlink -f /usr/local/lib/xen/bin`" ]; then \1 d! ^+ j y% j3 \( y: N
ln -sf /usr/local/lib/xen/bin/pygrub /usr/src/xen-RELEASE-4.10.0/dist/install//usr/local/bin; \( f! ~ s" ^/ H3 ~; Q7 F
fi
6 q1 n! X& h I) O8 V( ?4 L; imake[4]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools/pygrub'
1 c* |3 ~8 L$ ?% }make[3]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools'0 |0 p% x+ K# X
make[2]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools'
7 v. V6 C0 W) a/ `* p( a" f+ h$ zmake[1]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools'" x V+ X6 F7 {6 [' Z
* A; W7 H. `" c3 I8 [9 W8 C5 R2 W6 e, A( h- q3 s
9 v4 p% J+ C1 `$ N4 h0 S
make install0 b, c% b- a9 ]1 h( v" ^/ q! c0 O$ E
8 c# _9 g' [1 E1 I# ~$ e
做软连接
; a" A1 {/ e9 K4 ]' n6 C7 G# J# ?/ y" I ?
ln -s /usr/local/lib/libxlutil.so.4.10 /usr/lib/libxlutil.so.4.10& x) y# B# m7 }0 ]) Q
ln -s /usr/local/lib/libxenlight.so.4.10 /usr/lib/libxenlight.so.4.10
+ O, m! W' e: e; H, K/ T3 C* q或者使用ld.so.conf文件
8 R. j8 V1 M) E" c0 P( a5 }echo "/usr/local/lib/" >>/etc/ld.so.conf
$ [' g/ v' Z0 ?9 ^$ X- @5 j9 ?4 p* I
2 i4 \# b4 ~& M6 ^1 N ldconfig -v* M @; i) c% n; k& p0 m' d
0 [6 ^. I! A5 S o 启动:5 T2 F3 f" @ M5 H6 d3 K
/etc/init.d/xencommons start
( L6 C! h+ K! }9 H: [% P4 \ /etc/init.d/xendomains start' ?" q" @7 [3 O# [' ^# ]3 x
/etc/init.d/xen-watchdog start' L1 c; ]. q8 L1 d( T2 \2 P+ M
/etc/init.d/xendriverdomain start
; B d3 `; Z; N% Q; x2 n/ i
4 J7 h) y. s/ J配置内核:" j, x2 R% W( h; X% T! ~% ]4 N
- ~( c6 N1 j2 N6 j[root@localhost lib]# awk '/menuentry/ && /class/ {count++; print count-1"****"$0 }' /etc/default/grub | grep -i "Xen"
4 K) q" Q9 m* F: y- E5 H[root@localhost lib]# sed -i 's/GRUB_DEFAULT=[0-9]/GRUB_DEFAULT=3/' /etc/default/grub
4 q D- H% S5 u+ Y' Y( E9 p( q1 y2 U$ }! H8 I0 e. {; [5 h
" U' p2 U6 E' J% E- Y
awk '/menuentry/ && /class/ {count++; print count-1"****"$0 }' /boot/grub/grub.cfg | grep -i "Xen"& ]' L0 ?/ E4 E
awk '/menuentry/ && /class/ {count++; print count-1"****"$0 }' /etc/default/grub | grep -i "Xen"7 e6 \& P' }# r+ j* M# E9 I
sed -i 's/GRUB_DEFAULT=[0-9]/GRUB_DEFAULT=3/' /etc/default/grub
+ M3 K9 p, S' S b% r# d; ~" z9 V
" T5 a7 L( x$ Z[root@localhost lib]# grub2-mkconfig -o /boot/grub2/grub.cfg
5 s8 w9 D. `* s: U% o( E" y {Generating grub configuration file ...: w5 A' h0 [1 z) X& j
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
. r8 `$ Z' c2 G5 ], M$ D% H" E6 aFound initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img
; q9 v/ r$ I$ G' M7 g/ iFound linux image: /boot/vmlinuz-0-rescue-eb52b5b2e43a4c5d974045b5c0680969, V9 C$ l6 J: t8 r7 ~/ r
Found initrd image: /boot/initramfs-0-rescue-eb52b5b2e43a4c5d974045b5c0680969.img
/ u* ?1 R% o# }# F3 X! M5 M: Vdone# P% p2 V! a) e3 O
9 Y/ z" @# b0 L
( b9 J/ w/ \& @* Q- n
+ Q1 H$ U) m! M D/ X }% |0 a
, t: Y& o9 A2 C" o0 G3 X2.下载编译 内核
# T8 L4 b- k2 z; w, u! ^
# B! [( k; v: y/ I. W% I
' H: `$ T6 l) Syum install bc -y
& q, [7 m) E7 s! y& u4 t: T$ r) G0 R( h+ O
7 P- k' R1 L8 P5 J) e1 m6 N j
1 G3 p f6 M1 \6 q1 Khttps://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/4 k1 [+ L8 j1 Q/ i' ~2 a O
9 G+ X1 Y d( \ h8 w+ Q \wget https://mirrors.edge.kernel.org/ ... inux-3.18.98.tar.gz --no-check-certificate
- L3 Q7 l: e6 l' Y
4 ^: p8 ]% o1 V6 Q$ S# w, }, B: \; a4 V8 \' T# x, @" m
tar -zxvf linux-3.18.98.tar.gz
- j6 n4 [3 b* Y/ v% [ cd linux-3.18.98( f$ `% _, S! \2 q- A8 w
. B" B- i4 D8 j% Z- }1 `" }
$ o! t2 C9 K/ B( W[root@localhost linux-3.18.98]# make menuconfig
: ~- A- N; R# p, W, f ?( s% I! o$ ^" ~ x* I; B* N/ ]$ B/ M
' w9 n6 a y. ]; x
Xen memory balloon driver x x
$ I7 ]0 S0 n8 c1 m/ r( |) D0 r) d' \ x x Dynamically self-balloon kernel memory to target x x
( V- D0 T/ ?( E$ F( N7 ] x x [ ] Memory hotplug support for Xen balloon driver x x
8 P) O& r, @! u% b7 Y2 M, O x x Scrub pages before returning them to system x x
; X9 j" z! t7 K* {7 `- I v x x <*> Xen /dev/xen/evtchn device x x
3 x: G2 s3 O! p. J+ t$ D x x Backend driver support x x
: P% W3 o3 M! t% }! F" x/ c' g0 {2 Y& R x x <*> Xen filesystem x x : P5 l9 }) h+ f" ^
x x Create compatibility mount point /proc/xen x x 6 d" L" z x# f0 l* K
x x Create xen entries under /sys/hypervisor x x " Z; Z& [2 C0 h' B8 }
x x <M> userspace grant access device driver x x
% o7 F+ C: j( v5 E, R x x <M> User-space grant reference allocator driver x x $ x3 N! F) h( X# M
x x <M> Xen PCI-device backend driver x x 7 R" F. l! L3 I) s9 c4 `
x x <M> XEN SCSI backend driver x x ) N3 l7 z8 y. L _
x x <M> Xen ACPI processor x x + n# `) j1 C8 n
x x Xen platform mcelog x x
% Y# n# C' A- w! g" z! g x x
, B9 s. d) w" V1 I
) @) n- G& X/ I! m: w9 N8 k$ c9 V/ t4 W! q0 I
vim .config
3 K! X7 W* {4 x3 I% k
( I) B( C7 q, q! e2 T #修改如下参数
L+ {5 @& o2 z7 g& H CONFIG_X86_IO_APIC=y
/ ^9 w a1 b+ i# s Q+ P, ` CONFIG_ACPI=y
) r+ T% c% A m2 X CONFIG_ACPI_PROCFS=y (optional)8 \- e+ r; T. \8 n/ I2 e
CONFIG_XEN_DOM0=y) b: |& ]4 Z# s4 i! K
CONFIG_PCI_XEN=y
* v9 Y0 p; L( { j CONFIG_XEN_DEV_EVTCHN=y
- R0 N3 G3 d6 N% @6 ^6 B CONFIG_XENFS=y1 g" w4 J1 C3 q3 W8 F
CONFIG_XEN_COMPAT_XENFS=y
- h" x6 }( E% @+ o4 X) a* i CONFIG_XEN_SYS_HYPERVISOR=y
2 p2 c! j3 Z! Y$ E0 z S- Q CONFIG_XEN_GNTDEV=y( d7 O7 z" Y+ f' Y' q
CONFIG_XEN_BACKEND=y/ p' R. ]: ^, O
CONFIG_XEN_NETDEV_BACKEND=m+ {3 G5 R+ n1 d! k
CONFIG_XEN_BLKDEV_BACKEND=m
- B( D: a% A) G% E3 G CONFIG_XEN_PCIDEV_BACKEND=m- t7 ^2 J# U% _, B5 u/ W: b
CONFIG_XEN_BALLOON=y! t' ^6 M0 O: \
CONFIG_XEN_SCRUB_PAGES=y
/ `: j$ W8 R" `/ N" x' P CONFIG_EFIVAR_FS=m3 X; H3 c9 I5 J) F8 W4 m! ~
: i2 ]! i$ p- ?
- f9 a v5 N4 ^ Y m) J, j& e
make & Z% m8 z- p6 y9 g
make modules_install ' W6 _% e; w* o
make install5 z$ E1 l/ t1 i. M. Z& P7 t6 Q
- d0 }& S! I7 A1 N3 y+ x! W
配置 GRUB
) e& ]% ?1 F2 P0 r( W4 v4 q: n3 G
! P1 e8 a4 X4 y% H9 \4 e6 F#查看grub2.cfg相关配置
9 Z! u2 [) h0 o9 G, \# bcat /etc/grub2.cfg, k* `6 l& @9 P2 o3 s: d. l: [' y
找到这段:5 `9 M) R& U# l) I/ ^3 p% @
5 X! O5 J5 H3 x& k( k6 {( smenuentry 'CentOS Linux (3.18.98) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-c9f0f90b-19ee-4157-ad48-bbf3d5adc91c' {
* ?) ?0 D9 w/ \3 | load_video4 j) q% {2 J6 K3 M
set gfxpayload=keep
9 C) q. S8 O/ s9 \- M) q# J0 Z2 _ insmod gzio
9 C2 ?6 N8 w4 r& h insmod part_msdos: h3 V4 e% Q5 B: s6 d
insmod xfs
# d5 h: f3 C3 I! y4 K- ?2 z% b set root='hd0,msdos1'
W5 e; o5 ~! G' y& @ if [ x$feature_platform_search_hint = xy ]; then
" x, h& w# R: Y% @# n, a search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 82e6a5c0-2357-43a0-9d1e-755fadc55d21
% N) B1 j; ^) x, e5 h- k else6 h6 R6 P& ?( y' s2 R8 b, D
search --no-floppy --fs-uuid --set=root 82e6a5c0-2357-43a0-9d1e-755fadc55d21
m0 S* K F9 k |! `; ?( @* w fi
7 [- C2 r9 e5 I4 E' Y linux16 /vmlinuz-3.18.98 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root LANG=en_US.UTF-84 z/ v% q" k2 H( L9 F3 |5 H3 M, ?
initrd16 /initramfs-3.18.98.img
3 t* E' J! `! Y9 `}' P6 w" o4 }; S2 x0 q6 h" M; r
+ K9 _2 U* z5 h [+ l! q4 i7 w, I- T B3 U7 \2 L4 C+ A- b
2 D! F$ j) W6 T e/ u
0 a- e. e3 _( `
9 N4 w) l& R {% d#静态文件系统信息,定义了存储设备和分区整合到整个系统的方式3 L$ _: x, E7 a
cat /etc/fstab
- ~' H7 s2 G) J R. R1 w5 i' q+ Q. a$ t+ E1 V3 B5 R
#复制grub2.cfg里第一个引导配置到下面的文件,添加一行 multiboot /xen.gz,linux16、initrd16修改为module7 R- S6 j' [! k0 M; f* d
8 N" F: H) X+ ~
4 R: B4 m ]' J
0 ?* Q6 X% {) R4 r V0 F
; {! N- @ _' n X6 {0 R: ~1 a$ { a' ?2 v
#重新生成菜单" V* K; O: F$ U% K
grub2-mkconfig -o /etc/grub2.cfg
) ?/ l! C& v) j d. [5 u) L: L* W; `" T, r$ B* m9 L
$ {7 e" R: y0 v# @2 b: w2 w6 c7 b7 h2 h1 S
grub2-mkconfig -o /boot/grub2/grub.cfg % p8 a5 L" Q3 ?) z8 {2 j' X: e, [: [
Generating grub configuration file .../ y+ ?1 q0 x$ y
Found linux image: /boot/vmlinuz-3.18.98
! L/ c/ N! w- a6 k; L5 rFound initrd image: /boot/initramfs-3.18.98.img
7 _5 d* D4 p7 C2 M4 `Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64. E, p( R: m* F5 D7 O
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img
n& O- P* w6 `Found linux image: /boot/vmlinuz-0-rescue-eb52b5b2e43a4c5d974045b5c0680969
! y$ W) r2 S2 o/ o) FFound initrd image: /boot/initramfs-0-rescue-eb52b5b2e43a4c5d974045b5c0680969.img: v1 c1 h6 \, W C/ G; Y! u! l$ ]6 p
done' {+ }4 v3 T B1 W; B8 t7 c8 E
3 n' G) `2 B" t& q p6 O
两个执行都可以:
- Q* H8 }( ^- f7 K* O I: p0 e( s0 p8 I5 T
grub2-mkconfig -o /etc/grub2.cfg
/ X0 C7 U5 J' s- i4 z! QGenerating grub configuration file ...7 d" U2 R+ { o
Found linux image: /boot/vmlinuz-3.18.98; R/ _* V! ~" i3 P2 G' A
Found initrd image: /boot/initramfs-3.18.98.img
& L( M6 f% j( |" x" vFound linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64 M# C1 ~* [ E
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img
/ M: g6 K. v* y }- U5 j0 cFound linux image: /boot/vmlinuz-0-rescue-eb52b5b2e43a4c5d974045b5c0680969$ E$ h* u F0 S& o
Found initrd image: /boot/initramfs-0-rescue-eb52b5b2e43a4c5d974045b5c0680969.img
' ^6 S8 [; U. k/ w, _0 H; K1 Ddone: o+ _, l* A( ?& ]* s
3 W4 ?/ r( O* |- e/ n2 y& l
" ?6 l2 ^! N8 q# G3 Z
9 a) h7 g( t: B# i; Z8 d2 B$ B
vi /boot/grub/grub.conf
4 ^$ `8 y3 w4 x2 O+ P
; T0 M/ e1 j9 E; `# @% E6 u- X# B# b2 ?title Cent OS Linux (3.1.0-rc4)
/ j5 D8 M$ G7 T5 a% S& t! N' ^ root (hd0,5) % W) \! c# J3 ?) z
kernel /boot/xen-4.1.2.gz //指定xen
* [ e& w p$ v8 [8 Y# \ module /boot/vmlinuz-3.1.0-rc4 ro root=UU rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=zh_CN.UTF-8 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
* R6 E, X: D/ C: E8 V, B4 ? module /boot/initramfs-3.1.0-rc4.img //新内核模块
% k" F. x% A$ q! y8 r( e% d9 [ 9 Z" j3 I, d2 ]+ v
3.重启机器 ; y$ ?: P9 {/ u. Q" c5 ~
重启之后共有三个 系统 ,分别是:装有xen的linux系统、没有装xen但是使用的是新内核的linux系统、原始linux系统。
* r: }; ~+ z3 i, K进入装有xen的linux系统,启动服务
3 I7 q7 n t s$ i: Z7 m$ p- Nservice xen com mons start //如果报错:NO such file or directory,手动加载模块即可,modprobe xen-evtchn 1 Z( t0 {+ H( @( U+ s: g3 Z
service xend start& P0 _1 ~, f# f* P/ a
2 D, s- h, J( Z, l% h& A
+ R7 V2 }: S& k
! K6 \1 d: A- R; I- w' o: z
" S4 C2 j. N2 ]9 r
* i2 w/ E8 Y' `: t/ y+ n* ]( q, J$ F I# D& H1 X
$ B3 H% z6 @, U* ? z
2 U, j# z; b6 e
( ]/ U3 j5 S1 f6 \+ \7 h- p+ B
3 Q8 N1 Y R4 x+ D1 k
" j$ R; V5 a8 K# W9 J) z- i( l
3 S2 o8 {$ p. G* z6 c' S$ f0 N0 ~( U
0 `- |' o8 S' {3 h& D
$ \+ e! V6 ` h7 I6 T! i$ {8 }) {
( c; b- m: E, a5 ^) p" u& U7 Q7 W0 D$ n4 g# R0 S: @# @
. I- e: D: N. ?/ d ^* o2 R9 W' D& _: K: C
|
|