自动化安装linux(3)

2017-07-23  本文已影响0人  姜饼人_9e7b

http://www.jianshu.com/p/bb1bd67c7395
http://www.jianshu.com/p/3a752b9b6908
这两篇文章中,我们用光盘引导启动,然后在安装菜单上:

其实我们也可以自己制作一个iso文件去引导启动,只要在电脑插上有这个iso文件的光盘,就能实现自动安装操作系统。

1、拷贝isolinux目录

我的光盘挂载在/misc/cd/目录下。
先把光盘/misc/cd/isolinux/这个目录的内容拷贝到/app/centos6

[root@CentOS6 ~]#mkdir /app/centos6
[root@CentOS6 ~]#cp -r /misc/cd/isolinux/ /app/centos6/
[root@CentOS6 ~]#tree /app/centos6/
/app/centos6/
└── isolinux
    ├── boot.cat
    ├── boot.msg
    ├── grub.conf
    ├── initrd.img
    ├── isolinux.bin
    ├── isolinux.cfg
    ├── memtest
    ├── splash.jpg
    ├── TRANS.TBL
    ├── vesamenu.c32
    └── vmlinuz

2、编辑安装菜单

[root@CentOS6 isolinux]#vim isolinux.cfg         
#prompt 1
timeout 600

display boot.msg

menu background splash.jpg
menu title Welcome to CentOS 6.8!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000

label desktop     <<----菜单选项
  menu label ^Auto Desktop Install
  kernel vmlinuz
  append initrd=initrd.img ks=ftp://192.168.0.113/pub/centOS6.cfg
label mini        <<----菜单选项
  menu label Auto ^Mini Install
  kernel vmlinuz
  append initrd=initrd.img ks=ftp://192.168.0.113/pub/centOS6-2.cfg
label mini      <<----菜单选项
  menu label Manual ^Install
  kernel vmlinuz
  append initrd=initrd.img
label local     <<----菜单选项 
  menu default    <<默认选项,我放在这里,是避免误安装。当误操作放入光盘时,系统在本地找不到安装文件,就不会自动安装。
  menu label Boot from ^local drive
  localboot 0xffff

3、打包iso

接下来,我们就把/app/centos6这个目录打包刻录成iso文件。

[root@CentOS6 isolinux]#mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 --boot-info-table -V "CentOS 6.9x86_64 boot" -b isolinux/isolinux.bin -c isolinux/boot.cat -o /root/boot.iso /app/centos6
I: -input-charset not specified, using utf-8 (detected in locale settings)
genisoimage 1.1.9 (Linux)
Scanning /app/centos6
Scanning /app/centos6/isolinux
Excluded: /app/centos6/isolinux/TRANS.TBL
Excluded by match: /app/centos6/isolinux/boot.cat
Writing:   Initial Padblock                        Start Block 0
Done with: Initial Padblock                        Block(s)    16
Writing:   Primary Volume Descriptor               Start Block 16
Done with: Primary Volume Descriptor               Block(s)    1
Writing:   Eltorito Volume Descriptor              Start Block 17
Size of boot image is 4 sectors -> No emulation
Done with: Eltorito Volume Descriptor              Block(s)    1
Writing:   Joliet Volume Descriptor                Start Block 18
Done with: Joliet Volume Descriptor                Block(s)    1
Writing:   End Volume Descriptor                   Start Block 19
Done with: End Volume Descriptor                   Block(s)    1
Writing:   Version block                           Start Block 20
Done with: Version block                           Block(s)    1
Writing:   Path table                              Start Block 21
Done with: Path table                              Block(s)    4
Writing:   Joliet path table                       Start Block 25
Done with: Joliet path table                       Block(s)    4
Writing:   Directory tree                          Start Block 29
Done with: Directory tree                          Block(s)    2
Writing:   Joliet directory tree                   Start Block 31
Done with: Joliet directory tree                   Block(s)    2
Writing:   Directory tree cleanup                  Start Block 33
Done with: Directory tree cleanup                  Block(s)    0
Writing:   Extension record                        Start Block 33
Done with: Extension record                        Block(s)    1
Writing:   The File(s)                             Start Block 34
 22.37% done, estimate finish Mon Jul 10 02:52:33 2017
 44.66% done, estimate finish Mon Jul 10 02:52:33 2017
 67.01% done, estimate finish Mon Jul 10 02:52:33 2017
 89.33% done, estimate finish Mon Jul 10 02:52:33 2017
Total translation table size: 4483
Total rockridge attributes bytes: 1360
Total directory bytes: 2048
Path table size(bytes): 26
Done with: The File(s)                             Block(s)    22214
Writing:   Ending Padblock                         Start Block 22248
Done with: Ending Padblock                         Block(s)    150
Max brk space used 0
22398 extents written (43 MB)

看一下打包好的iso文件

[root@CentOS6 isolinux]#  cd ~
[root@CentOS6 ~]#ll boot.iso 
-rw-r--r--. 1 root root 45871104 Jul 10 02:52 boot.iso

4、把boot.iso拷贝到windows上

[root@CentOS6 ~]#sz boot.iso 
rz
Starting zmodem transfer.  Press Ctrl+C to cancel.
Transferring boot.iso...
  100%   44796 KB    14932 KB/sec    00:00:03       0 Errors 

5、用boot.iso启动引导

图1,我在vmware软件上新建一个虚拟机,启动光盘就是boot.iso


图1

图2,启动虚拟机,进入一个选项菜单。这个菜单就是我们第二步配置的isolinux.cfg文件。选择第一项我们试一下


图2

图3,系统用eth0网卡获取ip。


图3

后面就是自动安装了


Paste_Image.png Paste_Image.png

6、刻录到U盘

我们可以用dd命令刻录到一个空的U盘上面。我的U盘是/dev/sdb

Paste_Image.png
上一篇下一篇

猜你喜欢

热点阅读