使用preseed脚本安装Ubuntu 14.04


使用PXE来安装Linux系统是系统集成中最基础的工作,同时也是最容易被忽略的,平时一旦系统安装好之后,很少再管这部分。

关于PXE的集成工具,现在已经很多了,如cobbler。

但为了减少在这方面投入的时间,我们依然采用DHCP+TFTP+HTTP的方式来安装Linux系统。

PXE服务器是基于Ubuntu12.04-server-amd64配置的,CentOS系统使用kickstart脚本安装,Ubuntu系统采用preseed脚本安装。

关于CentOS的kickstart脚本,可以通过kickstart图形界面直接配置生成,此处不做具体介绍。

对于Ubuntu系统的preseed脚本,一直是使用人工配置。

1.使用本地HTTP proxy代替公共的HTTP proxy

之前使用preseed脚本安装Ubuntu 12.04过程中,为了方面安装都采用公共的HTTP的mirror(cn.archive.ubuntu.com)。

preseed脚本中关于mirror部分配置:

d-i mirror/protocol string http
d-i mirror/http/hostname string cn.archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string

今天忽然想到使用本地代理,于是将Ubuntu12.04.4的preseed文件配置至本地HTTP服务器。

d-i mirror/country string manual
d-i mirror/protocol string http
d-i mirror/http/hostname string 172.16.112.133  #HTTP服务器
d-i mirror/http/directory string /ubuntu12.04.4  #ISO目录
d-i mirror/http/proxy string http://172.16.112.133/#proxy地址

使用本地HTTP服务器后,安装过程中,报错为:

ubuntu 12.04 preseed debootstrap warning。

http://172.16.112.133/ubuntu12.04.4/dists/precise/main/binary-amd64/Packages.gz was corrupt。

此警告可忽略,直接点击continue可继续安装。

经过Google,有网友提出使用alternate版本的ISO安装可以回避这个问题,但经过实验使用alternate版本的ISO文件安装依然会报警。

经实验,从cn.archive.ubuntu.com下载Package.gz文件至HTTP服务器,依然会出现警告。

2.配置安装Ubuntu14.04的preseed脚本

ubuntu14.04使用preseed脚本安装会出现一些变化。

1.安装过程中,需添加自动处理脚本先卸载掉原有磁盘:

### Unmount the /dev/sda1.
d-i preseed/early_command string umount /media

2. 在Ubuntu14.04系统安装过程中,需处理live-installer的问题

在ubuntu12.10以后的版本中,当install base system 时,会出现一下错误:

main-menu[954]: info:Menu item ‘live-installer’ selected

base-installer: error: cloud not find any live images.

需在preseed脚本中添加live-installer处理:

###After the Ubuntu12.10, preseedfile need live-installer.

d-i live-installer/net-image string http://172.16.112.133/ubuntu14.04.2/install/filesystem.squashfs

经过以上处理,安装ubuntu-14.04.2-server-amd64系统使用的preseed脚本为:

### Localization.
d-i auto-install/enable boolean true
d-i debian-installer/locale string en_US
d-i localechooser/translation/warn-light boolean true
d-i localechooser/translation/warn-severe boolean true
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string us

### Net interface setting.
d-i netcfg/choose_interface select eth0
d-i netcfg/dhcp_timeout string 60
d-i netcfg/get_hostname string nova
d-i netcfg/get_domain string xinlixun.cn

### Mirror setting. use the local proxy.
d-i mirror/country string manual
d-i mirror/protocol string http
d-i mirror/http/hostname string 172.16.112.133
d-i mirror/http/directory string /ubuntu14.04.2/
d-i mirror/http/proxy string http://172.16.112.133/

### Clock and timezone setting. use local ntp.
d-i clock-setup/utc boolean true
d-i time/zone string Asia/Chongqing
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server 172.16.112.133

### Partioning setting.
#d-i partman-auto/disk string /dev/sda
d-i partman-auto-lvm/guided_size string max
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/method string lvm
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/confirm_write_new_label boolean true

### Account setting.
d-i passwd/root-login boolean false
d-i passwd/user-fullname string test
d-i passwd/username string test
d-i passwd/user-password password test123
d-i passwd/user-password-again password test123
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false

###After the Ubuntu12.10, preseedfile need live-installer.
d-i live-installer/net-image string http://172.16.112.133/ubuntu14.04.2/install/filesystem.squashfs

### Package selection.
d-i pkgsel/include string openssh-server
d-i pkgsel/upgrade select none
d-i pkgsel/update-policy select none
tasksel tasksel/first multiselect standard, ubuntu-server

### Boot loader installation.
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true

### finishing up the installation.
d-i finish-install/reboot_in_progress note

### Running custom commands.
d-i preseed/late_command string echo "hello" >> /root/test

### Unmount the /dev/sda1.
d-i preseed/early_command string umount /media

Ubuntu 14.04 下载、安装、配置的相关知识

Ubuntu 14.04系统下载地址:

Windows 7下硬盘安装Ubuntu 14.04图文教程

相关内容