歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 使用preseed腳本安裝Ubuntu 14.04

使用preseed腳本安裝Ubuntu 14.04

日期:2017/2/28 13:59:01   编辑:Linux教程

使用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 下載、安裝、配置的相關知識 http://www.linuxidc.com/Linux/2014-04/100370.htm

Ubuntu 14.04系統下載地址:http://www.linuxidc.com/Linux/2014-04/100352.htm

Windows 7下硬盤安裝Ubuntu 14.04圖文教程 http://www.linuxidc.com/Linux/2014-04/100983.htm

更多Ubuntu相關信息見Ubuntu 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=2

Copyright © Linux教程網 All Rights Reserved