LINUX Automatic Installation
LINUX Automatic Installation
Server (192.168.1.107)
1. Disable iptables and selinux
Service iptables stop
# Chkconfig iptables off
Setenforce 0
Or vi/etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX = can take one of these three values:
# Enforcing-SELinux security policy is enforced.
# Permissive-SELinux prints warnings instead of enforcing.
# Disabled-SELinux is fully disabled.
# SELINUX = enforcing comment out
SELINUX = disabled
# SELINUXTYPE = type of policy in use. Possible values are:
# Targeted-Only targeted network daemons are protected.
# Strict-Full SELinux protection.
2. Configure the YUM Source
Cp/etc/yum. repos. d/rhel-debuginfo.repo/etc/yum. repos. d/yum. repo
Vi/etc/yum. repos. d/yum. repo
[Base]
Name = Red Hat Enterprise Linux
Baseurl = file: // media/Server
Enabled = 1
Gpgcheck = 0
Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
3. Install dhcp tftp vsftp syslinux SYSTEM-CONFIG-KICKSTART
Mount/dev/cdrom/media/
Yum install-y vsftpd *
Yum install-y dhcp *
Yum install-y system-config-kickstart
Yum install-y tftp *
Yum install-y syslinux *
4. Configure DHCP
Vi/etc/dhcpd. conf
#
# DHCP Server Configuration file.
# See/usr/share/doc/dhcp */dhcpd. conf. sample
#
-- In the beginning, this configuration file only contains the preceding rows. Enter the colon as prompted:
: R/usr/share/doc/dhcp */dhcpd. conf. sample Press enter and the following will be available:
Ddns-update-style interim;
Ignore client-updates;
# Allow boot from network use PXE
Allow booting;
Allow bootp;
Subnet 192.168.1.0 netmask 255.255.255.0 {
Gateway and subnet mask
# --- Default gateway
Option routers 192.168.1.1; set the default gateway for the client
Option subnet-mask subnet mask 255.0; set the subnet mask for the client
# Option nis-domain "domain.org"; configure the NIS domain for the client
# Option domain-name "domain.org"; specify the DNS name for the client
# Option domain-name-servers 192.168.1.1; specify the DNS server IP address for the client
Option time-offset-18000; # Eastern Standard Time is the offset time between the client and Greenwich Mean Time, in seconds.
# Option ntp-servers 192.168.1.1;
# Option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- You understand Netbios very well
# Option netbios-node-type 2;
Range dynamic-bootp 192.168.1.128 192.168.1.254; ip address range provided by the client
Default-lease-time 21600;
Max-lease-time 43200;
# Next-server is the tftp server.
# Filename is boot image file under tftp root
Next-server 192.168.1.107; find the boot file from this host
Filename "pxelinux.0 ";
# We want the nameserver to appear at a fixed address
Host ns {
Next-server marvin.redhat.com;
Hardware ethernet 12: 34: 56: 78: AB: CD;
Fixed-address 207.175.42.254;
}
}
5. Configure TFTP
Vi/etc/xinetd. d/tftp
# Default: off
# Description: The tftp server serves files using the trivial file transfer \
# Protocol. The tftp protocol is often used to boot diskless \
# Workstations, download configuration files to network-aware printers ,\
# And to start the installation process for some operating systems.
Service tftp
{
Disable = no
Socket_type = dgram
Protocol = udp
Wait = yes
User = root
Server =/usr/sbin/in. tftpd
Server_args =-u nobody-s/tftpboot
Per_source = 11
CPIs = 100 2
Flags = IPv4
}
6. Start dhcp tftp
Service dhcpd start
Service xinetd start
Chkconfig dhcpd on
Chkconfig xinetd on
The/tftpboot directory should be available in the root directory after startup. If not, create your own partition (partition _ boot) partition.
7. Configure PXE
Cp/usr/lib/syslinux/pxelinux.0/tftpboot
Cp/media/images/pxeboot/{vmlinuz, initrd. img}/tftpboot/
Mkdir/tftpboot/pxelinux. cfg
Cp/media/isolinux. cfg/tftpboot/pxelinux. cfg/default
Vi/tftpboot/pxelinux. cfg/default
Default linux
Prompt 1
# Timeout 600
Timeout 6
Display boot. msg
F1 boot. msg
F2 options. msg
F3 general. msg
F4 param. msg
F5 rescue. msg
Label linux
Kernel vmlinuz
# Append initrd = initrd. img
Append ks = ftp: // 192.168.1.107/ks. cfg initrd = initrd. img
Change this. Note ks. cfg file location. Because ftp is configured, the folder that anonymous users log on to is/var/ftp/pub, so ks. cfg should be placed in this directory
Label text
Kernel vmlinuz
Append initrd = initrd. img text
Label ks
Kernel vmlinuz
Append ks initrd = initrd. img
Label local
Localboot 1
Label memtest86
Kernel memtest
Append-
8. Configure KICKSTART
By default, a anaconda-ks.cfg is generated under/root after the system is installed.
We can find a server and change it to another one.
Cp/root/anaconda-ks.cfg/var/ftp/pub/ks. cfg
Vi/var/ftp/pub/ks. cfg
# Kickstart file automatically generated by anaconda.
Install
# Cdrom
Url-url = ftp: // 192.168.1.107/redhat/
The ftp we use, so comment out the cdrom. Otherwise, the customer will go to the cdrom to find the installation file.
After installing the CD file, copy it to the/var/ftp/pub/redhat folder.
Key -- skip
Lang zh_CN.UTF-8
Keyboard us
Xconfig -- startxonboot
Network -- device eth0 -- bootproto dhcp
Set the root password for rootpw oracle
Firewall -- disabled
Authconfig -- enableshadow -- enablemd5
Selinux -- disabled
Timezone -- utc Asia/Shanghai
Bootloader -- location = mbr -- driveorder = sda -- append = "rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# Here so unless you clear all partitions first, this is
# Not guaranteed to work
# Clearpart -- all -- drives = sda
Clearpart -- all-initlabel must be added in this line or you will be asked to manually confirm
-------------------------------
Configure boot below
You can also create logical volumes, provided that pv is created.
Part/boot -- fstype ext3 -- size = 100 -- ondisk = sda
Part pv.2 -- size = 0 -- grow -- ondisk = sda
Volgroup VolGroup00 -- pesize = 32768 pv.2
Logvol/-- fstype ext3 -- name = LogVol00 -- vgname = VolGroup00 -- size = 1024 -- grow
Logvol swap -- fstype swap -- name = LogVol01 -- vgname = VolGroup00 -- size = 1008 -- grow -- maxsize = 2016
Reboot automatically restarts after installation, or you need to manually click
% Packages
@ Admin-tools
@ Base
@ Chinese-support
@ Core
@ Development-libs
@ Development-tools
@ Dialup
@ Editors
@ Ftp-server
@ Gnome-desktop
@ Gnome-software-development
@ Games
@ Graphical-internet
@ Graphics
@ Java
@ Java-development
@ Kde-desktop
@ Kde-software-development
@ Legacy-software-development
@ Legacy-software-support
@ Mail-server
@ Office
@ Printing
@ Ruby
@ Sound-and-video
@ System-tools
@ Text-internet
@ X-software-development
@ Base-x
Kexec-tools
Fipscheck
Device-mapper-multipath
Sgpio
Python-dmidecode
Imake
Emacs
Libsane-hpaio
Audit
Mesa-libGLU-devel
Xorg-x11-utils
Xorg-x11-server-Xnest
Xorg-x11-server-Xvfb
We can also execute scripts to Modify host names and other information after installation.
Pass
% Post followed by script
% Post
Ntpdate-B 172.16.0.1
Hwclock -- systohc-utc
Cat>/etc/ntp. conf <END
Restrict default ignore
Restrict 127.0.0.1
Restrict 172.16.0.1
Server 172.16.0.1
Driftfile/var/lib/ntp/drift
Broadcastdelay 0.008
END
Echo "172.16.0.1">/etc/ntp/step-tickers
Chkconfig ntpd on
Useradd student
Echo "student" | passwd -- stdin student
Useradd visitor
Echo "password" | passwd -- stdin visitor
Mkdir/home/student/Desktop
$ {Httpget}-source http: // 172.16.0.1/pub/gls/ClassInteractives. desktop>/home/student/Desktop/Class \ Interactives. desktop
Chown-R student: student/home/student/Desktop
Perl-pi-e's, DAILY_UPDATE = no, DAILY_UPDATE = yes, G'/etc/updatedb. conf
I will pay a detailed explanation of kickstart Configuration:
Http://blog.chinaunix.net/uid-17240700-id-2813881.html
9. Finally, copy the installation file to the ftp directory.
Cp-r/media/*/var/ftp/pub/redhat/
Then you can start the client to install
Installation principle:
1. Set the BIOS of the client to start from the network.
2. The client obtains the IP address from the DHCP server.
3. The client loads the boot image from the TFTP specified by the DHCP server.
4. Perform automatic installation Based on the configuration file on the TFTP server. If the configuration file gives too little information, it will enter the interactive installation mode. In interactive installation mode, you can select the location and access mode of the installation media on the network.
DHCP server IP address-tftp get Boot Image-find pxe configuration file in TFTP-obtain ks. cfg file in pxe configuration file-ks. cfg file get installation information and Installation File Location
After the client obtains the IP address, it searches for the configuration file in the/tftpboot/pxelinux. cfg directory of the TFTP server.
The MAC address of a machine is '88: 99: AA: BB: CC: dd', and the obtained IP address is 192.0.2.91 (The hexadecimal number is C000025B ), then it will search for its configuration file in the following order:
/Tftpboot/pxelinux. cfg/01-88-99-aa-bb-cc-dd
/Tftpboot/pxelinux. cfg/C000025B
/Tftpboot/pxelinux. cfg/C000025
/Tftpboot/pxelinux. cfg/C00002
/Tftpboot/pxelinux. cfg/C0000
/Tftpboot/pxelinux. cfg/C000
/Tftpboot/pxelinux. cfg/C00
/Tftpboot/pxelinux. cfg/C0
/Tftpboot/pxelinux. cfg/C
/Tftpboot/pxelinux. cfg/default
It can be seen that the order is to first find out whether there is a configuration file corresponding to its MAC address, then the IP address, then to a subnet that may be its, and finally the default
Then, the allocation is very good, for example:
If all machines in the 192.0.2.0/24 network segment are installed with SLES, modify the corresponding configuration file/tftpboot/pxelinux. cfg/C00002;
If RHEL is installed on machines in 192.168.95.240/28, modify the corresponding configuration file/tftpboot/pxelinux. cfg/C0A85FF;
These configuration files can be copied to default and then slightly modified:
# Cp/tftpboot/pxelinux. cfg/default/tftpboot/pxelinux. cfg/C00002
# Vi/tftpboot/pxelinux. cfg/C00002