ubuntu preseed 安装文档

来源:互联网 发布:spss数据分析难吗 编辑:程序博客网 时间:2024/06/07 00:30

#url:主要参考
# 1: https://wiki.ubuntu.com/Enterprise/WorkstationAutoinstallPreseed
# 2:https://wiki.ubuntu.com/Enterprise/WorkstationAutoinstallScripts
# 3:https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt
# 4:https://wiki.ubuntu.com/QATeam/AutomatedTesting/UbuntuTestAutomationHarness/HowToUseCustomPreseeds/default-preseed.cfg
# 5:https://www.debian.org/releases/wheezy/example-preseed.txt
# 6:https://help.ubuntu.com/14.04/installation-guide/i386/apb.html
# 7:http://www.startos.com/zhuanti/zt02/2010/1111/9391.html
# 8:https://help.ubuntu.com/lts/installation-guide/i386/ch04s06.html#preseed(然后它)
# 9:https://www.debian.org/releases/stable/i386/ch06s03.html.zh-cn(第一重要,有助于理解整个流程)

preseed主要包括以下内容
1、本地化
2、网络设置
3、镜像设置
4、账号设置
5、时钟与时区设置
6、分区
7、基本系统安装
8、设置apt
9、选择软件包
10、安装bootloader
11、完成安装
12、预置其他的软件包
#书写perseed时需要注意的点
#preconfiguration 文件格式如下
#<owner> <question name> <question type> <value>
#确保type与value之间只有一个空格符或者tab
#多行的话最好是在question name后添加\,而不应该在type与value之间
#对于debconf 变量,owner前需要加d-i
#其二,可以通过debconf-utils软件包里面的debconf-get-selections导出debconf数据库和安装程序的cdebconf数据库到另一文件
#debconf-get-selections --installer > file
#debconf-get-selections >> file
#本地化 设置 language country and locale
#如果预置locale为en_NL在安装后系统默认的locale将是en_US.UTF-8,如果想要使用en_GB.UTF-8,该值需要分别进行预置
#d-i debian-installer/language srtring en
#d-i debian-installer/country string CH
d-i debain-install/locale string zh_CN.UTF-8
#键盘配置,安装时只提供基本keymap,高级的需要在安装好的系统下才能使用,使用dpkg-reconfigure keyboard-configuration配置
d-i keyboard-configuration/xkb-keymap select us
#d-i keyboard-configuration/toggle select No toggling
#网络设置
#如果需要禁用网络,则如下
#d-i netcfg/enable boolean false
#若网络可用,则netcfg将选择一网口,如果需要跳过显示选择网卡列表,则设置自动选择
#d-i netcfg/choose_interface select auto
#如果想直接指定某一网口,则设置如下
#d-i netcfg/choose_interface select eth0
#设置链接网口的检测时间,默认时间时3秒
#d-i netcfg/link_wait_timeout string 10
#如果DHCP服务器延迟较高,可以将安装过程中DHCP设置时延变长
#d-i netcfg/dhcp_timeout string 45
#如果需要手动配置网络,则如下配置
#d-i netcfg/disable_autoconfig boolean true
#d-i netcfg/dhcp_failed note
#d-i netcfg/dhcp_options select Configure network manually
#d-i netcfg/get_nameservers string 192.168.1.1
#d-i netcfg/get_ipaddress string 192.168.1.42
#d-i netcfg/get_netmask string 255.255.255.0
#d-i netcfg/get_gateway string 192.168.1.1
#d-i netcfg/confirm_static boolean true
#设置hostname以及domain避免问答
#d-i netcfg/get_hostname string unassigned-hostname
#d-i netcfg/get_domain string unassigned-domain
#手动预置hostname
#d-i netcfg/hostname string abc
#non-free需要网络,可以配置其直接连接网络而无需询问
#d-i hw-detect/load_firmware boolean true
#需要注意的是,如果netcfg/get_netmask没有预置,netcfg将自动侦测掩码,这种情况下,为了自动安装,变量需要标记为seen,
#同样,如果netcfg/get_gateway没有设置,netcfg将自动选择一个合适的地址。特殊情况下,可以设置netcfg/get_gateway
#为none确定不使用网关
#网络控制台
#如果需要通过SSH进行远程安装,就需要确保网络console
#d-i anna/choose_modules string network-console
#d-i network-console/authorized_keys_url string http://10.133.5.100/ubuntu/openssh-key
#d-i network-console/password password r00tme
#d-i network-console/password-again password r00tme
#镜像设置
#镜像可用于下载安装程序的额外组件、安装基本系统以及所安装的系统建立/etc/apt/source.list
#参数mirror/suite决定了安装号的系统使用的套件。
#参数mirror/udev/suite决定安装程序使用的额外组件的套件。它只在组件通过网络下载病与安装时使用的initrd建立套件相匹配时才有效。
#通常安装程序会自动安装病使用正确的值,而无需手动设置
#如果选择FTP,则mirror/country无需设置
#d-i mirror/protocol string ftp 如果不指出所用协议,则默认为http
d-i mirror/country string manual
d-i mirror/http/hostname string http.us.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
#安装套件
#d-i mirror/suite string testing
#d-i mirror/udev/suite string testing

