Boot Image for CentOS semi-automated Installation

Source: Internet
Author: User
Tags time zones

Boot Image for CentOS semi-automated Installation

This experiment cannot be used in the production environment, because more advanced automatic installation software has been used to replace this experiment, so we only want to learn more about Linux installation from the lower layer, in this experiment, we conducted the "Guide image to achieve CentOS semi-automatic installation" experiment to deepen and understand the current knowledge.

Let's take a look at the topology!

To briefly explain the topology, first enable the http service on the server and create two directories, ks and x86_64, under the default http directory, attach the CD image to the/var/www/html/x86_64 directory, and load the created ks. copy the cfg file to the/var/www/html/ks directory. on the server side, create isolinux to boot the client (in fact, it is to extract the isolinux directory from the CD image, and re-use the command to generate an iso file ). Install CentOS 6.6 x86_64 on the local network when the client is mounted to isolinux.

(1) Create the ks. cfg file first.

After CentOS 6 is installed, a anaconda-ks.cfg file is generated under/root, this is a file generated by CentOS 6 installer anaconda based on the selection of all the keyboard types, languages, time zones, partitions, and packages during system installation.

If we want to make a anaconda-ks.cfg file, you can refer to this file on some basis to modify, you can use the system-config-kickstart program to generate the relevant file.

Install the system-config-kickstart Program

1 [root @ node-2 ~] # Yum install-ysystem-config-kickstart

Start the system-config-kickstart Program

Use xshell 4 to remotely connect to the terminal and start system-config-kickstart. We recommend that you install XmanagerEnterprise 4 to enable the software in Linux on the local terminal. Enter the system-config-kickstart command in the command line.

After the modification, select Save in the File menu, enter the ks. cfg name at the top, select the Save location, and click Save.

View the generated file and add some content, because some commands need to be manually added. For more information, see REHL official documents.

[Root @ node-2 ~] # Cat/var/www/html/ks. cfg
# Platform = x86, AMD64, or IntelEM64T
# Version = DEVEL
# Firewall configuration
Firewall -- disabled # select firewall off when the system is restarted after installation
# Install OS instead of upgrade
Install # select "install" as the installation type
# Use network installation
Url -- url = "http: // 172.16.9.21/x86_64/" # The Http service
Repo -- name = "CentOS" -- baseurl = http: // 172.16.9.21/x86_64/-- cost = 100
# Repo -- name = "FedoraEPEL" -- baseurl = http: // 172.16.0.1/fedora-epel/6/x86_64/-- cost = 1000
# Root password
Rootpw -- iscrypted $1 $ jLn8z9P1 $ ff07gV9CfXmz1Q0NEOmAw/# administrator root password, encrypted Storage
# System authorizationinformation
Auth -- useshadow -- passalgo = sha512 # authentication method. The sha512 encryption method is used.
# Use graphical install
Graphical # Install using graphical interfaces
Firstboot -- disable
# System keyboard
Keyboard us # The selected keyboard type is us
# System language
Lang en_US # English Language
# SELinux configuration
Selinux -- disabled # disable selinux
# Do not configure the X WindowSystem
Skipx # ignore the configuration of X Window System
# Installation logging level
Logging -- level = info # Start Log level
# Reboot after installation
Reboot # restart the system after installation
# System timezone
Timezone Asia/Shanghai # the system time zone is Asia/Shanghai
# Network information
# Network -- bootproto = dhcp -- device = eth0 -- onboot = on
# System bootloaderconfiguration # indicates passing Kernel Parameters
Bootloader -- append = "crashkernel = auto rhgb quiet" -- location = mbr -- driveorder = "sda"
# Partition clearinginformation
Clearpart -- all # The following operations are performed on the disk. The LVM is used here.
Zerombr # No partitions on the disk.
Part/boot -- fstype = ext4 -- size = 200
Part pv.008002 -- size = 61440

Volgroup vg0 -- pesize = 8192pv. 008002
Logvol/-- fstype = ext4 -- name = root -- vgname = vg0 -- size = 20480
Logvol swap -- name = swap -- vgname = vga0. -- size = 2048
Logvol/usr -- fstype = ext4 -- name = usr -- vgname = vg0 -- size = 10240
Logvol/var -- fstype = ext4 -- name = var -- vgname = vg0 -- size = 20480

% Post # script to be executed after installation

% End # script Terminator
% Packages # package and package group to be installed during installation
@ Base
@ Basic-desktop
@ Chinese-support
@ Client-mgmt-tools
@ Core
@ Desktop-platform
@ Fonts
@ General-desktop
@ Graphical-admin-tools
@ Legacy-x
@ Network-file-system-client
@ Perl-runtime
@ Remote-desktop-clients
@ X11
-Ibus-table-cangjie
-Ibus-table-erbi
-Ibus-table-wubi

% End # package and Program Package group Terminator

(2) install and start the http service
12345 [root @ node-2 ~] # Yum installhttpd-y # Install the httpd service
[Root @ node-2 ~] # Service httpdstart # Start the http service
Starting httpd: [OK]
[Root @ node-2 ~] # Netstat-ntlp | grep 80 # Check the startup status. The http port is tcp port 80.
Tcp 0 0: 80: * LISTEN 2008/httpd

(3) attach a CD image
Put the CD image into the optical drive. If you are using a virtual machine, add the CD file to the optical drive of the Virtual Machine and enable it.
1234 [root @ node-2 ~] # Mkdir/var/www/html/{ks, x86_64} # create ks, x86_64 directory
[Root @ node-2 ~] # Mount-r/dev/dvd/var/www/html/x86_64/# mount the disc image to/var/www/html/x86_64/in read-only mode/
[Root @ node-2 ~] # Mount | tail-1 # view mounting information
/Dev/sr0 on/var/www/html/x86_64 type iso9660 (ro)

