Automated installation with Kickstart

Source: Internet
Author: User

These two days to learn Kickstart deployment, using PXE + DHCP + TFTP + NFS, the entire process is outlined below.


The system I use here is rhel6.5, slightly different for the RHEL5/CENTOS5 series system.


Let's briefly describe the process of booting the installation over the network:

    1. The client is set to boot over the network and may need to be set in the BIOS to enable the function

    2. Broadcast on LAN after launch

    3. The DHCP server should broadcast, the client obtains the IP address, and some additional information, such as the IP of the TFPT server, the files that need to be downloaded, etc.

    4. The client obtains the required boot file (pxelinux.0) and its configuration file from the TFTP server

    5. The client obtains the auto answer file (ks.cfg) in the specified manner, and then begins the automated installation


Here is the complete process:

DHCP Service:

Installation

Yum install-y DHCP

Modify the configuration file/etc/dhcp/dhcpd.conf as follows:

Subnet 192.168.80.0 netmask 255.255.255.0 {range 192.168.80.100 192.168.80.110;  Option Domain-name-servers 192.168.80.12;  Option Domain-name "fhjjabba.com";  Option routers 192.168.80.2;  Option broadcast-address 192.168.80.255;  Default-lease-time 600;    Max-lease-time 7200;  Next-server 192.168.80.12; FileName "/pxelinux.0";}

In addition to the last two clauses in the above configuration, other configuration items can be copied directly from the sample configuration to modify, the sample file is/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample, the configuration of the DNS is not necessary (said to be).

Next-server is used to specify the address of the TFTP server, and filename specifies the file to download from the server, where the path "/" does not refer to the root of the operating system, but rather the TFTP service's own root, as described in the TFTP service configuration.


You can start the service after you've configured it.

Service DHCPD Start

It is important to note that at least one subnet in the dhcpd.conf must be in the same network segment as the current host, or the DHCP service will fail to start. Based on the above configuration, my current host must have a 192.168.80.0/24 address.


TFTP service:

Installation

Yum Install-y tftp-server

Because the TFTP service is managed by XINETD, its configuration file is/etc/xinetd.d/tftp, and the following changes are made:

service tftp{        socket_type     =  dgram        protocol      =  udp        wait        =  yes        user        =  root        server       = / Usr/sbin/in.tftpd        server_args    = -s  /var/lib/tftpboot        disable       = no        per_source     =  11        cps        =  100 2 &nbSp;      flags       = ipv4} 

Actually just change disable = yes to disable = No, then restart XINETD

Service xinetd Restart

Verify that the TFTP service is started

NETSTAT-ULNP | grep:69

You can see the result that TFTP started normally.


Here the focus is on the Server_args entry in the TFTP configuration file, followed by the value/var/lib/tftpboot, which is the root directory of the TFTP service, so the full path to the "/pxelinux.0" file mentioned above should be/var/lib/ tftpboot/pxelinux.0.


Next, prepare some necessary files for the client.

Includes kernel vmlinuz, memory image initrd.img, bootloader pxelinux.0.

First mount the system CD to/mnt/cdrom

Mkdir/mnt/cdrommount/dev/cdrom/mnt/cdrom

Copy the kernel and memory image

CP/MNT/CDROM/ISOLINUX/{VMLINUZ,INITRD.IMG}/var/lib/tftpboot

In addition, there are many tutorials to copy/mnt/cdrom/isolinux/under the boot.msg and vesamenu.c32 two files, these are not necessary, BOOT.MSG is the system startup when the output of some information, VESAMENU.C32 is a menu. I'm not going to copy it here, so I'll just get rid of it when I change the configuration.


Then is the bootloader pxelinux.0, which is provided by the Syslinux package, so to install the Syslinux

Yum Install-y syslinux

You can copy it when you're ready.

Cp/usr/share/syslinux/pxelinux.0/var/lib/tftpboot


After the client downloads the pxelinux.0, it also downloads its configuration file, which specifies that it is placed in a directory named Pxelinux.cfg under the TFTP root directory, so this directory is created first

Mkdir/var/lib/tftpboot/pxelinux.cfg

The configuration file can be copied directly under the/mnt/cdrom/isolinux isolinux.cfg, the name defaults to default

Cp/mnt/cdrom/isolinux/isolinux.cfg/var/lib/tftpboot/pxelinux.cfg/default

Then in order to modify this configuration file, you also need to modify its permissions

chmod U+w/var/lib/tftpboot/pxelinux.cfg/default

My configuration is as follows:

