制作Cnyunwei-X64-V11_base.iso的 U盘安装盘(syslinux方式)

实验准备:Kingston U盘(2G)

                Cnyunwei-X64-V11_base.iso(集成Nagios和Cacti的CentOS系统)

                下载地址:http://pan.baidu.com/share/link?shareid=3274671730&uk=2617460561


实验环境:Ubuntu 12.10(其它linux系统也可以)



制作过程都是在Vmware虚拟机下进行的


开启虚拟机的相关服务

右键点击-》我的电脑-》属性


以VMware开头的都是虚拟机的相关服务



打开虚拟机的Ubuntu 12.10系统

插入U盘

root@ubuntu:~# fdisk -l
Disk /dev/sda: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders, total 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00051606
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     9437183     4717568   83  Linux
/dev/sda2         9439230    10483711      522241    5  Extended
/dev/sda5         9439232    10483711      522240   82  Linux swap / Solaris
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2974a3af
Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     8390655     4194304   83  Linux
/dev/sdb2         8390656    14682111     3145728   83  Linux
/dev/sdb3        14682112    20971519     3144704    5  Extended
/dev/sdb5        14684160    18878463     2097152   83  Linux
Disk /dev/sdc: 1998 MB, 1998519808 bytes
62 heads, 62 sectors/track, 1015 cylinders, total 3903359 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a3bf2
Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *     2050048     3903358      926655+  83  Linux
/dev/sdc2            2048     1230847      614400   83  Linux
/dev/sdc3         1230848     2050047      409600   83  Linux
Partition table entries are not in disk order

这里因为系统有两块硬盘了,所以U盘识别出来是sdc



对U盘重新分区

分区方案:就一个分区sdc1,类型vfat


删除U盘旧分区

root@ubuntu:~# fdisk /dev/sdc
Command (m for help): d
Partition number (1-4): 1
Command (m for help): d
Partition number (1-4): 2
Command (m for help): d
Selected partition 3
Command (m for help): p
Disk /dev/sdc: 1998 MB, 1998519808 bytes
62 heads, 62 sectors/track, 1015 cylinders, total 3903359 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a3bf2
Device Boot      Start         End      Blocks   Id  System
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.


重新分区

root@ubuntu:~# fdisk /dev/sdc
Command (m for help): n
Partition type:
p   primary (0 primary, 0 extended, 4 free)
e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-3903358, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3903358, default 3903358):
Using default value 3903358
Command (m for help): a
Partition number (1-4): 1
Command (m for help): p
Disk /dev/sdc: 1998 MB, 1998519808 bytes
62 heads, 62 sectors/track, 1015 cylinders, total 3903359 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a3bf2
Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *        2048     3903358     1950655+  83  Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@ubuntu:~# partprobe
root@ubuntu:~# mkfs.vfat /dev/sdc1
mkfs.vfat 3.0.13 (30 Jun 2012)


创建U盘挂载目录

root@ubuntu:~# mkdir -p /mnt/u
root@ubuntu:~# mount /dev/sdc1 /mnt/u
root@ubuntu:~# df -Th | grep /sdc1
/dev/sdc1      vfat      1.9G  4.0K  1.9G   1% /mnt/u


创建Cnyunwei-X64-V11_base.iso放置目录和挂载目录

下载Cnyunwei-X64-V11_base.iso到/mnt/iso目录下

root@ubuntu:~# cp -rv /mnt/usb1/images /mnt/u/

`/mnt/usb1/images' -> `/mnt/u/images'

`/mnt/usb1/images/efiboot.img' -> `/mnt/u/images/efiboot.img'

`/mnt/usb1/images/efidisk.img' -> `/mnt/u/images/efidisk.img'

`/mnt/usb1/images/install.img' -> `/mnt/u/images/install.img'

`/mnt/usb1/images/pxeboot' -> `/mnt/u/images/pxeboot'

`/mnt/usb1/images/pxeboot/initrd.img' -> `/mnt/u/images/pxeboot/initrd.img'

`/mnt/usb1/images/pxeboot/TRANS.TBL' -> `/mnt/u/images/pxeboot/TRANS.TBL'

`/mnt/usb1/images/pxeboot/vmlinuz' -> `/mnt/u/images/pxeboot/vmlinuz'

`/mnt/usb1/images/TRANS.TBL' -> `/mnt/u/images/TRANS.TBL'

root@ubuntu:~# cp -rv /mnt/usb1/images /mnt/u/

`/mnt/usb1/images' -> `/mnt/u/images'

`/mnt/usb1/images/efiboot.img' -> `/mnt/u/images/efiboot.img'

`/mnt/usb1/images/efidisk.img' -> `/mnt/u/images/efidisk.img'

`/mnt/usb1/images/install.img' -> `/mnt/u/images/install.img'

`/mnt/usb1/images/pxeboot' -> `/mnt/u/images/pxeboot'

`/mnt/usb1/images/pxeboot/initrd.img' -> `/mnt/u/images/pxeboot/initrd.img'

`/mnt/usb1/images/pxeboot/TRANS.TBL' -> `/mnt/u/images/pxeboot/TRANS.TBL'

