|
|
在centos7.2系统上安装xen服务
* r' }8 B: N' p* q9 o! N# Y
5 \* s" J" Y+ N% L9 I1 E& _0 c, x! U" n
z, P$ h4 {( D: x5 o( O
[root@localhost ~]# cat /etc/centos-release; }6 U. O+ y# E7 O2 |
CentOS Linux release 7.2.1511 (Core)
% E1 V+ h' l( _! w# [. d" `8 e5 |, }! p# e
调整selinux ) |- D: q7 D7 m" C! l- b) k* F
: P" X, o0 [5 _
SELINUX=disabled: D4 N! w. s# l1 W$ ^; v+ z) j. N
2 z/ l8 l! s4 t7 Z' v
. L% @9 v; Q+ y7 l! M! [$ c! Y3 S) m/ T8 N7 U; C
首先配置yum源:
- L) o. c- B8 o5 ]8 x, k, D" X) Q5 @0 z2 i" `) A: k
, X% v$ v: l- \
[base]+ r/ `* ~: O4 I1 F8 t
name=CentOS-$releasever - Base: ]9 f% t: n# X
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
. ~: f. @# X3 {) hbaseurl=https://mirrors.aliyun.com/centos-vault/7.2.1511/os/x86_64/
|2 r9 }% `$ B4 n! S! T: r n0 Hgpgcheck=18 e4 ^$ t; F6 g D$ B6 U6 t0 L0 t
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
4 _2 k9 r3 A4 j- b, T$ z* @ p) J8 n
7 \, Y d/ W9 K h; Z; r* Y7 ~9 T! b#released updates
, w2 H. H3 L* @' C8 h1 P. R( R8 ~[updates] N1 d8 F7 C; g3 m
name=CentOS-$releasever - Updates5 I# }% A$ L; z; o5 `
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
$ R& l, C4 ]1 m6 Lbaseurl=https://mirrors.aliyun.com/centos-vault/7.2.1511/updates/x86_64/9 Y* ^( R# a0 R! K
gpgcheck=17 r) P7 Q1 P* ~1 s$ p9 j
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
( a" o: R; q S: L, h& x# Z- k2 S' r2 z
#additional packages that may be useful6 j9 }; s9 m4 H& M: U- @' W
3 \6 O* ^8 v; h" h" @: y
#additional packages that extend functionality of existing packages, q/ w9 }* x. o
[centosplus]
5 _) b- L/ i5 L) q2 Jname=CentOS-$releasever - Plus, e- }0 p% i z, B# W' Q
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
7 W2 w( V, b0 l7 o$ V1 kbaseurl=https://mirrors.aliyun.com/centos-vault/7.2.1511/centosplus/x86_64/
3 H- m; Z- d) C8 s5 Wgpgcheck=1) U9 X) \& L% z9 l" B% W
enabled=0: d' Q5 c* Y( g( h! I" |& B
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7' J( y; j9 [$ n+ j- h2 M
! K9 L& n0 p1 x6 L3 v" {) s6 y3 _
+ v8 r# h+ v3 O- f安装基础软件2 a0 {, P3 A2 z1 I( y
yum install -y vim
% T; V+ s/ c) O ~0 c- O& }yum install lrzsz -y! Y1 B/ {7 x$ f6 J; {! `+ @
9 W# N( U9 a8 h0 Q9 b: V4 R5 e; y3 m4 \; G: p* o1 p, d
- _) h* U- D% g1.下载xen的 源代码
, o2 Y4 S8 ?0 J! p& _https://xenproject.org/downloads ... roject-4-10-series/0 J* ^3 m, T. R; U
/ I+ x4 w! {! k6 E! _; T7 k1 m% b l$ ^
,解压 # k3 z9 f' H; M
4 b1 S; Z3 n& k. U7 b2 E$ u; V
& v9 t1 X: O$ a+ C
* h/ g: `4 S& l# Q) g. i* M. I4 A8 i" L) ?! W9 U% b& `
tar -zxvf xen-4.10.0.tar.gz
0 n p8 ]% e) t5 Q- Nunzip xen-RELEASE-4.10.0.zip8 D; G/ {$ D; Z6 a
7 ^' g; X* T) a2 H y; h8 L& v
2 v& ~' O* B' P$ R6 K1 {/ }cd xen-RELEASE-4.10.0
9 f/ h8 A" Y% N
- w$ Z" }+ Q3 T#make help
7 R8 G9 L! b& j* v" j
; b0 s6 \ t6 p$ N" [, L% h* F7 Y: ]
, p. j3 t/ R" p/ t' z2 l
2 ~+ m+ z2 b$ L& X5 w+ T" k1 _- g
5 [0 u N- l) S% y. B[url=]dev86-0.16.21-2.el7.x86_6 ...[/url]* H. `! M+ N! e @- m9 Z9 t# K
安装软件:
9 S9 b4 w6 M* @# K5 {
5 Q. M5 a8 J8 W8 G7 |4 k( _yum install dev86-0.16.21-2.el7.x86_64.rpm -y
; P. q1 ]+ {# B1 h2 Y2 k" k1 b
; C& N7 |2 I7 l, k* W6 e6 A2 B3 sDependencies Resolved! s' J! O! Z7 }. i1 T: R1 Y
@' F9 v+ n _ n, V==============================================================================================================================================================9 V7 @3 |6 v9 Y( f( L b2 a2 i
Package Arch Version Repository Size
[0 H$ b" q) L/ T& N==============================================================================================================================================================
9 S2 }" F5 j2 {( X: C: J4 NInstalling:. [8 U4 s% x Z
dev86 x86_64 0.16.21-2.el7 /dev86-0.16.21-2.el7.x86_64 991 k
! N, k% _. ?. r, u, B/ [: i; b& E
2 ]9 l9 `0 ]: s( S6 C Installing : dev86-0.16.21-2.el7.x86_64 1/1 6 c( Q$ F7 x. p7 q6 k: B- O' x
Verifying : dev86-0.16.21-2.el7.x86_64 1/1
0 Q! I' {& r4 l- d" C) c! M0 r3 x4 b( Z2 v$ g3 l/ A! @
Installed:! J$ m9 ^' y# ]; k
dev86.x86_64 0:0.16.21-2.el7 6 a0 \( p6 }, a" Z/ u) |, T4 C
: y( L% K3 h" M' @
Complete!( p; o8 l! ~/ V1 b5 a
0 W0 a- _' F5 @ e
5 N( p& Y! Q6 ]##yum install lzma
J$ P, {" B: l; P+ }: j$ `$ OLoaded plugins: fastestmirror" g5 d& @" k( i% j# W( h
Loading mirror speeds from cached hostfile
7 K3 z0 ]. b: B9 c7 Q8 m* oResolving Dependencies% v9 n5 x# B5 U2 \$ y& A9 j0 K" R4 {" C
--> Running transaction check7 @* Q7 P5 X1 H* F. D( P: m5 ?2 p
---> Package xz-lzma-compat.x86_64 0:5.1.2-12alpha.el7 will be installed
, Z% ^9 E4 A6 k0 _--> Finished Dependency Resolution
0 `0 J2 e1 \6 o9 s/ Y }. D' G" w' F2 d R
Dependencies Resolved
2 k# b% J; R2 ~9 L' G# T
- D" m& A1 s; b R8 f- n: w==============================================================================================================================================================
' o* D" t Q$ Q; y Package Arch Version Repository Size
5 }9 W8 L2 n# ^' L==============================================================================================================================================================& m1 U* ?( G* A- f3 e2 _
Installing:' i6 I8 i3 Q) k- r1 r1 ]* q& E
xz-lzma-compat x86_64 5.1.2-12alpha.el7 base 18 k( C! V& q& e& Z+ N \6 U
) j3 F- W, U# v
Transaction Summary
8 R* F; d! b9 e% [! m( @& e% b==============================================================================================================================================================5 ~: o$ l4 i* X0 O( D9 ]
Install 1 Package
8 }) I$ n. m- x0 @3 m- S. u, w8 j0 Q2 m8 f S. B5 R2 L2 T
( L- n1 E, ], G# O6 W0 s
Running transaction
+ j! c Q7 e/ \; ~: P8 ` Installing : xz-lzma-compat-5.1.2-12alpha.el7.x86_64 1/1 : t0 S& o V% X( f1 f$ V
Verifying : xz-lzma-compat-5.1.2-12alpha.el7.x86_64 1/1
4 b& G0 e- j$ R! x# D! ]. n( u) b& v! X3 [. G
Installed:
- t8 K* Y& q/ x/ S* C: f xz-lzma-compat.x86_64 0:5.1.2-12alpha.el7 9 o0 P z) q& E4 i# y
' z& v1 R( R. X0 \. `Complete!
4 r* T7 b1 ^' X2 \
7 o3 {4 r# b2 k# Y1 x* F3 U( A. G: c) L# s9 E1 @
##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
4 g6 `. M, W/ `" [% ]$ a: n: g# m7 Z6 q$ t: b
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 git8 f; [5 [. f, p e# c: L0 W
* j" i# o: M/ @#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
$ v! g G* g$ y4 J4 E w3 q% e
& I: |% ]8 i, m: Q2 S- W( G9 a#yum groupinstall "Development Tools" -y. q$ @" \+ ]- `/ S. x' j0 K |
7 u6 B2 D6 V. v' P) g9 b5 l$ k
注:在安装的时候会出现一些错误,原因是一些工具软件没有安装,提示什么没有,使用yum install dev86(等等)安装就可以了。3 j: A- Z# k* Y; _- S* l5 f+ O: }
1 l; I8 G7 q I9 v5 q6 B" s#make dist-xen dist-tools
3 f2 D$ b% {' g4 `, m1 C' I第二种:/ C# o% V5 C: {3 [+ L
#make dist% i) Z# C7 I( u7 C7 T6 y+ k
" F" o6 S# y9 d, |; I) y. r6 @
& \7 w! x% ^7 f% j' e6 Zrunning install2 S; l6 S& T4 X0 U9 v
running build
+ }+ `; X* C; U6 E0 ~% Nrunning build_py3 w" ]% B4 u! K; f
running build_ext' y% \' }4 ]2 Z
running build_scripts
0 }# b( I# H, trunning install_lib
$ K2 n* M- @8 j. e0 n+ Ncreating /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub4 T# r" [& A) Y/ W; y* M( e9 r4 |
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
+ j7 s5 t/ ?& e- C6 h0 {2 Gcopying 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% V8 y8 |# ~. [
copying 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
3 y: @ l( U) B( x7 ecopying 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
# e) ]( ]. y% f) I& {: F/ p0 j5 Ecopying 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
6 G( K1 E7 Q# Nbyte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/ExtLinuxConf.py to ExtLinuxConf.pyc
- ^5 m1 J0 p! v0 [4 O, D& Qbyte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/GrubConf.py to GrubConf.pyc( f: k$ [+ T$ t6 D/ M9 }
byte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/LiloConf.py to LiloConf.pyc0 n0 z) J$ D( d
byte-compiling /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/grub/__init__.py to __init__.pyc3 C. n4 H3 `7 O, m8 f! d
running install_scripts% B. r, {2 d; P" q
copying build/scripts-2.7/pygrub -> /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib/xen/bin$ c$ g& p8 h6 q8 d9 c
changing mode of /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib/xen/bin/pygrub to 755
+ c2 M7 B: K8 Trunning install_egg_info
3 a& e+ [1 U! }( G* E+ A: v1 A+ KWriting /usr/src/xen-RELEASE-4.10.0/dist/install/usr/local/lib64/python2.7/site-packages/pygrub-0.3-py2.7.egg-info
' d! E. B' }6 X3 W! owriting list of installed files to 'build/installed_files.txt': Y5 _' X8 i s p0 T4 F2 h
set -e; if [ /usr/local/bin != /usr/local/lib/xen/bin -a \
1 t; p. X' Q0 b/ V "`readlink -f /usr/src/xen-RELEASE-4.10.0/dist/install//usr/local/bin`" != \
p: i1 u- x2 l# ]. h# M( k. \ "`readlink -f /usr/local/lib/xen/bin`" ]; then \
/ ^/ Y4 B; T7 X/ s ln -sf /usr/local/lib/xen/bin/pygrub /usr/src/xen-RELEASE-4.10.0/dist/install//usr/local/bin; \, M% v" T: a1 [# V7 F! \
fi
7 G4 |% |9 n6 mmake[4]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools/pygrub'
% `+ t9 f# Y8 _* W1 \make[3]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools'
4 l H! \, @% ?% F& Kmake[2]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools'0 v* ]6 Y5 x* z0 T2 ~$ R" S
make[1]: Leaving directory `/usr/src/xen-RELEASE-4.10.0/tools'
# r4 h2 q y" X* ?& C8 a$ \& T( E3 X7 A, z5 l
& J) V2 u4 H5 c/ \% }
2 M" V* l3 d: S6 ymake install
1 L4 x) s0 ?% P* f3 {. Z" G+ w. a+ L8 o$ v3 _
做软连接 4 C% _8 S4 g6 e. Q2 }: ~1 L4 @
/ @- ~5 y2 ~( a" _ln -s /usr/local/lib/libxlutil.so.4.10 /usr/lib/libxlutil.so.4.10; _& @' n6 i' V1 s* f
ln -s /usr/local/lib/libxenlight.so.4.10 /usr/lib/libxenlight.so.4.10
' p V( {) v: z或者使用ld.so.conf文件0 Z5 o: l) z0 \8 _" I
echo "/usr/local/lib/" >>/etc/ld.so.conf" v+ ` s; p+ ^ y# v* u/ N- N7 }
2 B7 ^* i5 \$ o. I
w" @2 l1 g% ~# x, \% D* Z$ m
ldconfig -v c Z6 J- X% ^' z/ D3 N2 }
6 ?) z- u6 ^) F+ E 启动:
7 ^% b" w8 E$ P3 S/etc/init.d/xencommons start' k" `) [" ~; C
/etc/init.d/xendomains start! U& `" a( q$ U, O2 t
/etc/init.d/xen-watchdog start
. Q4 m- G0 E7 y8 z& _5 m- R /etc/init.d/xendriverdomain start
4 r0 E1 w( A2 F3 D& V( v- c+ ~+ v7 M# P* X
配置内核:3 l2 ?* s+ ]/ a
, }$ ^1 W% a7 j, g) p1 {
[root@localhost lib]# awk '/menuentry/ && /class/ {count++; print count-1"****"$0 }' /etc/default/grub | grep -i "Xen"
+ [' Z- X# w5 v9 V6 z8 n) f) r8 _[root@localhost lib]# sed -i 's/GRUB_DEFAULT=[0-9]/GRUB_DEFAULT=3/' /etc/default/grub% V2 n: I6 ?' T2 Q0 h: D& m# V
4 n, `) D7 X" M, S
3 y, {7 ~8 `& ^ awk '/menuentry/ && /class/ {count++; print count-1"****"$0 }' /boot/grub/grub.cfg | grep -i "Xen"9 F! R. a8 \* k! ~& C
awk '/menuentry/ && /class/ {count++; print count-1"****"$0 }' /etc/default/grub | grep -i "Xen" ~: e: ?6 y; J9 l/ B/ B8 k1 p
sed -i 's/GRUB_DEFAULT=[0-9]/GRUB_DEFAULT=3/' /etc/default/grub
7 A6 g( R; B, ~- \9 y
" R2 u* C3 |; h6 d5 _& J[root@localhost lib]# grub2-mkconfig -o /boot/grub2/grub.cfg1 H- ^/ q8 Z* q7 {3 j {* F
Generating grub configuration file ...
9 R, h4 T( k7 K; i* dFound linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64* f2 l9 ]1 G3 v* M# U
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img/ d- g4 C7 a/ f% v( k; Q% w5 ^4 \
Found linux image: /boot/vmlinuz-0-rescue-eb52b5b2e43a4c5d974045b5c0680969
3 [5 E( L. c& c6 oFound initrd image: /boot/initramfs-0-rescue-eb52b5b2e43a4c5d974045b5c0680969.img
& z& Z5 a$ k; c2 t! edone
" W4 d' u% r/ [4 W( j
+ }+ _. r1 d. z$ E% c7 b5 K m E r7 q* Y
! t+ t5 K2 d8 T# Q* a9 T
& y; h E+ R* S0 y6 D2.下载编译 内核
: D7 R$ Z- ?1 s4 K9 G R8 b$ F) s/ Z/ t
" m: C/ u0 h8 N5 V
yum install bc -y
2 X- p$ _! z5 r$ ]' B5 L+ n. h5 F, y1 v# I
* r9 k3 ]) `7 b9 y3 f+ R
- Y) X* n( S% \+ \; R$ Phttps://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/
$ ~( o- w9 K; G0 r
% {# b" ~9 d3 D3 R! twget https://mirrors.edge.kernel.org/ ... inux-3.18.98.tar.gz --no-check-certificate4 @" O/ y6 m% R' Q" |/ o
) c: Q5 K9 T. d4 K$ Y6 u6 }& a4 M
5 e9 w$ F1 i* X tar -zxvf linux-3.18.98.tar.gz 9 g) d! `! y1 H7 X& U5 S# x7 U2 m
cd linux-3.18.98) V: F4 `6 B0 k2 j
9 j& g; I0 d; d1 D) \- Z
; f& Z7 Y# j7 k( P$ n- E& O[root@localhost linux-3.18.98]# make menuconfig
: K" E: q$ f0 a. V; Y/ G7 y5 v; h; ?$ |+ ^7 m
3 t' m' v6 x; B* q, @. _ Xen memory balloon driver x x
. y( B/ Z: [/ w/ N( x0 v5 o x x Dynamically self-balloon kernel memory to target x x
) p3 F7 N$ [( [, E) Z# r x x [ ] Memory hotplug support for Xen balloon driver x x
/ w* `1 h) ~4 g) B) X: U x x Scrub pages before returning them to system x x - N% k% j& z" s3 `0 i
x x <*> Xen /dev/xen/evtchn device x x
" o w' \" K- @9 H- G4 h, t+ a x x Backend driver support x x * f1 K" l$ }! M; X+ ], t- X3 L
x x <*> Xen filesystem x x
* X; o; r s& o# ` x x Create compatibility mount point /proc/xen x x 2 m" H5 W! h1 i o9 g2 y: c+ A+ [! Y
x x Create xen entries under /sys/hypervisor x x . v2 ^2 h# D1 t4 T) ~% [- M( D* ]
x x <M> userspace grant access device driver x x
* s3 ]& f9 e$ |5 o9 i N# _# u V. { x x <M> User-space grant reference allocator driver x x
$ D* X, t C/ L5 d) G x x <M> Xen PCI-device backend driver x x , G2 r. ]& t0 ~0 s" q
x x <M> XEN SCSI backend driver x x ' X' }0 \8 P( b4 U+ l7 u* M
x x <M> Xen ACPI processor x x
' L# G g' D6 l# ]5 g. |/ ~ x x Xen platform mcelog x x
5 F2 c0 W( H) P, D" ] x x 3 U R8 G7 B- |8 v1 z/ ]
( x" Q5 g& @( i3 ~0 ]
# t( ^) `' f. s; W3 hvim .config: A) I! G" m$ [ c
$ A3 Z' @9 C9 ?8 f; s8 t
#修改如下参数
; z, r' n; M8 x, s5 @6 X2 v CONFIG_X86_IO_APIC=y
+ m5 y3 X5 I# n- f! ^; y CONFIG_ACPI=y& l9 ]$ \5 [# l1 q2 b5 n
CONFIG_ACPI_PROCFS=y (optional)
1 v3 R8 r1 b* P4 Q CONFIG_XEN_DOM0=y- ]8 j# H* d1 B6 m) I
CONFIG_PCI_XEN=y0 u% u3 I" I# Z+ m% \* ^
CONFIG_XEN_DEV_EVTCHN=y
; v/ y# f$ ^5 x8 p5 A& A CONFIG_XENFS=y/ G6 {) A8 v B* D
CONFIG_XEN_COMPAT_XENFS=y! ^2 A# k1 q1 X+ W4 f( I. s
CONFIG_XEN_SYS_HYPERVISOR=y
+ ?* {4 T2 K* u; e6 r CONFIG_XEN_GNTDEV=y. U) M/ n2 s7 ^! d! R: s2 r
CONFIG_XEN_BACKEND=y
( n. H _ z: q% H+ L ?6 _ CONFIG_XEN_NETDEV_BACKEND=m2 z4 x+ z' ^( a- D8 B
CONFIG_XEN_BLKDEV_BACKEND=m \* o3 v0 o+ t$ U2 C
CONFIG_XEN_PCIDEV_BACKEND=m0 I: o5 I8 ~$ I& Q& ]
CONFIG_XEN_BALLOON=y# A9 }0 b! l" U# |
CONFIG_XEN_SCRUB_PAGES=y
* j0 i @ |; @* n1 u CONFIG_EFIVAR_FS=m
$ {8 r/ z/ o: k+ ]) K) p+ c. p. W) L8 m; L$ F" ^
8 D ~7 b2 ^' v- Q
make / `* \( s! F k
make modules_install 7 \, b, @% ]3 V* ^, s1 |( N
make install/ M/ |6 w2 K1 X, D k# C' W0 h
4 P! f Z% F0 n# d2 X8 D$ t 配置 GRUB& G! z- D7 K8 ^% c) Z
$ \+ C! w6 ?, N# Y5 {! s
#查看grub2.cfg相关配置
* e; ]! z: ~/ ~8 F) c/ {" B( }cat /etc/grub2.cfg" _; j; E0 X: Z0 e& w! T
找到这段:
7 {: m8 P" N+ @5 T/ t" J* W
/ Z$ o7 j. ^ C# y( I0 I4 ?. Pmenuentry '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' {
7 }6 {+ ^0 w( ^# `0 V% J load_video1 V& Y; }# F& i6 Y3 @& F9 B) p, s
set gfxpayload=keep' o% L7 y- z# z+ T& K
insmod gzio
, O- a- l( U+ `/ m; a insmod part_msdos
2 W6 }! s, H- j' ^- ?: T insmod xfs2 J; x9 j8 g2 L, k" R7 v$ @
set root='hd0,msdos1'6 ]/ t! G$ Q8 u' C, q
if [ x$feature_platform_search_hint = xy ]; then
! u0 |0 |" N. Y" W 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( v6 F3 u3 s8 \# D- d- P* D8 o$ w
else4 y, h1 n! I) X9 Y2 r$ K# _1 b& H
search --no-floppy --fs-uuid --set=root 82e6a5c0-2357-43a0-9d1e-755fadc55d21# n- s* ` t" V* X% Q0 }! ^( X' {
fi
9 x( S8 {: r r6 Q! ]" C% @ linux16 /vmlinuz-3.18.98 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root LANG=en_US.UTF-8
% t" K6 Y- g$ [6 c) k! c initrd16 /initramfs-3.18.98.img
6 ?( n$ S' X. W. m5 m}- F v; @3 V# m+ a/ \
3 b: D% F: _4 {* P; j2 H/ m, W
: J @& m X e, `' S1 }7 {, X5 E7 a
& E3 V1 R6 k" d6 Y% I4 l. x
2 I/ d2 b* G% f+ \3 s6 w- U7 e6 f ]* p. p/ g
#静态文件系统信息,定义了存储设备和分区整合到整个系统的方式1 x' G7 u7 s5 J5 ?. R2 t8 w& v3 y
cat /etc/fstab
6 `3 b6 T) ^4 i2 X5 B. w3 L2 s
- ]6 x/ {: y# T3 n! }3 X" {#复制grub2.cfg里第一个引导配置到下面的文件,添加一行 multiboot /xen.gz,linux16、initrd16修改为module
" h5 K4 b: D# u- d7 ]$ B% v; Q/ r0 \1 Q9 ]9 \9 v. K
* q# i6 T. J: _; z" N* f# e
6 [9 M- ~" R) I* ^1 F8 i0 z7 h1 x. U9 G$ @8 T
- W! ]/ i5 k* S: ~
#重新生成菜单* D% d: H8 M, H6 g: B) N
grub2-mkconfig -o /etc/grub2.cfg
" _4 c5 H7 K% L
5 A' k4 h/ ~# I* [) ]' \ S& `2 L( E$ f8 i
; L" |. l7 C# b' I0 M! p
grub2-mkconfig -o /boot/grub2/grub.cfg
' U9 N0 n' b8 H0 b, qGenerating grub configuration file ...
% _( o6 p* X$ ?- ]5 i' HFound linux image: /boot/vmlinuz-3.18.98$ e: w0 H7 J8 D0 Z& p: L- U% R
Found initrd image: /boot/initramfs-3.18.98.img' S% g5 a5 I2 G( S& [
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
6 r. Q4 C; ]' i7 s( m+ {* |Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img# }& W. W/ P+ C' f7 d5 u0 u
Found linux image: /boot/vmlinuz-0-rescue-eb52b5b2e43a4c5d974045b5c0680969
0 k; l3 Y1 `; y" h( Z8 wFound initrd image: /boot/initramfs-0-rescue-eb52b5b2e43a4c5d974045b5c0680969.img
T/ i7 a: m5 U Y, Pdone5 U p$ [8 B7 @' C: `+ K0 f
3 |$ h8 e/ n: }9 n6 n
两个执行都可以:
" y4 S* W. {( c9 _7 ^4 M" J1 @& C; d7 {/ A j
grub2-mkconfig -o /etc/grub2.cfg % o! R2 o7 U/ e. }: J; f
Generating grub configuration file ...
* T8 U4 j# h# H7 y/ OFound linux image: /boot/vmlinuz-3.18.98
6 l6 u, L( j* R2 u1 bFound initrd image: /boot/initramfs-3.18.98.img$ o$ X3 S( N' H
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
& X8 ~* G( l$ TFound initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img5 m/ b* ^. d5 t7 X; n
Found linux image: /boot/vmlinuz-0-rescue-eb52b5b2e43a4c5d974045b5c0680969
% I) s- e/ ]% }' OFound initrd image: /boot/initramfs-0-rescue-eb52b5b2e43a4c5d974045b5c0680969.img& O; K/ X. y" T: A5 W
done
, {- [" z7 L, y! g1 l" K( Z* r
- V* h1 l( P0 S5 N% K: l" ^7 ]3 s" ^8 v0 w8 m/ p. m- F
6 M& k P+ _: y* P" s7 [vi /boot/grub/grub.conf
/ F. @+ B4 C2 N* @8 k" r# V7 p! E5 e6 K) Z' ~% A2 {- r* P" V$ L
title Cent OS Linux (3.1.0-rc4) : I% G7 t' z1 v0 ^* G* _! d
root (hd0,5) 1 c& i) r p1 U; J( Q2 l5 `
kernel /boot/xen-4.1.2.gz //指定xen
7 B$ G% T- X9 _0 }' G 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 d7 C& Y3 c' ~' ]6 S4 U
module /boot/initramfs-3.1.0-rc4.img //新内核模块8 S5 K6 u7 z R
6 _, f! f) G1 x! d3.重启机器 & y t4 y* H) K: f7 t
重启之后共有三个 系统 ,分别是:装有xen的linux系统、没有装xen但是使用的是新内核的linux系统、原始linux系统。 . Z! N0 w. ?. D
进入装有xen的linux系统,启动服务 # b! G, @) ~) Q4 r9 @
service xen com mons start //如果报错:NO such file or directory,手动加载模块即可,modprobe xen-evtchn , @; G1 A5 Y \1 x7 [/ ^
service xend start
& e! @8 X" v/ s8 V, ]" l5 x: E3 ^" b0 F2 G8 \& B3 y
6 W# j q6 M9 k% l8 O2 q
6 S; |9 K' c) ~- ^* y" Y1 J l+ K1 V C& O
9 T$ T1 k6 [" z4 {6 j" ?1 j
; N: r) A1 p. h4 |) t+ c) ^% E) U5 r, ^- O" }3 k) N
5 N k' n9 ~; ]7 Q2 Y; C; C
' u+ {- ~- y$ y7 ?0 b! p8 J; P P: {: T. i
) T& t* \; X3 H) `6 Y" j8 j
@. s2 V: t0 \0 X' K
3 n+ W" z6 k4 I2 @
8 u& j0 v0 s! d q6 O7 a
, U( I4 a6 J. ?5 Y; @& b( I$ ?) m7 v6 Z3 z8 K T5 R- \ G4 a
" B, Y* e' O" _( O- G
" {: U& g& z& i( U9 I: u# {7 Z1 Q4 i* K
|
|