#账号设置
#root账号的密码和普通用户的用户名和密码都可以预置。可以使用纯文本或者MD5
#如果需要跳过root用户的创建则
#d-i passwd/root-login boolean false
#同样也可以跳过创建普通用户
#d-i passwd/make-user boolean false
#设置root密码,负责为空
#d-i passwd/root-password password 123456st
#d-i passwd/root-password-again password 123456st
#同样可以用加密的MD5哈希
#d-i passwd/root-password-crtpted password [MD5 hash]
#创建普通账户
#d-i passwd/user-fullname string Debian User
#d-i passwd/username string debian
# 普通用户密码
#d-i passwd/user-password password insecure
#d-i passwd/user-password-again password insecure
# 或者用MD5
#d-i passwd/user-password-crypted password [MD5 hash]
# 为第一个用户以指定UID进行创建
#d-i passwd/user-uid string 1010
# 将第一用户加入某一group
#d-i passwd/user-default-groups string audio cdrom video
passwd/root-password-crypted 和 passwd/user-password-crypted 值可以使用 “!” 作为他们的预置值。这种情况下,对应的帐号关闭。
它常用于 root 帐号,用其他替代方法允许管理或 root 登录(例如使用 SSH key 认证或 sudo).
下面的命令可用于生成密码的 MD5 值。
mkpasswd -m sha-512

#时钟与时区设置
#设置硬件时钟是否为UTC
d-i clock-setup/utc boolean true
#设置为某一时区
# 可以参照/usr/share/zoneinfo里面的值
d-i time/zone string Asia/Shanghai
#设置在安装过程中是否以NTP为时间基准
d-i clock-setup/ntp boolean true
# 使用的NTP服务器
#d-i clock-setup/ntp-server string xxx
#分区设置
分区可以参考一下以下资料
#http://www.cnblogs.com/silenceli/p/3472222.html
#https://wiki.ubuntu.com/Enterprise/WorkstationAutoinstallPreseed
#使用预置进行硬盘分区受限于 partman-auto 提供的支持。您可以选择使用磁盘上已有的空闲分区或者整个磁盘。磁盘的布局将取决于所使用的预定义方案,用户自定义的方案文件或预置文件包含的方案。
#已经支持包括 RAID、LVM 和加密高级分区设置的预置,但对于非预置安装的分区仍然弹性不足。
#下面的例子仅提供了使用方案的最基本信息。详细的内容清参考文件 partman-auto-recipe.txt 和 partman-auto-raid-recipe.txt,它们含在 debian-installer 软件包里。这两个文件也可以从 debian-installer source repository##获取。注意不同发布版支持的功能会有所改变。
#http://anonscm.debian.org/gitweb/?p=d-i/debian-installer.git;a=tree;f=doc/devel
# If the system has free space you can choose to only partition that space.
# This is only honoured if partman-auto/method (below) is not set.
#d-i partman-auto/init_automatically_partition select biggest_free

# Alternatively, you may specify a disk to partition. If the system has only
# one disk the installer will default to using that, but otherwise the device
# name must be given in traditional, non-devfs format (so e.g. /dev/hda or
# /dev/sda, and not e.g. /dev/discs/disc0/disc).
# For example, to use the first SCSI/SATA hard disk:
#d-i partman-auto/disk string /dev/sda
# In addition, you'll need to specify the method to use.
# The presently available methods are:
# - regular: use the usual partition types for your architecture
# - lvm: use LVM to partition the disk
# - crypto: use LVM within an encrypted partition
d-i partman-auto/method string lvm

# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. This can be preseeded away...
d-i partman-lvm/device_remove_lvm boolean true
# The same applies to pre-existing software RAID array:
d-i partman-md/device_remove_md boolean true
# And the same goes for the confirmation to write the lvm partitions.
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true

# You can choose one of the three predefined partitioning recipes:
# - atomic: all files in one partition
# - home: separate /home partition
# - multi: separate /home, /usr, /var, and /tmp partitions
d-i partman-auto/choose_recipe select atomic

# Or provide a recipe of your own...
# If you have a way to get a recipe file into the d-i environment, you can
# just point at it.
#d-i partman-auto/expert_recipe_file string /hd-media/recipe

# If not, you can put an entire recipe into the preconfiguration file in one
# (logical) line. This example creates a small /boot partition, suitable
# swap, and uses the rest of the space for the root partition:
#d-i partman-auto/expert_recipe string \
# boot-root :: \
# 40 50 100 ext3 \
# $primary{ } $bootable{ } \
# method{ format } format{ } \
# use_filesystem{ } filesystem{ ext3 } \
# mountpoint{ /boot } \
# . \
# 500 10000 1000000000 ext3 \
# method{ format } format{ } \
# use_filesystem{ } filesystem{ ext3 } \
# mountpoint{ / } \
# . \
# 64 512 300% linux-swap \
# method{ swap } format{ } \
# .

# The full recipe format is documented in the file partman-auto-recipe.txt
# included in the 'debian-installer' package or available from D-I source
# repository. This also documents how to specify settings such as file
# system labels, volume group names and which physical devices to include
# in a volume group.

# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
#其他分区方式可以查看
#https://www.debian.org/releases/stable/i386/apbs04.html.zh-cn#ftn.idp56652848

#分区挂载控制
#文件系统一般使用 UUID 作为关键字挂载; 这使得在设备名变更的情况下仍然可以正常挂载。UUID
#本身很长不容易阅读,因此,安装程序也可以依照您的意愿使用传统设备名或者指定标签(label)挂载文件系统。假如安装程序使用标签方式,那些没有标签
#的文件系统仍然使用 UUID 方式挂载。
#具有固定名称的设备,比如 LVM 逻辑卷,将继续使用它们自己的名字而不是 UUID 方式挂载。
#传统设备名会根据内核在引导时发现的次序进行调整,这将导致挂载错误的文件系统。与此类似,假如您插入一个新磁盘或 USB 设备,标签也可能有冲突发生。这样系统启动后会出现一些随机的情况。
# The default is to mount by UUID, but you can also choose "traditional" to
# use traditional device names, or "label" to try filesystem labels before
# falling back to UUIDs.
#d-i partman/mount_style select uuid
#基本系统的安装
#本阶段的安装并没有多少东西需要预置。仅有一个与内核安装相关的问题。
#配置apt使得其不安装默认推荐软件包,这将致使系统不完整,非专业人士不推荐
#内核镜像安装,none将致使其不安装
#d-i base-installer/kernel/image string linux-generic
#设置apt
#设置 /etc/apt/sources.list 和其他的基本配置选项,将自动地基于您使用的安装方式以及前面问题的回答。您也可以选择性地安装其他(或本地)的仓库
# 可以选择安装 non-free和 contrib 软件
#d-i apt-setup/non-free boolean true
#d-i apt-setup/contrib boolean true
# 配置是否使用网络镜像
#d-i apt-setup/use_mirror boolean false
# 定义使用镜像
#d-i apt-setup/services-select multiselect security
#d-i apt-setup/security_host string security.ubuntu.com
#d-i apt-setup/security_path string /ubuntu
# 另外的repo local[0-9] 可用
#d-i apt-setup/local0/repository string \
# http://local.server/debian stable main
#d-i apt-setup/local0/comment string local server
# Enable deb-src lines
#d-i apt-setup/local0/source boolean true
# URL to the public key of the local repository; you must provide a key or
# apt will complain about the unauthenticated repository and so the
# sources.list line will be left commented out
#d-i apt-setup/local0/key string http://local.server/key
# 无需key认证
#d-i debian-installer/allow_unauthenticated boolean true
#选择软件包
#主要看tasksel所包含的软件集
#如果打算安装一些安装任务之外的独立软件包,可以使用参数pksel/includ,该参数的值可以用逗号或者空格分开的软件包列表,便于在内核命令行上使用