`/mnt/usb1/images/pxeboot/vmlinuz' -> `/mnt/u/images/pxeboot/vmlinuz'

`/mnt/usb1/images/TRANS.TBL' -> `/mnt/u/images/TRANS.TBL'

root@ubuntu:~# mkdir -p /mnt/{iso,usb1}
root@ubuntu:~# mount -o loop /mnt/iso/Cnyunwei-X64-V11_base.iso /mnt/usb1
mount: warning: /mnt/usb1 seems to be mounted read-only.


Cnyunwei-X64-V11_base.iso中的isolinux目录复制到U盘/dev/sdc1中并改名为syslinux目录,然后重命名isolinux.cfg文件为syslinux.cfg

root@ubuntu:~# cp -rv /mnt/usb1/isolinux /mnt/u/syslinux
`/mnt/usb1/isolinux' -> `/mnt/u/syslinux'
`/mnt/usb1/isolinux/boot.cat' -> `/mnt/u/syslinux/boot.cat'
`/mnt/usb1/isolinux/boot.msg' -> `/mnt/u/syslinux/boot.msg'
`/mnt/usb1/isolinux/cnc-cn-ks.cfg' -> `/mnt/u/syslinux/cnc-cn-ks.cfg'
`/mnt/usb1/isolinux/cnc-en-ks.cfg' -> `/mnt/u/syslinux/cnc-en-ks.cfg'
`/mnt/usb1/isolinux/cnm-cn-ks.cfg' -> `/mnt/u/syslinux/cnm-cn-ks.cfg'
`/mnt/usb1/isolinux/cnm-en-ks.cfg' -> `/mnt/u/syslinux/cnm-en-ks.cfg'
`/mnt/usb1/isolinux/cnn-cn-ks.cfg' -> `/mnt/u/syslinux/cnn-cn-ks.cfg'
`/mnt/usb1/isolinux/cnn-en-ks.cfg' -> `/mnt/u/syslinux/cnn-en-ks.cfg'
`/mnt/usb1/isolinux/grub.conf' -> `/mnt/u/syslinux/grub.conf'
`/mnt/usb1/isolinux/initrd.img' -> `/mnt/u/syslinux/initrd.img'
`/mnt/usb1/isolinux/isolinux.bin' -> `/mnt/u/syslinux/isolinux.bin'
`/mnt/usb1/isolinux/isolinux.cfg' -> `/mnt/u/syslinux/isolinux.cfg'
`/mnt/usb1/isolinux/memtest' -> `/mnt/u/syslinux/memtest'
`/mnt/usb1/isolinux/splash.jpg' -> `/mnt/u/syslinux/splash.jpg'
`/mnt/usb1/isolinux/TRANS.TBL' -> `/mnt/u/syslinux/TRANS.TBL'
`/mnt/usb1/isolinux/vesamenu.c32' -> `/mnt/u/syslinux/vesamenu.c32'
`/mnt/usb1/isolinux/vmlinuz' -> `/mnt/u/syslinux/vmlinuz'
root@ubuntu:~# mv /mnt/u/syslinux/isolinux.cfg /mnt/u/syslinux/syslinux.cfg


Cnyunwei-X64-V11_base.iso中的image目录复制到U盘/dev/sdc1中

root@ubuntu:~# cp -rv /mnt/usb1/images /mnt/u/
`/mnt/usb1/images' -> `/mnt/u/images'
`/mnt/usb1/images/efiboot.img' -> `/mnt/u/images/efiboot.img'
`/mnt/usb1/images/efidisk.img' -> `/mnt/u/images/efidisk.img'
`/mnt/usb1/images/install.img' -> `/mnt/u/images/install.img'
`/mnt/usb1/images/pxeboot' -> `/mnt/u/images/pxeboot'
`/mnt/usb1/images/pxeboot/initrd.img' -> `/mnt/u/images/pxeboot/initrd.img'
`/mnt/usb1/images/pxeboot/TRANS.TBL' -> `/mnt/u/images/pxeboot/TRANS.TBL'
`/mnt/usb1/images/pxeboot/vmlinuz' -> `/mnt/u/images/pxeboot/vmlinuz'
`/mnt/usb1/images/TRANS.TBL' -> `/mnt/u/images/TRANS.TBL'


使用syslinux工具将U盘的/dev/sdc1分区制作成启动盘

apt-get install syslinux

root@ubuntu:~# syslinux --stupid /dev/sdc1

成功会有ldlinux.sys*文件生成

root@ubuntu:~# ll /mnt/u | grep ldlinux*
-r-xr-xr-x 1 root root     32256 Aug 11 18:58 ldlinux.sys*


如果在windows系统下,也可以这样制作成启动盘

需要下载syslinux工具写入mbr引导信息与ldlinux.sys引导文件(系统隐藏)在fat分区上。

win7必须管理员权限下执行cmd操作才能成功,64位系统选择win64目录的工具。

syslinux下载地址: http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.04.zip

cmd命令下
d:
cd \syslinux-4.04\win32
syslinux.exe -a -m i:


Cnyunwei-X64-V11_base.iso放到/dev/sdc1根目录下

