|
|
在centos7.2系统上安装xen服务
0 h3 D3 r$ J, w3 p8 D8 _0 x( f, Y: d; ]" s4 j3 G, c" G* r
+ A" A& a/ ^2 J/ P6 B/ o8 d6 I) {- p1 @. i `
[root@localhost ~]# cat /etc/centos-release+ C- L8 M9 W% S" R% E3 s; o
CentOS Linux release 7.2.1511 (Core) / K' q& N, b/ _8 G h
* r9 ] _3 L6 ?6 M4 w" P/ H/ }
调整selinux ; U6 o. W- X$ p9 @8 d
2 z4 x2 W+ l& E1 r; q" G1 bSELINUX=disabled; i% j* [! m8 Y# Z, M" Y
- o8 l g/ c" U" F1 R, Q9 I6 b. X( M8 g( x/ s3 t3 ?6 K# q
! A5 \3 f4 X/ w3 \+ Y" ?首先配置yum源:) \6 |) S q: N& o; g& y; Q' C
& l3 ?+ M' d) J9 p( I5 e. s" D c8 m; Y; b+ n
[base]$ E& R; a, F4 V2 u
name=CentOS-$releasever - Base
I% m B( \) m: q( ^#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
, r# M9 w( E; m0 s; j% R9 j' Zbaseurl=https://mirrors.aliyun.com/centos-vault/7.2.1511/os/x86_64/3 l) i: w1 s" V5 J
gpgcheck=1
8 l& n% C4 V5 dgpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
1 A4 o3 t d' H- a" B
; @! B; J( S% b ~" n& G#released updates
/ {5 {- B9 K2 t" x! W9 _[updates]
0 c! a R8 z1 o" E1 `% N2 `. y- l$ `' Mname=CentOS-$releasever - Updates/ V! z5 _1 }* t( k& E- v; e
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
7 k* n6 i. _5 g7 [$ d$ ~8 Hbaseurl=https://mirrors.aliyun.com/centos-vault/7.2.1511/updates/x86_64/# b: S) D$ s* o; w+ I' V; \# b
gpgcheck=1
f2 n. `5 R% r6 F% ygpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
; a1 I& ` C4 q, W. P9 [' b( k
; c# K3 f* w+ K' E8 k; s2 z4 L3 y#additional packages that may be useful! m, a; M q( ^* U# j
) ]9 ]# T S# ` c2 c8 B, J#additional packages that extend functionality of existing packages" q B+ t8 Y% ~, g6 J! H
[centosplus]# N# Y/ J3 D8 p$ k( |
name=CentOS-$releasever - Plus* J% Y- ~7 K! N6 d1 U* y2 W! L
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
' X( E. H4 F( _# b) @; Fbaseurl=https://mirrors.aliyun.com/centos-vault/7.2.1511/centosplus/x86_64/6 N. [. o% r5 z4 s
gpgcheck=1% S2 |! L) `% o5 d0 v: g8 O* E4 ]
enabled=0" O4 _8 ~" l8 I# Q+ w
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-76 G2 ~3 k7 s8 p0 S- \
4 k0 H2 i& e1 z5 u2 W
9 ^" E) f$ D' n安装基础软件. R4 t) e# ?0 P, x4 G
yum install -y vim
U! ~. l, |" y. [yum install lrzsz -y
2 J9 G+ o1 H- V$ @; `' U6 p+ C) F3 J8 f
* S; ?( I0 S! q+ u' C& \7 |5 Y; b8 t$ s
" b5 W! r0 L& J/ n+ s1.下载xen的 源代码2 |; S# t& k' \
https://xenproject.org/downloads ... roject-4-10-series/- t& M; v. Q9 U/ p) c8 S) t$ k
+ Z9 U b6 K- X4 I8 a ,解压
7 p$ b& [) G- m1 M0 Q! i& Q$ F, f7 c! Q& O9 F% L+ a' c
/ y5 D1 u: o+ ?& \
' O+ `6 E3 B ~* L' t/ o5 I" Z2 I( H1 G" r4 @" v# x: N- ^$ p! c
tar -zxvf xen-4.10.0.tar.gz! L6 [' C5 ]8 d% k
unzip xen-RELEASE-4.10.0.zip
2 Z. N1 T6 {4 n* k# |+ m4 c* U0 |% T" q5 P5 \ G3 N& T9 G: K- L
0 S) t$ H0 ` T; T0 lcd xen-RELEASE-4.10.0; D" G, c. n7 X& l5 i. @) t9 z2 i% ^
: c: z- a, t1 f0 L#make help 8 z6 Q* l6 m+ Z+ j& x8 K* V7 W ^4 Q: T" [
2 u6 g6 {7 Y- b& O
3 m. s7 h1 w1 y/ o0 D6 m- P% U) r8 Z. v
& ~% Y0 Y1 X8 o
+ I. V) l% F. j$ l o7 z8 Y7 P[url=]dev86-0.16.21-2.el7.x86_6 ...[/url]
/ k% P) f+ j' Q, r* v安装软件: E/ E4 L. f( e
: |: J0 B2 M- P1 N! x# a2 |yum install dev86-0.16.21-2.el7.x86_64.rpm -y , Q8 ~ Y, f0 [3 D/ E
& x. i9 P9 c- i7 x' n/ l
Dependencies Resolved
* F: {9 J m# C
* r U0 q7 T" x) ]2 N( b# i9 s) n==============================================================================================================================================================
?$ k0 g# B# P2 q8 ~ Package Arch Version Repository Size
: {- m7 K/ Y: Y* U==============================================================================================================================================================
; j/ S$ x7 \3 _/ L/ z+ K2 TInstalling:
7 `! Q% I, I D, S+ P: b5 k& Y" G6 Y dev86 x86_64 0.16.21-2.el7 /dev86-0.16.21-2.el7.x86_64 991 k6 l/ Z( l7 j# j% q: U
+ O7 \! w# e4 C! ~8 ~0 W6 d% K
, j# x. C! S5 c7 `
Installing : dev86-0.16.21-2.el7.x86_64 1/1 * ?" H; r! v* \& u5 n
Verifying : dev86-0.16.21-2.el7.x86_64 1/1
/ {9 U5 T% r% T7 ]
0 A0 @ Q5 ~. X7 s0 q& ]6 n7 mInstalled:
1 i( r( j9 v4 K0 J, v$ M$ g/ W dev86.x86_64 0:0.16.21-2.el7
2 _) R. L0 L# y' R+ q" u1 W2 z) \8 `1 A+ D
Complete!
0 ^1 a/ T w% C& _! O
5 U2 i x7 J) ] V$ L
2 B' F$ z- \. H: K6 J+ c##yum install lzma1 g \/ M; n3 D* j- r* P! h
Loaded plugins: fastestmirror
2 g$ g9 Y, W0 @* I' hLoading mirror speeds from cached hostfile
# N$ z# t* [0 a4 I+ |) c5 L3 MResolving Dependencies
9 e G1 h5 a" [% f g% @--> Running transaction check* n) D4 u# C1 Q7 |2 a# m( G9 y: ~
---> Package xz-lzma-compat.x86_64 0:5.1.2-12alpha.el7 will be installed
4 w, ^3 x( v) i( W! H, b--> Finished Dependency Resolution
, L: m V; [: l4 b8 L8 R; K3 F6 w$ }* j" Z
Dependencies Resolved5 z e; g7 P. v& K( @( M2 Q$ ]/ V
5 J7 V. |- I6 }* @8 m
==============================================================================================================================================================! w* P( j8 ?6 W( l+ h4 N. j
Package Arch Version Repository Size( @' ]9 I) a# s$ q1 g+ O9 H) g' k# e
==============================================================================================================================================================
- w {4 u3 a4 b0 M; ~Installing:8 {6 m( Q9 q5 m# U4 J9 @' G
xz-lzma-compat x86_64 5.1.2-12alpha.el7 base 18 k [/ S/ }* [6 A! y& N" O5 e
t/ J% G9 \2 w* n. T) G/ o& a! L
Transaction Summary
9 S- R# ~& Z( t$ v8 A! R5 R, c( V==============================================================================================================================================================0 M' Y0 ~) d& v. ?8 Q; w8 O
Install 1 Package0 M v6 ?& [5 y# [5 Q( X6 L
5 q& p( G% ^: }8 m. f7 Q6 g: Q$ K+ K2 q
2 i H6 c5 ] ~5 E
Running transaction
6 P8 K/ M3 w. a+ s Z Installing : xz-lzma-compat-5.1.2-12alpha.el7.x86_64 1/1 : Q1 }; l+ e8 Z
Verifying : xz-lzma-compat-5.1.2-12alpha.el7.x86_64 1/1
3 O# `6 q* g! S* w# q% n! ~3 c$ O r, z7 y0 i( O; }8 F" Y+ O% y
Installed:
9 b, Z) O3 k- i8 b- W H; j, b: c xz-lzma-compat.x86_64 0:5.1.2-12alpha.el7 3 Y: G+ L+ N) h! M3 i/ O1 @& D
+ x- w x' z9 a) `, {% T
Complete!8 O$ j* |$ n2 G8 _$ W
! Y4 `/ x$ M! B. o- X; t( C/ i+ Q0 {2 ^; ?0 V7 V. f( \4 G R
##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 patch1 e v& W5 J, M
+ n" j2 F6 Y. e @; L% L$ x1 Tyum 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
1 `. K$ N! }( k" Q" @" X+ V. d 7 R/ e% x( W4 t& \9 \# U
#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 6 d9 ^& T0 I/ _0 Q( L' B$ M% U
, H9 K9 |4 n8 V# K9 f
#yum groupinstall "Development Tools" -y3 Y0 x$ x* b3 M; D& s
: V, H( r* |5 R
注:在安装的时候会出现一些错误,原因是一些工具软件没有安装,提示什么没有,使用yum install dev86(等等)安装就可以了。
( I) K4 z8 x! G& F! i/ V X0 f3 N : q2 U% a( s3 H, O) Z
#make dist-xen dist-tools, A6 w* P3 n8 q. x
第二种:
: s) t' ~- t+ g9 |! e#make dist/ s! O7 @# l; A9 }+ x, U" i
6 _' Q$ g; I8 H, B z" k
t0 C) ^5 Y- R; L# A5 i2 xrunning install
# ]) N0 ]6 ], a& O% B! O+ k Prunning build
3 h( y2 j# a3 X) f7 h( p$ |- ~/ k0 V- R( qrunning build_py; h( a5 e' \$ x
running build_ext
2 e5 T; @7 l X6 T4 B# i8 Jrunning build_scripts
3 }: D2 V" Z5 d4 m& A0 Lrunning install_lib
/ J: S, D3 D& _# Qcreating /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub# F* z9 [ C- M9 J& }
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: y/ Q( {9 O: A( N2 }3 T9 n9 W! D$ e
copying 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
9 K- B+ x' Y' h9 Xcopying 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
! E& y6 y3 w# O1 k6 jcopying 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/ m. d3 i& p- M& q6 J
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! [! l$ Z- J3 ~/ V6 f
byte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/ExtLinuxConf.py to ExtLinuxConf.pyc( ^1 `! n5 w5 r2 Z
byte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/GrubConf.py to GrubConf.pyc
% q! Q% h1 a. g4 y0 t/ `8 h' Pbyte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/LiloConf.py to LiloConf.pyc
3 w; I3 g8 S- g) cbyte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/__init__.py to __init__.pyc p4 t/ w8 B/ D- B! o# A
running install_scripts
9 S: _6 a! a0 u* {) ecopying build/scripts-2.7/pygrub -> /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib/xen/bin
6 A% a w$ `2 m! N- k3 ~: rchanging mode of /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib/xen/bin/pygrub to 755
G9 h) g9 U, s6 @; E3 n/ srunning install_egg_info
$ x7 T4 o9 I( V- G* \9 eWriting /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/pygrub-0.3-py2.7.egg-info
4 ~& t% A( @; [* Gwriting list of installed files to 'build/installed_files.txt') ^0 t1 q2 g5 x% a) L
set -e; if [ /usr/local/bin != /usr/local/lib/xen/bin -a \
/ {; q1 a. s3 Y) H5 k7 Z @2 y "`readlink -f /usr/src/xen-RELEASE-4.10.0/dist/install//usr/local/bin`" != \6 V$ T4 a6 y; V- f. C" k" M5 J' i
"`readlink -f /usr/local/lib/xen/bin`" ]; then \* ^, m5 X3 p2 C: e2 c7 H
ln -sf /usr/local/lib/xen/bin/pygrub /usr/src/xen-RELEASE-4.10.0/dist/install//usr/local/bin; \7 I# M; D5 f( S7 L8 h
fi: ?4 U9 N% `- Y) M6 ]' ~7 ]: X
make[4]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools/pygrub'8 m( J2 u, X1 `" y( [& c
make[3]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools'
* B6 c4 \7 S1 o: Mmake[2]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools'' `7 S$ }! B8 w# E0 K$ X* x
make[1]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools', p6 q) V1 d, t$ S6 Q$ w5 X& J& }! w
# e% m8 c; H/ E. h& L" q3 N( y. i, a; [0 L0 u
2 j! N& U) y! L9 C7 d
make install
* L9 ?' @5 y1 Q/ f; U, i( M: K
8 M! H$ X+ {+ p) u做软连接
2 s; f3 X) U# P5 o, ~
5 J" e3 V( B8 \) i0 Rln -s /usr/local/lib/libxlutil.so.4.10 /usr/lib/libxlutil.so.4.103 p& v7 I" }- O
ln -s /usr/local/lib/libxenlight.so.4.10 /usr/lib/libxenlight.so.4.10 @8 n# P' H t9 c+ Y
或者使用ld.so.conf文件
- Z; M: ]) f& c6 Kecho "/usr/local/lib/" >>/etc/ld.so.conf% ]8 P1 b Z& e6 u" c* D
e2 u) u/ w; _$ Q/ i$ H, L
2 H4 [2 X9 F8 d( Q/ v* ]# ~7 ] ldconfig -v( z. b/ y6 c0 W6 D# x( `
3 J7 V% ]9 u2 |4 M 启动:
/ x+ z$ \1 K6 k1 ~% M' f/etc/init.d/xencommons start
$ j( v# a8 c& a6 W6 W# q6 S8 q /etc/init.d/xendomains start8 q* H$ C# p9 L0 t; t- C! \+ O
/etc/init.d/xen-watchdog start9 Z; v1 B! v9 A. H: w' H
/etc/init.d/xendriverdomain start8 j! c& }! F- s' P9 U4 |7 Y1 s
3 y$ y' z0 ?' z4 @# F7 k' N+ a. D配置内核:8 g/ o1 i1 ~+ B# Q+ A; B
6 s) J3 e) a/ L. z6 B K c; C[root@localhost lib]# awk '/menuentry/ && /class/ {count++; print count-1"****"$0 }' /etc/default/grub | grep -i "Xen"8 i) M; f3 I `: ]& A2 T+ T
[root@localhost lib]# sed -i 's/GRUB_DEFAULT=[0-9]/GRUB_DEFAULT=3/' /etc/default/grub
, b# n# u5 S! x& U1 r6 B- ~4 [
% J) j5 r" x; j @- t
$ m. A& t! U' y+ A- H awk '/menuentry/ && /class/ {count++; print count-1"****"$0 }' /boot/grub/grub.cfg | grep -i "Xen"+ |+ ^+ t# ^% F0 {
awk '/menuentry/ && /class/ {count++; print count-1"****"$0 }' /etc/default/grub | grep -i "Xen"% C# B7 g. e5 b* K# I7 l
sed -i 's/GRUB_DEFAULT=[0-9]/GRUB_DEFAULT=3/' /etc/default/grub$ D6 M, Z g' Y; h; E
+ r: L! i5 X! K[root@localhost lib]# grub2-mkconfig -o /boot/grub2/grub.cfg
; l8 D' e" b: n6 ?1 Y- {6 l* o$ OGenerating grub configuration file ...+ Q$ r5 U p v" o2 \+ V0 {; {
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
5 S# c( a& f9 M+ j% h. P h, ]$ {Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img3 U9 b) r7 k9 Y2 s: _4 w
Found linux image: /boot/vmlinuz-0-rescue-eb52b5b2e43a4c5d974045b5c0680969
3 j( N0 U" I5 k& A/ cFound initrd image: /boot/initramfs-0-rescue-eb52b5b2e43a4c5d974045b5c0680969.img) R! y6 ~1 Y; x! c4 E
done7 k. O+ }0 w3 [* S+ B
! V3 l- B" g" C4 H8 w. k# l8 Y+ c$ D* z7 O0 Z' w( v- i
! o: Y7 h; ~9 G
$ u' D& P: P+ H) ^
2.下载编译 内核 - A. Z( }$ e, Z2 w+ T
3 i3 v+ a6 U5 K
6 p, G Y; B3 Vyum install bc -y . {3 t$ }1 X: h. ^$ V `% S
8 n2 W) o$ w# t+ ]
+ j, ?4 x `' n/ n* C$ A6 z5 W; y4 u% M- u9 p! R, t
https://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/
) ?3 e) @1 E! M! A1 l6 b" |$ F
! L @- a# o9 s+ ~2 |wget https://mirrors.edge.kernel.org/ ... inux-3.18.98.tar.gz --no-check-certificate: I n! R( ?- H* J& _
z9 ~' ~6 c: f7 b0 @
" c4 W+ k# F7 o1 Y% ]& o$ e tar -zxvf linux-3.18.98.tar.gz
3 e9 z' S1 K6 r: R6 j cd linux-3.18.98+ t8 _* ~0 O0 r* [. D1 p
; w0 c; c; b1 u% q: \9 d' ^$ n" h! W: U6 V, a
[root@localhost linux-3.18.98]# make menuconfig3 W/ F: S% j+ f# B2 x/ H8 O4 O
q7 C3 }9 {% z/ z/ ?7 L! D; ^& I# |$ M
Xen memory balloon driver x x
; o' k! }0 [3 Y+ m! q x x Dynamically self-balloon kernel memory to target x x ( `/ ?4 Z+ X/ X# i2 s& E$ A
x x [ ] Memory hotplug support for Xen balloon driver x x # S, M& f7 r# {4 \. M0 Z
x x Scrub pages before returning them to system x x
; M- B* J( B) C x x <*> Xen /dev/xen/evtchn device x x
0 L' T- D5 w7 S% V* \# Z0 B7 D x x Backend driver support x x
& _1 K1 B* w, {; y7 H7 q2 l x x <*> Xen filesystem x x " j. Z: q* K; _, P- o
x x Create compatibility mount point /proc/xen x x
5 I6 \8 Q% Q8 F- W3 _ x x Create xen entries under /sys/hypervisor x x # R9 l, U+ L% E5 \) i
x x <M> userspace grant access device driver x x
& z1 Z4 {& }' u5 s7 A" r: h. X" P x x <M> User-space grant reference allocator driver x x 8 q% T9 z& Z9 `/ o- e5 \- m
x x <M> Xen PCI-device backend driver x x 4 }1 S: r- i$ K# U0 [
x x <M> XEN SCSI backend driver x x
: L1 T# l! i1 Q x x <M> Xen ACPI processor x x + I4 |! S0 [4 ]8 i, f0 n
x x Xen platform mcelog x x & ~; E* e) x. c* G* W
x x
# L1 M P5 L- Z; r8 T: N' n( j0 R& p
3 a J9 o) A9 f8 |- m/ Z
vim .config( O& A" I; J# j5 i8 c$ @
, f9 {" R! X# k( S# P: m5 F4 g% ~ #修改如下参数
# d' W! Q3 ^* B0 b CONFIG_X86_IO_APIC=y
- x# r. L5 U9 c u2 S1 G7 V CONFIG_ACPI=y
' U3 i1 f" q) P CONFIG_ACPI_PROCFS=y (optional)
7 K9 c4 T% u a0 z/ M CONFIG_XEN_DOM0=y) [2 m: Y9 b2 b# c! f- E
CONFIG_PCI_XEN=y
) P$ t* q) Y' ^9 g4 t; { CONFIG_XEN_DEV_EVTCHN=y4 G+ U( n* B: z2 v
CONFIG_XENFS=y
% S/ @8 b" ^' k3 {4 Y' s3 F7 l CONFIG_XEN_COMPAT_XENFS=y
- |0 K( K7 P5 N" {6 q CONFIG_XEN_SYS_HYPERVISOR=y* i6 k7 t8 {( ?/ ^. }8 L
CONFIG_XEN_GNTDEV=y
+ T3 Z9 O& j) |" s4 j6 C CONFIG_XEN_BACKEND=y$ Q& m0 ^2 J, z( F9 s0 N) u
CONFIG_XEN_NETDEV_BACKEND=m* U4 t8 b4 f( a: ?
CONFIG_XEN_BLKDEV_BACKEND=m
' \7 u$ |8 }5 {" x CONFIG_XEN_PCIDEV_BACKEND=m
1 S; R$ T5 P% k) A CONFIG_XEN_BALLOON=y+ k4 n' I/ @" l$ v5 h$ z& ]
CONFIG_XEN_SCRUB_PAGES=y
) \# i0 a2 e! R- \7 d CONFIG_EFIVAR_FS=m
. D3 f Y( K( V4 [1 X3 I4 b# i
1 k2 K1 r) o$ l( h* e+ n5 o6 C
make
/ f: E: c9 E+ R) A: P9 L" |make modules_install 7 X. X' f' x* X5 x
make install8 j+ o6 W4 w5 ?8 j/ ^0 p! O7 e( z
5 i; b e1 q+ i: E, L
配置 GRUB
! z) R+ ^* B6 x5 s7 A) |0 D! e0 z; T* L& W9 ^5 Z5 W
#查看grub2.cfg相关配置" b1 w9 V* t9 S, W- k/ M7 S
cat /etc/grub2.cfg
/ P$ z- x" a% [找到这段:5 }0 t% Q+ Q5 ^" N/ y) K2 M( X
: b' v# a, A. t" f& ]: D9 Q9 Gmenuentry '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' {, k9 V7 ^5 u/ ~6 \- F: L
load_video# N0 V& S0 G) p$ v6 {, M8 I8 C! H
set gfxpayload=keep
3 V* C1 ]% e4 R# j% @ insmod gzio1 D8 |: G+ W# D2 o* [4 L+ a
insmod part_msdos4 s; M. O3 R% @- h4 H% g3 J) m) L
insmod xfs
) \& e d8 L% v- C set root='hd0,msdos1'
( @9 `, K/ ?6 W if [ x$feature_platform_search_hint = xy ]; then4 P( E* |; B9 G1 I+ ^! _6 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
6 ]* B7 O% w# K9 f else
; W8 ~. v/ V" T search --no-floppy --fs-uuid --set=root 82e6a5c0-2357-43a0-9d1e-755fadc55d21) D* w6 s0 Y( m5 u0 n O" g1 f
fi
, |" r8 t+ k* L linux16 /vmlinuz-3.18.98 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root LANG=en_US.UTF-83 r4 q, B; [, \) W
initrd16 /initramfs-3.18.98.img
& w; Z1 `2 r8 ]3 F! s8 T}& s2 D: W, B* U1 T
. ?, y! t! t, X% h' R$ i9 n
. n, L+ o! q+ z4 l7 a
# R; {; P7 W. \7 [: t3 v$ k0 |- ]" j
/ r9 r; f3 i; N8 ?3 P7 \#静态文件系统信息,定义了存储设备和分区整合到整个系统的方式
: B3 a5 T0 l5 e8 C7 ~/ Hcat /etc/fstab
. [) ~: k2 z+ Q4 o$ C- Y( c. ]2 k5 z) [, J
#复制grub2.cfg里第一个引导配置到下面的文件,添加一行 multiboot /xen.gz,linux16、initrd16修改为module
" x# w$ B! n3 T! |' U0 ~+ l6 T9 o/ u2 @' x, S5 G6 L
3 \% G# Z3 ^2 x' Y2 C6 N
* }) W2 x/ |2 ?8 w8 q3 E" i5 K
! O; F( y% L* g4 d* W
3 ^1 ?. `3 r S& U! N! r( a/ C$ P#重新生成菜单
% W4 T0 L* L& }! e6 d, _" ?' y0 r/ V0 v! |8 ggrub2-mkconfig -o /etc/grub2.cfg7 x; x& G! M" V8 p7 a
" k- {9 W! l7 ^7 O |7 f! D" V7 {8 l% |$ r
# ^' A* [' k+ `' g3 m6 n/ I grub2-mkconfig -o /boot/grub2/grub.cfg
, c/ K# O# X. U/ H' d4 P1 FGenerating grub configuration file ...
$ B+ K1 T) l# R8 \7 Q! E3 P7 e, M7 RFound linux image: /boot/vmlinuz-3.18.98
) E7 V: c; H3 Q- a* zFound initrd image: /boot/initramfs-3.18.98.img
2 {* ^2 ], ^ G+ T+ KFound linux image: /boot/vmlinuz-3.10.0-327.el7.x86_640 q5 Y& g8 n( c4 o2 i; v3 L; p
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img
2 \1 j* G. x/ C0 l* {Found linux image: /boot/vmlinuz-0-rescue-eb52b5b2e43a4c5d974045b5c0680969
4 }! q7 P1 h7 F7 kFound initrd image: /boot/initramfs-0-rescue-eb52b5b2e43a4c5d974045b5c0680969.img$ ]4 U- r/ a4 W8 k) l
done
k( G! I% _2 l" c- _, c$ [
8 x- W$ b$ `# c/ Q两个执行都可以:; k% g. i6 D, y( q
% l% K( K: C& m) n5 T grub2-mkconfig -o /etc/grub2.cfg
; A& B t: @( F8 Z9 K& I2 v( v: ZGenerating grub configuration file ...8 X' _8 y! {3 q) O" S$ y
Found linux image: /boot/vmlinuz-3.18.989 p- B, D# P9 H" y( \
Found initrd image: /boot/initramfs-3.18.98.img8 C7 I0 i( N" r
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64; k- e0 j* _, T. U$ z9 Y; E
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img' k& {( A9 U4 v( V# j1 `
Found linux image: /boot/vmlinuz-0-rescue-eb52b5b2e43a4c5d974045b5c06809691 b! I. \* M" F5 v8 @/ o: C
Found initrd image: /boot/initramfs-0-rescue-eb52b5b2e43a4c5d974045b5c0680969.img s8 q# P# B6 v. _0 ?
done6 s l7 {$ O7 |: I# x
1 k; q, q8 q# W4 B: s% b# f# s0 S
+ J+ I& v2 [9 F( lvi /boot/grub/grub.conf 2 F$ ?2 I; z3 m2 ~2 l/ t2 s
1 U4 {3 s o% ?
title Cent OS Linux (3.1.0-rc4) ! V; y8 w5 H4 q
root (hd0,5)
; j- n% j$ T( K* E% q2 P" d kernel /boot/xen-4.1.2.gz //指定xen ; t- L9 z+ L9 s0 j) t# Y- r: ? {( A
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
4 T# |; \% @; s) F# z/ |: D- t module /boot/initramfs-3.1.0-rc4.img //新内核模块8 W. U5 S7 D* x4 I3 F* T% R
1 `: m/ T& X( X5 B" T k
3.重启机器 / E% k: Q1 a) E. H: D5 w b4 l
重启之后共有三个 系统 ,分别是:装有xen的linux系统、没有装xen但是使用的是新内核的linux系统、原始linux系统。 ) |: T, q7 V+ i3 e2 ?# @. N4 N$ @
进入装有xen的linux系统,启动服务
+ x2 k; n6 ~$ V8 eservice xen com mons start //如果报错:NO such file or directory,手动加载模块即可,modprobe xen-evtchn - H8 Y4 _$ q8 X \+ {
service xend start5 t1 R1 Q# `2 P1 F& k( H9 d' S
" p" l1 U ~( O7 D- g
& P7 D7 {" O! s1 G/ s* F! L" I) Z9 o: x6 l% n5 W
7 f* _& v _4 ^* q+ b: E
* Y/ P+ ~" h) K* L' s
9 a8 K* Z. Y* G7 p
3 I1 v8 r9 C1 Z+ C7 k, t9 x- r! |, z/ Y. H& A: q3 G; j/ }
Y$ a; A( F% [8 i4 n( R7 S* h( F
$ P- A; H9 \ H$ T7 q$ `* }/ y
( ?* S7 A, H0 Q- F& v7 s) c, E7 p/ Q: v8 X% Q6 G5 C
) e6 W8 o& _7 @- s( P3 o, y% A* r7 j+ x( a; S+ }/ T4 a U
+ d U8 `* X2 l$ k) z5 h
6 o2 G6 f( V" }4 H8 h& e8 w5 |6 Y% D0 X' \, E* _1 I5 s
, o/ ]- S! b# Q& w( D
( Z# t! z' v1 C; x0 }, S. U( ?& C |
|