0%

ubuntu-12.04-kickstart-usb

基于Ubuntu 12.04镜像测试,主要解决装机规范问题,减少沟通成本

首先准备好官方Ubuntu 12.04 Server 64bit 镜像

1
wget http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso

工作目录准备

1
2
3
mkdir ubuntu_12.04_install
mount -o loop ubuntu-12.04.5-server-amd64.iso /mnt/cd
cp -rT /mnt/cd/* ubuntu_12.04_install/

kickstart 配置,按需调整相关配置即可

lang配置(可选),跳过安装时language选择

1
echo en >> ubuntu_12.04_install/isolinux/lang

ubuntu_12.04_install/ks.cfg

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#Generated by Kickstart Configurator
#platform=AMD64 or Intel EM64T

#System language
lang en_US
#Language modules to install
langsupport en_US
#System keyboard
keyboard us
#System mouse
mouse
#System timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $1$14WcoQJN$KJGncCOpznGPzdRIBv39B/
#Initial user
user --disabled
#Reboot after installation
reboot
#Use text mode install
text
#Install OS instead of upgrade
install
#Use CDROM installation media
cdrom
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr yes
#Partition clearing information
#clearpart --all --initlabel
clearpart --drives=sda --all --initlabel
# sda
ignoredisk --only-use=sda
#Disk partitioning information
#part / --fstype ext3 --size 3600 --asprimary --ondisk=LABEL="/"
#part / --fstype ext3 --size 3600 --asprimary --label="/"
part / --fstype ext3 --size 3600 --asprimary
part pv.01 --size=1 --grow --asprimary
volgroup vg_data pv.01
logvol swap --fstype swap --vgname=vg_data --size=4096 --name=lv_swap
logvol /data --fstype ext4 --vgname=vg_data --size=1 --grow --name=lv_data
#System authorization infomation
auth --useshadow --enablemd5
#Network information
network --bootproto=static --device=eth0 --ip=192.168.168.100 --netmask=255.255.255.0
network --bootproto=static --device=eth1 --ip=1.1.1.2 --netmask=255.255.255.0 --gateway=1.1.1.1 --nameserver=114.114.114.114
#Firewall configuratio
firewall --disabled
#Do not configure the X Window System
skipx
#Install packages
%packages
openssh-server
#post command
%post
echo "
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.168.100/24
up ip -4 route add to 192.168.0.0/16 via 192.168.0.1

auto eth1
iface eth1 inet static
address 1.1.1.2/24
gateway 1.1.1.1" > /etc/network/interfaces

sed -i "s/sleep 20/sleep 5/;s/sleep 40/sleep 1/;s/sleep 59/sleep 1/;" /etc/init/failsafe.conf
tune2fs /dev/sda1 -L /
tune2fs /dev/mapper/vg_data-lv_data -L /data
swapoff /dev/mapper/vg_data-lv_swap
mkswap /dev/mapper/vg_data-lv_swap -L swap

新增安装选项并指定ks文件

ubuntu_12.04_install/isolinux/txt.cfg

1
2
3
4
5
default autoinstall
label autoinstall
menu label ^Auto-Install Ubuntu Server
kernel /install/vmlinuz
append file=/cdrom/preseed/ubuntu-server.seed vga=788 initrd=/install/initrd.gz ks=cdrom:/ks.cfg quiet --

mkisofs 生成iso文件

1
mkisofs -o output.iso -R -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 4 -hide-rr-moved ubuntu_12.04_install

root密码生成方法

1
2
3
grub-crypt --md5
grub-crypt --sha-256
grub-crypt --sha-512

基于密码生成算法按需调整authconfig选项即可

1
2
3
authconfig --enableshadow --enablemd5
authconfig --enableshadow --passalgo=sha256
authconfig --enableshadow --passalgo=sha512

part --label 设置

通过%post 方式实现