root@ubuntu:~# umount /mnt/usb1
root@ubuntu:~# cp /mnt/iso/Cnyunwei-X64-V11_base.iso /mnt/u/



接下来的操作可以在windows系统下进行

使用notepad++打开syslinux目录下的syslinux.cfg

ks=cdrom:/isolinux 全部改为ks=hd:sdb1:/syslinux

现在用的是U盘安装,不是光盘安装,sdb1要根据实际情况改变(假设系统只有一块硬盘的情况下)

保存退出!


接下来修改这几个ks配置文件


cnc-en-ks.cfg配置文件修改:(其它配置文件类似)

#Cnyunwei-Cacti+Nagios+Centreon

install

#选择从硬盘安装,安装介质位置为U盘,iso镜像在根目录下

harddrive --partition=/dev/sdb1 --dir=/

lang zh_CN.UTF-8

keyboard us

skipx

network --onboot yes --device eth0 --bootproto static --ip 192.168.0.88 --netmask 255.255.255.0 --gateway 192.168.0.253 --noipv6 --nameserver 8.8.8.8 --hostname Cnyunwei.CNC

rootpw  yao

firewall --enabled --port=22:tcp --port=25:tcp --port=161:udp --port=80:tcp --port=443:tcp --port=514:udp --port=10000:tcp --port=5666:tcp  --port=12489:tcp

authconfig --enableshadow --enablemd5

selinux --disable

timezone --utc Asia/Chongqing

#bootloader --location=mbr

bootloader --location=mbr --driveorder=sda --append=" rhgb crashkernel=auto quiet"


zerombr yes

#clearpart --all --initlabel

clearpart --all --drives=sda   ##分区选择清除,不然会提示您手动选择

part /boot --fstype ext4 --size=512 --asprimary

part swap --size=4096

part / --fstype ext4 --size=1 --grow


#reboot --eject


%packages

@core

httpd

perl

perl-DBD-MySQL

perl-DBI

perl-libs

mysql

mysql-server

mysql-devel

lm_sensors

net-snmp

net-snmp-devel

net-snmp-utils

net-snmp-perl

net-snmp-python

php

php-mysql

php-gd

php-snmp

php-pear

php-php-gettext

php-pdo

php-cli

php-common

php-devel

php-ldap

php-mbstring

php-mcrypt

php-mssql

php-xml

phpMyAdmin

php-pear-DB

ttmkfdir

xorg-x11-fonts-Type1

perl-Net-SNMP

perl-Time-HiRes

perl-libwww-perl

ruby

gettext

ntp

ntpdate

man

zip

unzip

compat-readline5

system-config-network-tui

gd

mailx

fping

mod_ssl

openssh-clients

sysstat

sqlite-devel

bc

mod_python

rsyslog-mysql

xinetd

wget

fontconfig-devel

libpng-devel

gd-devel

perl-GD

perl-Config-IniFiles

perl-ExtUtils-MakeMaker

rrdtool

dejavu-fonts-common

dejavu-lgc-sans-mono-fonts

dejavu-sans-mono-fonts

krb5-libs-1.10.3-10.el6.i686

libgcc-4.4.7-3.el6.i686

zlib-1.2.3-29.el6.i686

perl-Socket6

perl-IO-Socket-INET6

perl-Net-DNS

perl-XML-LibXML


#------- Cacti Config ---------

%post --nochroot

mkdir -p /mnt/sysimage/tmp/cacti

mkdir -p /mnt/{t1,t2}

mount /dev/sdb1 /mnt/t1

mount -o loop /mnt/t1/$(ls /mnt/t1/ | grep "^Cnyunwei.*\.iso$") /mnt/t2

cp /mnt/t2/Packages/cnyunwei.com.zip /mnt/sysimage/tmp/cacti

cp /mnt/t2/Packages/cnc.zip /mnt/sysimage/tmp/cacti

cp /mnt/t2/Packages/pear.zip /mnt/sysimage/tmp/cacti

cp /mnt/t2/Packages/cnc-en.x /mnt/sysimage/tmp/cacti

%post

/tmp/cacti/cnc-en.x

%end


mount光盘资源:
     在没完成安装前,光盘的资源是挂在/mnt/source下的,完成安装后系统自动将/mnt/source umount并删掉了/mnt/source


在包都装完后执行后续的自定义脚本“%post --nochroot”和“%post”所在的工作不一样。前者是类似于rescue模式的/目录,后者是系统的/root目录。


rescue模式:系统的/root是在此模式下的/mnt/sysimage/root下。

更具体的kickstart参数介绍,请参考:http://pan.baidu.com/share/link?shareid=3993772748&uk=2617460561 kickstart.pdf


到此,U盘安装制作完毕,接下来就是在VMware虚拟机下测试了!



参考文献:

http://redking.blog.51cto.com/27212/1216136redking 的BLOG 制作CentOS 6.4 U盘启动安装盘

http://linux.chinaitlab.com/set/915580_2.html U盘无人值守安装fedora 13方法

http://blog.chinaunix.net/uid-23896361-id-106996.html kerecsen 制作kickstart安装光盘





你可能感兴趣的:(syslinux)