Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Install CentOS 6.9 from the unattended ks file located on the http server

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

CentOS 6.x how to create kickstart files:

Manually edit it directly according to a template: it can be modified according to the / root/anaconda-ks.cfg configuration file generated after the system installation is completed.

Created by system-config-kickstart command according to a template (graphical interface support is required)

Configure Xmanager to use a graphical interface:

Install the gnome desktop environment: # yum-y install xdm gdm

Modify the configuration file: # vim / etc/gdm/custom.conf

Add: under the [security] setting section:

AllowRemoteRoot=true

Add: under the [xdmcp] setting section:

Enable=1

Port=177

Configure the system in graphical mode: # vim / etc/inittab-- > id:5:initdefault:

Restart the CentOS server: # reboot

Open the Xbrowser of Xmanager in Windows, enter the CentOS server IP in the address bar and enter to connect.

# yum-y install system-config-kickstart

# system-config-kickstart & / / & indicates running in the background

File-- > Open File-- > find anaconda-ks.cfg-- > Open-- > after importing anaconda-ks.cfg, edit as needed-- > File-- > Save as ks.cfg

Syntax check command for kickstart file: # yum-y install pykickstart # ksvalidator/root/ks.cfg

Format of the kickstart file:

Command section: indicates various pre-installation configurations, such as keyboard types, including prerequisite commands and optional commands

Package segment: indicates the package group or package to be installed, or the package that does not need to be installed, etc., you can use * for wildcard

% packages / / start

@ group_name / / package groups to be installed, one line for each entry

Package / / Software packages to be installed

-package / / packages that do not need to be installed

% end / / end

Script paragraph:

% pre: pre-installation script

Operating environment: a miniature Linux environment running on installation media

% post: post-installation script

Running environment: installed system

Behavior comment line at the beginning of the # sign

Kickstart sample configuration file ks.cfg:

# indicates that this is a new installation system

Install

# use the local optical drive as the system installation source

Cdrom

# set the language used during system installation and the default language of the system. English is recommended. If Chinese is selected, it is zh_CN.UTF-8.

Lang en_US.UTF-8

# set keyboard type

Keyboard us

# set the network interface of the system, including whether to activate the network card automatically when the system starts, the device name of the network card for activation and system installation, how to obtain the IP address, the IP address, mask NETMASK, gateway GATEWAY, DNS, the host name after installation, whether to enable the IPv6 function of the device. The values of all parameter options must be written on one line.

Network-onboot=yes-device=eth0-bootproto=static--ip=192.168.199.18-netmask=255.255.255.0-gateway=192.168.199.1--nameserver=114.114.114.114-hostname=centos6.9-noipv6

# set the encrypted password of the system root administrator, where the source password is 123456

Rootpw-- iscrypted $1 $.ul2D7pG$h7nbx475YjlrswZRYAgOf/

# disable the system firewall

Firewall-disabled

# set the authentication method of the system, use hidden passwords, and use SHA-512 hash algorithm

Authconfig-enableshadow-passalgo=sha512

# disable system selinux

Selinux-disabled

# set system time zone

Timezone Asia/Shanghai

# set the installation options for bootloader, including the location where the boot record is written, the boot sequence of the device in BIOS, and the parameter options that need to be passed to the kernel, which will be appended to the end of the line of the kernel keyword corresponding to title in the grub configuration file / etc/grub.conf

Bootloader-location=mbr-driveorder=sda-append= "crashkernel=autorhgb quiet"

# clear the mbr information and clear the original partition table on the system, otherwise you will be prompted whether to clear the data on the disk

Zerombr

# empty the original partition table on the system before creating a new partition, and initialize the disk volume marked as the default volume label of the system architecture

Clearpart-all-initlabel

# create a disk partition. The disk partition method here is: / bootext4 2G focus swap2G focus / LVM all the remaining available capacity

Part / boot-fstype=ext4-size=2048

Part swap-size=2048

Part pv.008003-grow-size=1

Volgroup vg_centos6.9-pesize=4096 pv.008003

Logvol /-- fstype=ext4-- name=lv_root-- vgname=vg_centos6.9-- grow--size=1

# create an ordinary user after the system installation is completed

User-- name=marion-- password=$1 $.ul2D7pG $h7nbx475YjlrswZRYAgOf/--iscrypted

# set the services that are disabled after the system starts

Services-disabled NetworkManager,iptables

# automatically restart the system after the system installation is complete, and eject the CD before restarting the system

Reboot-eject

# install package group and package, @ package group name. For specific names, you can view the files ending with-comps.xml in the repodata directory on the installation CD, where the name in the id tag is the package group name.

% packages

@ base

@ chinese-support

@ core

@ desktop-platform

@ development

@ server-platform

@ server-platform-devel

@ server-policy

@ workstation-policy

@ x11

Cronie

Lftp

Ntpdate

Screen

Tree

Vim-enhanced

Wget

% end

% post

# it is not controlled by NetworkManager script. CentOS 6.x recommends setting the value of NM_CONTROLLED to no

Sed-I's no control = "yes" # NM_CONTROLLED= "no" # g'/etc/sysconfig/network-scripts/ifcfg-eth0

/ etc/init.d/network restart & > / dev/null

# ssh service optimization, including: prohibition of DNS parsing, prohibition of remote login of root users, prohibition of login with empty password

Sed-I 's/#UseDNS yes/UseDNS no/g' / etc/ssh/sshd_config

Sed-I 's/#PermitRootLogin yes/PermitRootLogin no/g' / etc/ssh/sshd_config

Sed-I 's/#PermitEmptyPasswords no/PermitEmptyPasswords no/g'/etc/ssh/sshd_config

/ etc/init.d/sshd restart & > / dev/null

# set selinux to disabled

Sed-I's setting SELINUXFORCING'/ etc/selinux/config

# set to disable iptables after system startup

/ sbin/chkconfig iptables off

# set the system yum source, modify the default yum source to aliyun source, and add epel source

Find / etc/yum.repos.d/-name "CentOS-*.repo"-exec mv {}. Bak\

Wget-qO / etc/yum.repos.d/aliyun.repo http://mirrors.aliyun.com/repo/Centos-6.repo

Wget-qO / etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

Wget-qP / etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-testing.repo

Sed-I's #\ [base\] #\ [aliyun\] # g' / etc/yum.repos.d/aliyun.repo

Yum clean all & > / dev/null

Yum makecache & > / dev/null

Yum repolist & > / dev/null

# Import the GPG key of aliyun

Rpm-- import http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

# resize the file descriptor

Echo'*-nofile 65535'> > / etc/security/limits.conf

% end

Put the ks file on the http server

Create a new virtual machine-- > capacity 1000G (size is not fixed, selected according to the actual situation)-- > put into the original ISO installation CD-ROM-- > start the virtual machine-- > boot sequence preferred optical drive-- > enter the installation menu interface-- > press the ESC key to enter the boot prompt

Install the system automatically without human intervention:

Restart automatically after the installation is complete:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report