|
|
在centos7.2系统上安装xen服务
9 v/ F, V3 m6 Y! E) ? Y3 p+ u) }8 ]$ d! \" p. r: J
/ h/ ?/ `/ e6 J8 y) m
- |1 [" ?3 y) a9 ?& }7 ^; M' h[root@localhost ~]# cat /etc/centos-release. F \! z( @# E$ Y3 t+ I
CentOS Linux release 7.2.1511 (Core)
6 W8 N& G' n3 r$ E1 E9 I: Z& U* @# {
调整selinux
2 J# K2 D. k; w/ j" C
5 G0 v9 @& t$ r; {. ZSELINUX=disabled
! ~% y8 s; Q% A6 G
8 ? N6 p, h5 R1 Y
9 e1 `& C5 J9 t0 {9 ?) x. h6 T+ x" V! k. Y$ q8 l( R2 s4 f
首先配置yum源:6 L1 ?! I# w9 a) R+ W8 z
# `, y* W( y! W' _3 }' N$ z6 ^! d
/ Y% C* J6 |6 g7 G5 ^1 A[base]
( T) }" ~% l7 w1 l0 |name=CentOS-$releasever - Base
# D: ?1 |4 \4 k! t0 w0 c7 |, N#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
8 _7 o6 p" k# \! y Sbaseurl=https://mirrors.aliyun.com/centos-vault/7.2.1511/os/x86_64/0 t( g9 T+ U, L8 t+ | ]% Z; l% A/ W& d
gpgcheck=1
7 k, L7 s: u6 x# G) e, ggpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7; k1 i- m% C. {5 e4 a( H
1 ^: [& v# X$ q( ?#released updates
! q2 ]' k: J/ s7 ~[updates]
% e2 a$ d; S" B# z) Z" u+ [name=CentOS-$releasever - Updates
& k3 ^9 c. v. S6 }#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra. |7 N8 }% s& L4 V% x( p
baseurl=https://mirrors.aliyun.com/centos-vault/7.2.1511/updates/x86_64/
O1 U+ Z! O9 C" i+ Agpgcheck=1) I5 }5 P7 l/ a: e1 o4 @
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
! _ Q/ k: y) I8 l, {2 n$ F$ W, Q7 X; F$ E1 H2 y
#additional packages that may be useful
- m3 D; E4 t2 b
6 v/ x% _/ `' V#additional packages that extend functionality of existing packages# s+ ?0 \. s9 z4 r
[centosplus]
5 Q/ b1 N h: Uname=CentOS-$releasever - Plus7 ]1 B9 {( U2 \! X/ T9 q
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
% e- V: t) L. zbaseurl=https://mirrors.aliyun.com/centos-vault/7.2.1511/centosplus/x86_64/) P% ?6 W1 H1 X% {$ Y
gpgcheck=1 v0 g7 t% l L* K- @7 g( S( A" Q
enabled=06 h, l) o3 \+ z: j
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-74 [+ h+ f* g3 p6 Z
6 {( q. l S7 ~$ ^, r7 T
+ F4 H# f8 I! {+ s1 ]
安装基础软件( `+ [# k: ~& p' }- u
yum install -y vim
( L3 e# k/ p: p$ w" p0 k0 hyum install lrzsz -y+ U4 I$ {3 w- T, M; b T
. a, Y9 d* K; H0 S
& s. x! t. S/ s: V# Q3 z/ P! V& A) j! u( a) N; o
1.下载xen的 源代码
) e9 M( Z+ L5 o+ ?0 q# }1 P3 I; hhttps://xenproject.org/downloads ... roject-4-10-series/; ^9 u- }+ z* _
; G1 g' v- B( j4 q% q- B
,解压 1 U! H O& l' Q. E1 V( y6 b4 I% O
1 N, ^! V: Q0 j* k' j: f [& T4 l9 H6 ^. |: p: p
% R' X6 Y) ]" R- \4 l$ c# I9 _# u$ p; z; A6 m5 I% c7 Z
tar -zxvf xen-4.10.0.tar.gz' G6 g) N0 w/ x$ c8 z
unzip xen-RELEASE-4.10.0.zip" f( Z4 O$ r: j2 G( O; h6 J3 {. r
9 z$ l6 H( U. ?6 ], w6 Q0 r0 y
2 U4 B) B# e! `( ?2 K/ ^7 n1 dcd xen-RELEASE-4.10.0
: l: ]0 ]6 h% c5 k5 v
+ p4 O7 u$ V7 N" T S#make help * g z, ?( E* z B h' s( @
, a( O2 v: K7 n' k+ A
' G2 ~$ |8 s+ I0 e4 Q. i1 I* F% r
2 M% T0 Q7 T4 v( [+ A
& N- q0 Q- ]" c2 B( x6 X0 N; n/ A3 t5 |& o
[url=]dev86-0.16.21-2.el7.x86_6 ...[/url]
, B. j; {4 h' F# }# }安装软件:
$ `$ ^7 H6 O9 V- y5 }1 z6 D% s
$ j; Z# ^! q4 `/ w, q( G' V1 A$ _yum install dev86-0.16.21-2.el7.x86_64.rpm -y 4 F$ n* x$ V5 R/ M: ~
# }* D& S2 j1 ]+ B- _Dependencies Resolved
) @; _4 _; b. ?* o" L
8 K3 Q: x" ^0 s% ~# W==============================================================================================================================================================2 Z, n* [2 b. L/ E$ ?3 m" j9 D- c
Package Arch Version Repository Size" e' y; B; ]8 b
==============================================================================================================================================================' C3 f w, O% M0 x; w
Installing:
/ @! O' h; m; t* `' k dev86 x86_64 0.16.21-2.el7 /dev86-0.16.21-2.el7.x86_64 991 k m; X$ c6 X, k! Q0 ?0 B+ z+ q w) q
$ i; X8 P! w5 I0 A, ]# Y2 C9 c) ]8 [, j1 h: Y
Installing : dev86-0.16.21-2.el7.x86_64 1/1
7 Q( E6 j2 x$ b% } Verifying : dev86-0.16.21-2.el7.x86_64 1/1 8 ~; U9 h# n- t5 s# c5 Z- m4 n0 j/ {( L
1 n% T" u+ @9 W
Installed:" h3 ~. O1 q0 Y2 r$ P' ^" ~
dev86.x86_64 0:0.16.21-2.el7
* Z: @) v" O% I+ o7 o' b* h- a& t9 U% C+ w& T k( k* X
Complete!9 l5 h" S2 r8 G! F7 ]5 d
! ]# d3 t: S2 r6 e# P# m- `! Y
5 b$ c" V3 C* R1 p4 i; [##yum install lzma
2 H* q/ j9 Q- O. L: M) D) m1 I0 jLoaded plugins: fastestmirror# y. X. R+ Q E z8 K
Loading mirror speeds from cached hostfile
* o9 b! z0 y5 r1 M1 l* ?! WResolving Dependencies* e/ b, S D9 k; A. l4 J N
--> Running transaction check
+ ~: U2 V6 e6 M---> Package xz-lzma-compat.x86_64 0:5.1.2-12alpha.el7 will be installed
b0 t6 [2 B$ Y. t7 t" |9 W' [6 U--> Finished Dependency Resolution- O* p8 r" l: M+ \' R$ H
8 l# e# Z& z; C" g8 ?& N
Dependencies Resolved
% O5 S- }. Q" ]0 s' m9 x9 N+ U, Y& o0 ?: {* v& C
==============================================================================================================================================================* R" a5 Y5 u# s) U5 Z- g
Package Arch Version Repository Size
% Q9 \7 U0 @6 V- T==============================================================================================================================================================' T4 s" o: p& H3 z! X
Installing:
# S4 W5 ]2 z9 q- s8 A, I, Z' [$ H/ y6 X xz-lzma-compat x86_64 5.1.2-12alpha.el7 base 18 k
, y Y% P$ V6 E7 R4 l. j% ]
/ N; \% m& ]/ {Transaction Summary) N/ w! F, o+ Z9 z5 ~* p
==============================================================================================================================================================0 c9 Z8 ?8 L1 }; O% M8 h
Install 1 Package2 e, W# k" N* Y& x5 W/ R
+ O; a8 {2 }" `- @
' r0 H; T, a. QRunning transaction
" j: |6 V0 j0 G/ m: Z @3 ~ Installing : xz-lzma-compat-5.1.2-12alpha.el7.x86_64 1/1 * w2 |& K0 @* \4 [0 X1 }4 ?" x
Verifying : xz-lzma-compat-5.1.2-12alpha.el7.x86_64 1/1 , z) A* P! v6 e% P7 o- |' L4 B
% E2 _3 w4 n2 d6 \Installed:
1 u4 ^3 o- c. n xz-lzma-compat.x86_64 0:5.1.2-12alpha.el7 7 G8 _, i/ O( s" m p& E# z* _
: V) v8 o6 S1 vComplete!
; N* i( v: _. H1 i$ N2 B) E8 f/ f5 D6 o0 L- o2 \* G
A& V k B. Y##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 patch4 {. _3 X# |0 P0 R
9 x* h& O% i7 E: U. `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
: ^. _& r" {/ E+ ], W; _# c Z' t) b* t% X1 ]
#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 3 D& P; [5 W" y* K+ ]: G
/ A2 J1 k! f: \5 Z o; N
#yum groupinstall "Development Tools" -y( \4 ?) a) ]; E
" c1 F% l. ]7 i5 W: @; \注:在安装的时候会出现一些错误,原因是一些工具软件没有安装,提示什么没有,使用yum install dev86(等等)安装就可以了。# i' [7 Y' Y8 w# Q" x. q
3 b8 N6 i: ]1 }% {; d$ `- G
#make dist-xen dist-tools% Z3 x: Z% {9 x U" k
第二种:+ @' s0 M' O5 A- p, i+ E
#make dist
7 D+ o7 d3 T+ |9 d1 `7 P# t0 p+ O. d
5 y5 v2 |1 r* p1 f: mrunning install
% z3 N: C7 J9 A8 U& w: I2 Crunning build1 b; g: x9 G" G- n
running build_py* u% t# y7 D3 ]% z- Z6 T' O. o
running build_ext
# y$ P3 H V% T) x1 z5 mrunning build_scripts. L7 H1 Y' G& R3 H. j6 b, j0 d
running install_lib- B( C. [0 z* o
creating /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub+ Z d$ c f4 t% L, b/ i5 I
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/grub0 P8 Y+ E' `4 z* A. m/ q( j; j7 w
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
5 t Q- P, M( ?# S9 icopying 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/grub3 Y9 r5 G. Y, E, A! ^
copying 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- G. Q2 k D5 `" w6 Z; O* xcopying build/lib.linux-x86_64-2.7/fsimage.so -> /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages0 N7 N7 J, c0 i; ?: G# a, l
byte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/ExtLinuxConf.py to ExtLinuxConf.pyc8 l# j7 N$ z( C: u% Q: i
byte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/GrubConf.py to GrubConf.pyc5 ^# I3 q7 N5 q8 h2 |, A% i
byte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/LiloConf.py to LiloConf.pyc) c" f6 r3 d. ^7 P! B0 i
byte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/__init__.py to __init__.pyc
- X% r+ _1 n. ~( ~% N9 |running install_scripts% q- d+ B3 S, s
copying build/scripts-2.7/pygrub -> /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib/xen/bin
* e8 V/ y( X1 M8 O ]9 uchanging mode of /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib/xen/bin/pygrub to 755
4 x& ]2 C5 M( P; hrunning install_egg_info: ?9 M+ U- V) r0 h/ ^* b# U
Writing /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/pygrub-0.3-py2.7.egg-info6 E- d, G# U/ Y" K' q8 |; e
writing list of installed files to 'build/installed_files.txt'
) K. o! ]; d. C, T9 Iset -e; if [ /usr/local/bin != /usr/local/lib/xen/bin -a \4 m' _# u! d- M! o: B* |6 T' Y
"`readlink -f /usr/src/xen-RELEASE-4.10.0/dist/install//usr/local/bin`" != \
3 V4 t* d5 s3 s: C- ?; \ "`readlink -f /usr/local/lib/xen/bin`" ]; then \
" u6 b; {0 I9 G( h8 L3 |+ ?* D. V% h ln -sf /usr/local/lib/xen/bin/pygrub /usr/src/xen-RELEASE-4.10.0/dist/install//usr/local/bin; \
2 W$ b; h" E# X+ Ifi
8 K0 j/ Q) }/ u; A! Nmake[4]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools/pygrub'
5 k& R7 y7 T+ h& g) P9 Mmake[3]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools'
& n/ E4 L$ s' zmake[2]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools'
W. p' U$ M, g: ?1 ~" I: Hmake[1]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools' T1 O0 L3 h1 g2 b" |- J$ V
, E/ ?, e+ @+ P/ ^) \
h o& c1 v9 h( n) q- P; }6 M( X
! O9 L0 e3 O# Rmake install
8 \8 d$ G, t; E0 q, m
& C+ m; @1 C; L/ u做软连接 ! v. y& N2 Q( _2 A1 u0 k( L1 d
( r$ d& s* F' m% D; Fln -s /usr/local/lib/libxlutil.so.4.10 /usr/lib/libxlutil.so.4.109 Y8 A/ M6 Y) k, y% b& a' B
ln -s /usr/local/lib/libxenlight.so.4.10 /usr/lib/libxenlight.so.4.10 : F0 o0 ^( m: h3 t G
或者使用ld.so.conf文件3 T' V t6 n; _0 ?& G I
echo "/usr/local/lib/" >>/etc/ld.so.conf
& m8 D9 c6 F, w; c- k0 t4 K, Y K& p. O( V7 {' @
" U- J7 N! \( N/ A1 d ldconfig -v( H A# P( T; w
+ ?* ?6 q; B+ u
启动:; L8 E9 V% x, a$ t
/etc/init.d/xencommons start
& A1 y8 ~9 q2 ^2 } D! q /etc/init.d/xendomains start
/ I+ k* V+ n% e6 Y3 X4 ]: W /etc/init.d/xen-watchdog start b0 D/ {6 B1 j( e# L* a+ O& Q
/etc/init.d/xendriverdomain start! B" s" v& J: Z3 K b& v' P& k5 M
O- k: Q. X7 l5 p* H! u( m) f配置内核:7 K3 \% M% ?8 t: |2 C
6 p0 i- {" f. x! m[root@localhost lib]# awk '/menuentry/ && /class/ {count++; print count-1"****"$0 }' /etc/default/grub | grep -i "Xen"
9 C3 X a5 }* E. j* K/ v[root@localhost lib]# sed -i 's/GRUB_DEFAULT=[0-9]/GRUB_DEFAULT=3/' /etc/default/grub
4 Y0 H0 d' X. H% c
1 X7 D& I0 m4 p# |- \
! v" D2 x; i/ o; _5 ? awk '/menuentry/ && /class/ {count++; print count-1"****"$0 }' /boot/grub/grub.cfg | grep -i "Xen" |7 x: W( ~9 M7 W: V
awk '/menuentry/ && /class/ {count++; print count-1"****"$0 }' /etc/default/grub | grep -i "Xen"9 s! s" _( d9 K. I; n4 n% h
sed -i 's/GRUB_DEFAULT=[0-9]/GRUB_DEFAULT=3/' /etc/default/grub
. S' N# ?5 P, x( Y5 W8 F& `4 i7 Q
[root@localhost lib]# grub2-mkconfig -o /boot/grub2/grub.cfg9 K& E: {; M" X! f0 X
Generating grub configuration file ...
+ O7 Y8 b" a# _& I" S4 sFound linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
9 p; d# K9 o+ u7 yFound initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img0 q: L. H4 @& u; |# \* g3 a' Z
Found linux image: /boot/vmlinuz-0-rescue-eb52b5b2e43a4c5d974045b5c0680969/ N2 h4 J. y: Y# J5 Y
Found initrd image: /boot/initramfs-0-rescue-eb52b5b2e43a4c5d974045b5c0680969.img
' p" d2 C; {' Ndone- r' t8 i5 }/ Q& ^: X3 P
% X3 v# Y, h0 D) @ I3 ?# _' a
7 a) q% c9 a+ n; G1 B
% l7 `0 A Q3 O3 E2 u8 }4 I; n3 b) x6 f, h" z
2.下载编译 内核 % y- A6 i& U" {& x$ i9 W" T) d
% o* k6 _9 _/ z6 o. Y' B3 ]
& c, ]' g2 x2 s% N7 n) ^7 Uyum install bc -y . d+ R g& L0 j" G. K4 _
$ e) a% j' n$ P9 e) F7 Y m/ E& I0 A1 m$ c
& O5 Z+ t9 e6 h8 Bhttps://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/6 E* i* {+ W- Z- d) m
, @7 Y3 C$ i2 a9 j
wget https://mirrors.edge.kernel.org/ ... inux-3.18.98.tar.gz --no-check-certificate) {" T; g }7 R$ t0 v3 I
9 k" S2 f f- i9 A5 p6 Z8 Q
3 q9 C2 |; v/ D U% @4 E tar -zxvf linux-3.18.98.tar.gz ( }/ z3 t3 c7 V1 r6 @! T4 t, k4 N9 R
cd linux-3.18.98
`* G1 I- O F0 e9 M, L* P7 B9 X( Z6 _) c6 `/ |4 p5 S8 X
1 x8 [, U: q9 X4 R
[root@localhost linux-3.18.98]# make menuconfig" r" j. w1 I4 f: i& H* F
* a8 y5 W8 j$ g+ f9 c3 Z
3 T% E' s) c& Y8 B3 u' [ Xen memory balloon driver x x
" G8 X% y! l3 I' Y7 o1 \. U: R x x Dynamically self-balloon kernel memory to target x x
y/ I6 A! {5 t" I; _' i x x [ ] Memory hotplug support for Xen balloon driver x x + S! H' |3 R2 z$ M) j
x x Scrub pages before returning them to system x x * H- a j# \$ ~; w. w* R/ _
x x <*> Xen /dev/xen/evtchn device x x i9 X& |. |% [6 P
x x Backend driver support x x
, N& a- \4 O5 m3 x x x <*> Xen filesystem x x # ~) M# Y4 i( `+ e! X2 u p* U! v
x x Create compatibility mount point /proc/xen x x 9 n- J2 a2 Z" Z* @( x' b, @% O
x x Create xen entries under /sys/hypervisor x x 3 @4 p$ L$ i. Q7 H& F
x x <M> userspace grant access device driver x x
2 X U7 O; g6 e0 T7 W2 Z% n$ ^ x x <M> User-space grant reference allocator driver x x 6 r3 [1 p# `* J' U% S' l
x x <M> Xen PCI-device backend driver x x 4 X1 f) s0 ?* H6 H
x x <M> XEN SCSI backend driver x x h+ e# o( o; f/ F
x x <M> Xen ACPI processor x x
: ?0 f- X/ D7 K; I3 P7 K x x Xen platform mcelog x x
9 S! O3 t. m$ D x x
; R, U D6 E. g1 |4 @% C
3 W# a: i* H% h# \; o9 a1 o
( ]+ A3 X; j5 J zvim .config
6 `1 [" B3 f7 p8 a. B: V+ I- p- x) c
+ g$ i' K! W+ | p #修改如下参数
2 f* J- R7 x1 |( u( ?$ u0 ` CONFIG_X86_IO_APIC=y' i$ N, e' f4 A6 [! m. N
CONFIG_ACPI=y
. V6 ]8 P& c6 r$ Y0 x CONFIG_ACPI_PROCFS=y (optional)7 \8 j, O/ Q( D# C! g
CONFIG_XEN_DOM0=y- ]( V6 d8 z: Y" A
CONFIG_PCI_XEN=y5 G+ j3 E# C2 U" K7 h
CONFIG_XEN_DEV_EVTCHN=y
, o. C* y$ ~: p+ {- K CONFIG_XENFS=y" W+ I! _" k" j8 C$ \* o
CONFIG_XEN_COMPAT_XENFS=y6 E: r: g9 s) N# h$ \6 s8 S
CONFIG_XEN_SYS_HYPERVISOR=y( |" U' @9 {5 k: N
CONFIG_XEN_GNTDEV=y
4 n4 f' s! W0 v4 {, W+ ?+ w L CONFIG_XEN_BACKEND=y
X" R( V( g# O, h2 Q, u) S; O& }' O CONFIG_XEN_NETDEV_BACKEND=m4 f; C( x8 d1 U8 y
CONFIG_XEN_BLKDEV_BACKEND=m
7 [& W* x7 @- y9 \% G0 V1 P! d CONFIG_XEN_PCIDEV_BACKEND=m
, z7 b }3 u2 |/ k1 c CONFIG_XEN_BALLOON=y
- M7 K4 x6 i# t+ s7 G8 y3 r CONFIG_XEN_SCRUB_PAGES=y+ H" R3 o. k, w
CONFIG_EFIVAR_FS=m
1 r* \- B" C; C! p
& E! w/ H: G; t) r: \ $ {4 q2 \+ k. n; ~2 V- I
make
2 r9 K3 x# l7 h0 y B$ ~make modules_install # j7 q7 M7 U' u2 e
make install
* i; l: R' T9 x0 G
' v0 v/ ^- Q7 w 配置 GRUB: P6 \( ]& X6 p" ]0 T) ]
8 Z! S# W0 d g4 Y3 G4 L
#查看grub2.cfg相关配置' F0 b; E% x6 Q# o" E9 p' j
cat /etc/grub2.cfg2 V0 o& w$ \, l
找到这段:
- J, v/ @* |7 b. o4 D3 H( R5 P; x9 p1 x2 t
menuentry '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' {
9 b! ~ q5 q' j0 J load_video
2 y$ Y7 ^; Z5 X- r: t set gfxpayload=keep
5 n6 W' y9 J; `0 D" r J insmod gzio4 t+ Z& A' a% p" m2 o$ Z1 d' B8 y: l
insmod part_msdos
/ \: `" L# S2 ^5 p. o2 @* U insmod xfs
( p9 |7 J3 C1 b# v3 R set root='hd0,msdos1'
! u7 L# m' w8 b" n, R if [ x$feature_platform_search_hint = xy ]; then( l( K. }; l0 [. p
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
4 d/ g+ x( r5 ~% Z5 q" N else9 q# X* ]( M2 |3 K( P" W
search --no-floppy --fs-uuid --set=root 82e6a5c0-2357-43a0-9d1e-755fadc55d21
4 y& B0 O# W C8 _6 f fi
$ c( R1 @1 I: L- d8 I K4 z linux16 /vmlinuz-3.18.98 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root LANG=en_US.UTF-8
" i$ `$ i- l5 s, g3 i initrd16 /initramfs-3.18.98.img
2 ^0 i+ r$ j8 I}
/ j2 N/ [5 V& S: V" A3 ]# K% q. p" n6 x' `; S
7 U) f# u8 A) {8 q- S4 [6 U
A" Z& p3 d1 Q( k5 i9 z$ O5 u
. ^8 X& G" W4 z( u* \& _( J5 K+ P8 G& H
#静态文件系统信息,定义了存储设备和分区整合到整个系统的方式3 e- i$ c" Q' D! M) i$ |3 s
cat /etc/fstab
8 { [( ]* E5 q% ]5 i% O- R
P) i; F5 W3 ]7 ]#复制grub2.cfg里第一个引导配置到下面的文件,添加一行 multiboot /xen.gz,linux16、initrd16修改为module
. ~! u$ ?& m! M& W1 z6 \" N+ g5 U2 Y& q+ O6 _- l6 G! F
; e7 x% L7 ^% ]( k0 N+ A2 e# h P4 T2 z. H* o
4 x: }. S- l* m$ _% _1 ~- P) ^$ z, Z7 R- [1 G1 l2 m) u3 C
#重新生成菜单7 T3 h+ G0 Q6 O
grub2-mkconfig -o /etc/grub2.cfg* P: H, b1 t( |/ Z2 Y6 w9 T2 o* ]
3 L: |5 R: ]7 R: i5 E
$ [7 Q f8 ?. A: G" F" W! z+ [. _8 Q: |* z" ]. L4 ]9 }4 l, t
grub2-mkconfig -o /boot/grub2/grub.cfg
/ m5 E3 Q' O0 K3 q' V0 k8 jGenerating grub configuration file ...
* U# o |+ Q1 X# i5 yFound linux image: /boot/vmlinuz-3.18.98
# r. A2 O6 Q& d6 f8 gFound initrd image: /boot/initramfs-3.18.98.img
/ Q7 B# }! N/ H4 L! d+ gFound linux image: /boot/vmlinuz-3.10.0-327.el7.x86_644 R5 I0 p- v5 q5 Q: |
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img+ n2 W: @$ S) b) u
Found linux image: /boot/vmlinuz-0-rescue-eb52b5b2e43a4c5d974045b5c0680969
' u. I+ B; Z( Q) R9 u9 h4 m/ AFound initrd image: /boot/initramfs-0-rescue-eb52b5b2e43a4c5d974045b5c0680969.img
* h8 r' a5 G- ^( u+ B/ S8 fdone
! N9 X4 `; E5 M; i
: M# r0 B1 ]% _( e两个执行都可以:
G/ t9 E' F8 ^2 J% R, V1 a: S8 s/ ^ ]; K/ X& t
grub2-mkconfig -o /etc/grub2.cfg
3 R- J9 \7 l' A2 C8 gGenerating grub configuration file ...( S0 i$ I1 ]' l. \* p
Found linux image: /boot/vmlinuz-3.18.98
6 B$ s0 g" ]4 H+ D9 i! c- x8 kFound initrd image: /boot/initramfs-3.18.98.img
- K/ a7 G0 [! {9 WFound linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64& ]; V$ Z7 x4 A$ V
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img' q4 o( N" ]- q. y3 L! L
Found linux image: /boot/vmlinuz-0-rescue-eb52b5b2e43a4c5d974045b5c0680969
1 M) y3 _ e6 R( [3 {, u1 UFound initrd image: /boot/initramfs-0-rescue-eb52b5b2e43a4c5d974045b5c0680969.img5 l0 x% `! e( G3 U6 S5 S
done
3 O* T- f0 j) y0 E. Q a' t9 g) d& C* Z J: i7 Z. v3 i
% E9 O+ Y0 c& E# o* X/ Q7 b) T* j$ e: B0 s! `2 y" z. [, F
vi /boot/grub/grub.conf
0 J5 d9 i# j9 j- {0 \: f1 [. u( A4 u' f; e' A* _
title Cent OS Linux (3.1.0-rc4)
/ J) J7 _, d5 y) ^( d root (hd0,5) ! y! r8 R$ R% k' J9 [' G6 l- e
kernel /boot/xen-4.1.2.gz //指定xen # R8 Y! f _5 h5 n2 f Y8 B
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 5 w: [3 v: D5 {5 X0 [; `' B
module /boot/initramfs-3.1.0-rc4.img //新内核模块
$ ?. g& c4 G! c7 d: e9 H5 H, C
9 a/ v4 \ D: Y, ~8 v6 F3.重启机器
8 B& z; G- P3 u, e1 Z0 F重启之后共有三个 系统 ,分别是:装有xen的linux系统、没有装xen但是使用的是新内核的linux系统、原始linux系统。
3 x$ G0 u! i9 Y6 t进入装有xen的linux系统,启动服务 ( F; v8 |) }1 n) d7 Y5 }
service xen com mons start //如果报错:NO such file or directory,手动加载模块即可,modprobe xen-evtchn " O- N9 g s2 S$ \$ T4 H
service xend start
# V! v, u2 p2 z: \5 @, U8 e3 t {3 A9 N# ?+ A2 f
* A0 e$ v, M1 k w8 |" v$ T
. j( D5 a9 Y3 b# w* w0 Z; m8 e
' i4 X% i/ P5 Z: {
; E+ u* [& w# V1 {) |
. H J4 F% i9 y5 v* z) E0 v9 i/ x& `: V1 T) \
) G( q5 V" |, c
% m% ?: |/ ~/ G5 D6 w; r) Y
& |% d! O8 ~$ N
% `' H* v( }/ M2 Z$ y; T- m8 C9 G: k5 u+ Y* P0 B
. t; h7 [& m4 ]0 U
: h, G. O1 W2 P: o# }( e M( a/ C* c' J# k
& g$ p: L6 b- a. [* u, V1 N7 E: t( ]/ J
/ E4 P0 b y h$ W) [
2 Y, W$ G" K0 S |
|