Ubuntu14.04下定制Ubuntu的ISO镜像

来源:互联网 发布:虚拟现实与大数据 编辑:程序博客网 时间:2024/05/17 04:37

Ubuntu14.04下定制Ubuntu的ISO镜像

1. Ubuntu的ISO镜像的安装过程

1. BIOS加电自检

2. 运行isolinux目录下面的isolinux.bin文件,这个isolinux.bin文件根据isolinux.cfg文件的选项来加载内核vmlinuz和initrd.img文件,

     initrd.img文件会在内存中生成一个虚拟的linux操作系统,为安装过程提供一个安装环境。

3. 进行系统的安装

 

2.修改Ubuntu安装执行过程

通过修改isolinux\isolinux.cfg文件来修改相关的启动选项和执行过程;ubuntu-14.04-server-amd64默认的isolinux.cfg文件的内容如下:

# D-I config version 2.0include menu.cfgdefault vesamenu.c32prompt 0timeout 0ui gfxboot bootlogo


include menu.cfg   #isolinux.cfg引用isolinux目录下的menu.cfg文件

default vesamenu.c32  # 默认加载vesamenu.c32菜单模块

prompt 0  #设定默认行为模式(交互模式和非交互模式)

timeout 0 #等待时间(30s设置为300

ui gfxboot bootlogo  #指定了启动时的图形界面

 

menu.cfg文件内容如下:

menu hshift 13menu width 49menu margin 8menu title Installer boot menuinclude stdmenu.cfginclude txt.cfginclude gtk.cfgmenu begin advancedmenu title Advanced optionsinclude stdmenu.cfglabel mainmenumenu label ^Back..menu exitinclude adtxt.cfginclude adgtk.cfgmenu endlabel helpmenu label ^Helptext help   Display help screens; type 'menu' at boot prompt to return to this menuendtextconfig prompt.cfg

  其中txt.cfg文件指定系统启动时的引导选项,可以通过修改该文件来添加或修改引导选项,txt.cfg的文件内容如下:

default install_openstack_controller_nodelabel install_openstack_controller_node  menu label ^Install OpenStack Controller Node  kernel /install/vmlinuz  append  file=/cdrom/preseed/openstack_controller_node.seed vga=788 initrd=/install/initrd.gz biosdevname=0 netcfg/choose_interface=auto boot=install debian-installer/locale=en_US console-setup/ask_detect=false keyboard-configuration/layoutcode=us automatic-ubiquity quiet --label cloud  menu label ^Multiple server install with MAAS  kernel /install/vmlinuz  append   modules=maas-enlist-udeb vga=788 initrd=/install/initrd.gz quiet --label check  menu label ^Check disc for defects  kernel /install/vmlinuz  append   MENU=/bin/cdrom-checker-menu vga=788 initrd=/install/initrd.gz quiet --label memtest  menu label Test ^memory  kernel /install/mt86pluslabel hd  menu label ^Boot from first hard disk  localboot 0x80

default install  #默认的引导选项为install

label 是指Linux系统启动时的引导选项;menu label项是引导选项显示的内容;kernel项指定了启动时的内核文件路径;append项中file指定预制文件的路径,vga指定分辨率,initrd 指定 initrd 的文件路径,其余的内核参数还可能有很多,Linux内核中启动的所有参数,在这里都是可以加入的。


在这个文件中可以修改相关选项来定制ISO安装镜像的相关的安装操作,可以修改预制seed文件,也可以添加相关的内核启动参数。

seed文件格式如下所示:

# Suggest LVM by default.d-ipartman-auto/init_automatically_partitionstring some_device_lvmd-ipartman-auto/init_automatically_partitionseen false# Install the Ubuntu Server seed.taskseltasksel/force-tasksstring server# Only install basic language packs. Let tasksel ask about tasks.d-ipkgsel/language-pack-patternsstring# No language support packages.d-ipkgsel/install-language-supportboolean false# Only ask the UTC question if there are other operating systems installed.d-iclock-setup/utc-autoboolean true# Verbose output and no boot splash screen.d-idebian-installer/quietboolean falsed-idebian-installer/splashboolean false# Install the debconf oem-config frontend (if in OEM mode).d-ioem-config-udeb/frontendstring debconf# Wait for two seconds in grubd-igrub-installer/timeoutstring 2# Add the network and tasks oem-config steps by default.oem-configoem-config/stepsmultiselect language, timezone, keyboard, user, network, tasks


可以在该文件中添加或修改相关内容来控制安装过程中的相关操作,实现自动安装。另外在文件末尾可以添加如下语句:

d-i  preseed/late_command string 命令

其中命令是命令行下可以执行的任何命令,多条命令可以用分号隔开。

        这里就可以将ISO文件中的openstack的安装包拷贝到系统中,然后编写openstack系统的安装脚本,并将脚本的执行语句写到/etc/init.d/rc.local文件中,使得在操作系统安装过程中可以自动安装和配置openstack,命令如下:

d-ipreseed/late_command string cp -R /cdrom/openstack /target/opt/;echo "if [ !-f /opt/openstack/install.log ];then">> /target/etc/init.d/rc.local;echo "   /bin/bash /opt/openstack/allinoneinstall-ubuntu.sh>>/opt/openstack/install.log">>/target/etc/init.d/rc.local;echo"fi" >>/target/etc/init.d/rc.local


0 0
原创粉丝点击