#default vesamenu.c32default linuxprompt 0#display boot.msglabel linux menu label ^install or upgrade an existing system Menu default kernel vmlinuz append initrd=initrd.img ks=nfs:192.168.80.12:/nfs_share/ks.cfg

There are two lines with "#" that begin with a comment, which is the two files that were not copied to.

Note the second line of default Linux and the following label Linux, which are corresponding, indicate that the default is to use the label Linux configuration below. Focus on label Linux below the fourth line of ks= ... This one, I added, it means to specify the system installation process of the automatic answer file, according to the actual situation to fill out, if it is HTTP or FTP format is http://ip/path/to/ks.cfg.


NFS Services:

Installation

Yum Install-y nfs-utils

Then set the directory that needs to be shared, I set the/nfs_share, the configuration file is/etc/exports

Mkdir/nfs_shareecho "/nfs_share * (ro,async,nohide,crossmnt)" >>/etc/exports

The exports file describes the directories that NFS needs to share, and it is recommended to add the Nohide and crossmnt two options, or the client may not be able to mount.


Then provide the auto answer file in the shared directory, I copy the/root under the anaconda-ks.cfg directly.

CP ~/anaconda-ks.cfg/nfs_share/ks.cfg

Then manually edit the Ks.cfg.

I don't say much about each of them, here is my configuration:

# kickstart file automatically generated by anaconda. #version = Develinstalltextkey --skipnfs --server=192.168.80.12 --dir=/nfs_share/cdromlang en_us. utf-8keyboard usnetwork --onboot yes --device eth0 --bootproto dhcp -- noipv6rootpw  --iscrypted $6$9znvhzodnrm03bdb$0bvvh1umqehmubktruanas2wrjyebjwia6rqtcdqofvn0qw/ fvwowbcdgx9zhs9xl7/kvsouyevkubaefzto60firewall --service=sshauthconfig --enableshadow -- passalgo=sha512selinux --permissivetimezone asia/shanghaibootloader --location=mbr -- Driveorder=sda --append= "Crashkernel=auto rhgb quiet" rebootclearpart --all --drives= Sdazerombrpart /boot --fstype=ext3 --size=100part / --fstype=ext3 --size= 5120part /usr --fstype=ext3 --size=10240part /home --fstype=ext3 --size=5120part  swap --size=1024%packages --nobase@coRe%end 

Note the NFS entry, which specifies the directory where the IP and system images of the NFS server are located (that is, the various installation packages that need to be downloaded during the system installation), I hang the system CD under/nfs_share/cdrom, and this directory is specified instead of/nfs_share. In addition, since this directory is a subdirectory of/nfs_share, it is necessary to specify Nohide and crossmnt two options in/etc/exports.

Because the system CD has been hung under the/mnt/cdrom, it can be mounted again in the following way

Mount--bind/mnt/cdrom/nfs_share/cdrom

So there are two entrances at the same time.


And the ROOTPW item is set root password, after a long string is my password encryption results, you can set according to your needs, with the Grub-crypt command can be

# Grub-cryptpassword:retype Password:$6$ehchyechzegzakml$duvm9ik06zeyfilfpeysnhgqczu7sbkp19bupwj2ruqnzzjkrr9sj03 /q9e8ghrtxcwdkczhsexh6wtzimice.

is to copy and paste the final result.

If you forget to do this step, then the login system will enter the password I set, so you want to change the password, you can be in the Grub boot interface to the kernel to add a boot parameter, in the back with "1" or "s" can be, the specific way to Google it, forget the root password too many people ...


Because this configuration file is copied from the root home directory, you also need to modify the permissions so that everyone can read it, otherwise the client will not be able to download the file

chmod +r/nfs_share/ks.cfg

You can then start the NFS service

Service NFS Start


Well, the complete configuration process has been completed, and then a new machine can be built to do the experiment.

But there are a few more things to explain:

    • The new virtual machine in the same LAN as the DHCP server, and try not to appear more than one DHCP server, so it is best to put two virtual machines in the Host-only network.

    • The virtual disk of the new virtual machine should be allocated a sufficient amount of space immediately, or there will be an error that cannot allocate enough disk space during installation. For example, if the partitions configured in my ks.cfg are combined with 21+G, the new virtual disk is best allocated 25G immediately before it can be installed successfully.

    • If the client cannot connect to the TFTP server after obtaining an IP address, the connection timeout occurs, both SELinux and iptables are turned off.



The first time on the 51CTO blog, do not do a good place also please forgive me, where the writing is not correct please point out that there are problems can be proposed to discuss together. 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0057.gif "alt=" J_0057.gif "/>

Automated installation with Kickstart

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.