#tasksel tasksel/first multiselect standard, web-server, kde-desktop
# 另外一些packages
#d-i pkgsel/include string openssh-server build-essential
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
#d-i pkgsel/upgrade select none
# 安装反馈报告
#popularity-contest popularity-contest/participate boolean false
#安装bootloader
# Grub 时默认 boot loader (for x86).如果想使用lilo则
#d-i grub-installer/skip boolean true
# 跳过bootloader安装,则使用下面的
#d-i lilo-installer/skip boolean true
# 下述选项将使得GRUB自动安装到MBR,如果没侦测到OS
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true

# 如果想装到其他地方,而不是本地MBR
#d-i grub-installer/only_debian boolean false
#d-i grub-installer/with_other_os boolean false
#d-i grub-installer/bootdev string (hd0,1)
# To install grub to multiple disks:
#d-i grub-installer/bootdev string (hd0,1) (hd1,1) (hd2,1)
# To install to a particular device:
#d-i grub-installer/bootdev string /dev/sda
# 可选,设置grub密码
#d-i grub-installer/password password r00tme
#d-i grub-installer/password-again password r00tme
#MD5密码
#d-i grub-installer/password-crypted password [MD5 hash]
# Use the following option to add additional boot parameters for the
# installed system (if supported by the bootloader installer).
# Note: options passed to the installer will be added automatically.
#d-i debian-installer/add-kernel-opts string nousb
#完成安装
# 保持console有效
#d-i finish-install/keep-consoles boolean true
# 避免安装最后信息弹出
d-i finish-install/reboot_in_progress note
# 阻止CD弹出
#d-i cdrom-detect/eject boolean false
# 完成后shutdown,但不重启
#d-i debian-installer/exit/halt boolean true
# poweroff
#d-i debian-installer/exit/poweroff boolean true

#预置其他的软件包
# debconf-get-selections --installer
> file
# debconf-get-selections
>
> file

#安装过程中运行用户命令
#预置工具提供了一个非常强大和灵活的选项,可以在安装过程的一些环节运行命令或脚本。
# d-i preseeding is inherently not secure. Nothing in the installer checks
# for attempts at buffer overflows or other exploits of the values of a
# preconfiguration file like this one. Only use preconfiguration files from
# trusted locations! To drive that home, and because it's generally useful,
# here's a way to run any shell command you'd like inside the installer,
# automatically.

# preseed被读取之后,第一个命令将尽可能快的被执行#d-i preseed/early_command string anna-install some-udeb
# 开始分区开始前命令执行. It may be
# useful to apply dynamic partitioner preseeding that depends on the state
# of the disks (which may not be visible when preseed/early_command runs).
#d-i partman/early_command \
# string debconf-set partman-auto/disk "$(list-devices disk | head -n1)"
# 完成安装前命令执行 but when there is
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh
d-i preseed/late_command string \
in-target wget -O /root/desktop-bootstrap.sh "http://example.com/ubuntu-desktop-bootstrap.sh"; \
in-target chmod +x /root/desktop-bootstrap.sh; \
in-target /root/desktop-bootstrap.sh; \
cp /var/log/syslog /target/root/log/install-syslog;
# No boot splash screen.
#d-i debian-installer/splash boolean false

#预置文件链
#可以在一个预置文件里面包含另外的预置文件。这些文件里面的任何设置将覆盖前面加载的设置。有一种用法,例如,通用的网络设置放在一个文件,其他规格的设置放在另外的文件里面。
#d-i preseed/include string x.cfg
# The installer can optionally verify checksums of preconfiguration files
# before using them. Currently only md5sums are supported, list the md5sums
# in the same order as the list of files to include.
#d-i preseed/include/checksum string 5da499872becccfeda2c4872f9171c3d

# More flexibly, this runs a shell command and if it outputs the names of
# preconfiguration files, includes those files.
#d-i preseed/include_command \
# string if [ "`hostname`" = bob ]; then echo bob.cfg; fi

# Most flexibly of all, this downloads a program and runs it. The program
# can use commands such as debconf-set to manipulate the debconf database.
# More than one script can be listed, separated by spaces.
# Note that if the filenames are relative, they are taken from the same
# directory as the preconfiguration file that runs them.
#d-i preseed/run string foo.sh

查看原文:http://www.zoues.com/index.php/2015/09/13/ubuntu-preseed/

0 0