(4) copy the ks. cfg file to the/var/www/html/ks directory.
123 [root @ node-2 ~] # Cp/root/ks. cfg/var/www/html/ks/
[Root @ node-2 ~] # Ls/var/www/html/ks/
Ks. cfg

(5) Create an isolinux boot Guide
Create a cdrom directory in/tmp/, copy the isolinux image in the CD image to the/tmp/cdrom directory, and run the mkisofs command to generate the iso file.
1234567 [root @ node-2 ~] # Cd/tmp/# Switch the/tmp directory
[Root @ node-2 tmp] # cp-r/var/www/html/x86_64/isolinux // tmp/cdrom/# copy isolinux to the/tmp/cdrom directory
[Root @ node-2 tmp] # ls cdrom/# view the copy result
Isolinux
[Root @ node-2 tmp] # mkisofs-R-J-T-v -- no-emul-boot -- boot-load-size 4 -- boot-info-table-V "Centos6.6 X86_64 boot disk "-B isolinux/isolinux. bin-c isolinux/boot. cat-o/root/boot. iso cdrom/# create boot. iso file
[Root @ node-2 tmp] # ll/root/boot. iso # view iso File Creation
-Rw-r -- 1 root 3986620.apr 17/root/boot. iso

(6) download the created boot. iso file to a local computer. You may drag the boot. iso file to the desktop through the Xftp file that comes with Xshell 4.
(7) create a new virtual machine with a disk space of 120 GB. iso loaded to the virtual machine drive, select "connection at startup", open the new virtual machine, press F2 to enter the BIOS, move to the Boot option to modify the first Boot item to CD-ROM Driver, press F10 to save and exit. The VM will be restarted.
(8) The CentOS installation and selection page appears, as shown in.

Press ESC, because we only have one boot and there is no package required by the installation program. We want to manually specify ks. use the http service to remotely install CentOS 6 x86_64.
Enter the linux ip address = 172.16.9.34 netmask = 255.255.255.0.0 gateway = 172.16.0.1ks = http: // 172.16.9.21: 80/ks at the boot command prompt. cfg. Press enter to start loading vmlinux and initrd. imgfile to start automatic installation of CentOS.

Tip:
Run the linux Command in the command line prompt of the boot command to install CentOS in a graphical manner. A memory larger than MB is required;
Ip, netmask, and gateway are used to specify the ip address, mask, and gateway of the local Nic,
Ks indicates the location where the ks. cfg file is located. You can use http, ftp, nfs, https, and DVD Driver. The addresses of different services may be different:
DVD drive ks = cdrom:/path/to/kickstart_file
HTTP Server ks = http: // server_ip: port/path/to/kickstart_file
HTTPS Server ks = https: // server_ip: port/path/to/kickstart_file
FTP Server ks = ftp: // server_ip: port/path/to/kickstart_file
NFS Server ks = nfs: server_ip:/path/to/kickstart_file
 
Advanced installation of Centos:
Through the above installation, you find that we need to specify the IP address, subnet mask, Gateway and ks every time. cfg file path. Can we set ks. make the cfg file into the isolinux boot. Assume that there is already a DHCP server in the network environment where the host can automatically obtain the IP address. In this way, we only need to put the CD made by isolinux into the optical drive, then wait. Centos 6 x86_64 has been installed. Draw a simple image:

We only need to modify the above to implement it, and make the following changes;
(1) copy the ks. cfg file to the/tmp/cdrom/directory.
123 [root @ node-2 tmp] # cp/var/www/html/ks. cfg/tmp/cdrom/ks. cfg
[Root @ node-2 tmp] # ls/tmp/cdrom/
Isolinux ks. cfg

(2) modify the DHCP service enabled for the NIC in the ks. cfg file so that it can automatically obtain the IP address and add the following line:
12 # Network information
Network -- bootproto = dhcp -- device = eth0 -- onboot = on # in the preceding ks. cfg file, cancel the previous;

(3) switch to the/tmp/cdrom/isolinux/directory and modify the isolinux. cfg file.
[Root @ node-2 ~] # Cd/tmp/cdrom/isolinux/# Switch to the/tmp/cdrom/isolinux/directory
[Root @ node-2 isolinux] # chmod u + w * # Add modification permissions to all files
[Root @ node-2 isolinux] # vimisolinux. cfg # compile the isolinux. cfg file and add ks = cdrom:/ks. cfg to the append file.
Label linux
Menu label ^ Install or upgrade an existingsystem
Menu default
Kernel vmlinuz
Append initrd = initrd. img ks = cdrom:/ks. cfg
(4) recreate the isolinux Boot Image
12 [root @ node-2 isolinux] # cd/tmp # Switch to the/tmp directory
[Root @ node-2 tmp] # mkisofs-R-J-T-v -- no-emul-boot -- boot-load-size 4 -- boot-info-table-V "Centos6.6 X86_64 boot disk "-B isolinux/isolinux. bin-c isolinux/boot. cat-o/root/boot. iso cdrom/

(5) download/root/boot. iso to the local desktop, restart the virtual machine used to Install the system, and select the "Install or upgrade an existing system" label to automatically Install CentOS6.6 x86_64.

Tip: ks. the cfg file is specified as ks/ks in the http service when creating the isolinux boot image. cfg file, you can also put ks. the cfg file can be installed automatically on the CD of the release version as needed.
 
Summary:
This experiment has not been used in the production environment. It is just to understand the CentOS installation process, so that you can manually create isolinux to boot and provide CentOS installation images and ks through the http service. cfg file, so as to achieve a semi-automated installation of CentOS system, for a better understanding of fully automated installation of CentOS in the future, familiarize yourself with the installation process in the early stage.

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.