安装linux的时候需要人机交互,如果一次安装几台那就要耗费很多精力,莫不如把每次要做的设置写在配置文件里,一键安装,省时省力。
Here we only introduce the use of CD-ROM for automatic installation.
Unattended installation The first thing we think about is kickstart software, so what is kickstart?
Kickstart is an unattended installation method. It works by documenting typical parameters that require manual intervention during the installation process and generating a file named Ks.cfg. If you have to fill in the parameters during the installation process (not limited to the machine that generated the Kickstart installation files), the installer will first look for the files generated by the kickstart, and if the appropriate parameters are found, use the found parameters; Need to be manually intervened by the installer. So, if the kickstart file covers all the parameters that may be required during installation, then the installer can simply tell the installer where to fetch the ks.cfg file and then go to work on it. When the installation is complete, the installer restarts the system according to the settings in the Ks.cfg and ends the installation.
Acquisition of Ks.cfg
1) The file can be obtained graphically, in the system execution System-config-kickstart follow the prompts step by step.
2) after each installation of the system will be generated under the root of the file named Anaconda-ks.cfg, it will automatically record the parameters you use during the installation process, for the sake of insurance, you can first customize the installation on the virtual machine once, and then change the file to Ks.cfg
The most basic ks.cfg file consists of the command section (commands section) and the%packages section (Software Installation section), the command part is in front, the%packages part is behind.
The KS.CFG options are as follows:
#告知安装程序, this is a new installation, not an upgradeInstall#告知安装程序, this is a network installation that uses FTP to provide the resources required for installation#我这边是使用匿名方式, you can also use username/password#url--url ftp://<username>:<password>@<server>/<dir>URL--url="Ftp://192.168.80.3/pub"#使用文本模式安装Text#默认语言是英语Lang en_US. utf-8#使用美式键盘Keyboard US#清空mbrZerombr#指定bootloader的安装位置及参数#--location Specifies the boot record location, we do not do a long system here, so write directly in the MBR#--driveorder specifying the first boot device#--append Specify kernel parameters, this way I use the default value, did not make changesBootloader--location=mbr--DRIVEORDER=SDA--append="Crashkernel=auto rhgb quiet"#设置安装完成后的主机网络, the keyword is network#这边参数都比较常见, I'm not going to explain it.Network--bootproto=Static--ip=192.168.. 8--netmask=255.255. 255. 0--gateway=192.168.. 2--HOSTNAME=CENTOS6--noipv6#设置时区#--utc setting using UTCTimeZone--UTC Asia/shanghai#设置密码加密方式为sha512 Enable the shadow fileAuth--useshadow--passalgo=sha512#设定root的密码#--iscrypted If the root password is encrypted, you must use this parameter, how to obtain this encrypted password, see the article attached to 1ROOTPW--iscrypted $6$QQAMYYYZMJZ/tpqh$cjmwagj8xpzk4jplrbucnxd/8Jesh7wtsbaefkl6hycgfmkfud/pbwtc75q62d3pi8iyclnulf750q7c7iys. 1#清空所有分区#--all clearing all partitions from the system#--initlable Initialize the disk label, for example my virtual machine is x86 schema, usually initialized to MsdosClearpart--all--initlabel#新建磁盘分区#新建/boot partitionPart/boot--FSTYPE=EXT4--size= -#新建3个pv, each PV size is 10GPart PV. 008002--size=10240Part PV. 008003--size=10240Part PV. 008005--size=10240#新建一个VG, named Vg_root, contains the 3 PV that you just createdVolgroup Vg_root--pesize=4096Pv. 008002Pv. 008003Pv. 008005#创建LVLogvol/home--FSTYPE=EXT4--name=lv_home--vgname=vg_root--size=2048Logvol/opt--FSTYPE=EXT4--name=lv_opt--vgname=vg_root--size=2048Logvol/--FSTYPE=EXT4--name=lv_root--vgname=vg_root--size=6116Logvol/tmp--FSTYPE=EXT4--name=lv_tmp--vgname=vg_root--size=4096Logvol/var--FSTYPE=EXT4--name=lv_var--vgname=vg_root--size=4096Logvol Swap--name=lv_swap--vgname=vg_root--size=2048#禁止firstboot, Firstboot is that we use the graphical installation of the system, after reboot has an initial setupFirstboot--disable#禁止selinuxSELinux--disabled#禁止防火墙Firewall--disabled#设定安装过程中的日志级别Logging--level=info#设定安装完成后关机Poweroff#安装包我选择的是Basic模式, added support for Chinese%packages@base#中文支持@chinese-support@console-internet@core@debugging@directory-client@hardware-monitoring@java-platform@large-systems@network -file-system-client@performance@perl-runtime@server-platform@server-policy%end
It is recommended not to have a brain installation here, be sure to look at the meaning of these parameters. Then modify your ks.cfg.
After the Ks.cfg file is generated, put the file into the ISO file, just drag it to the root directory in the ISO file.
To configure the Isolinux.cfg file below, the purpose is to find the ks.cfg when installing
File location in the ISO file inside the Isolinux folder, modify the file.
label linuxkernel vmlinuzappend initrd=initrd.img ks=cdrom:/ks.cfg ksdevice=eth0
Do not forget to replace it with the ISO after modification.
The ISO file is now ready to be made, very simple.
You can test with a virtual machine, and if the ISO is not a problem, it will generally succeed.
This method is only applicable to a small number of servers or network conditions are limited, if there are a large number of servers need to install the system, you can use Pxe+kickstart from the network installation.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Linux Automatic installation CD