Linux system installation: CentOS Department
Post--bootsequence (BIOS)-BootLoader (Grub-->1.5 Stage-to-2nd stage)-Kernel (DEVTMPFS)-[RA MDisk (Dev,proc,sys)-->] Rootfs--/sbin/init (SysV init,upstart init,systemd)
For the CentOS operating system installed, some of its first-level sub-directories, some can not be separate partitions, some may be separate partitions;
Absolutely no partitioning: bin,sbin,lib,lib64
Create separate partitions: BOOT,HOME,VAR,USR
To install a Linux system:
/boot
Swap
/
/home
/var
/usr
Disk Partitioning planning:
Boot partition
Root partition
Swap
Planning the file system:
/sbin/init,/sbin/systemd
The path where all applications store the path that the application relies on to store the library files
The path that the application relies on for the configuration file to be stored
CentOS System/rhel System installation program: Anaconda
During the installation of the operating system, the system starts the process:
Post--BootLoader-kernel---initrd--rootfs--Anaconda
Anaconda provides us with two operating interfaces:
TUI: Curses-based file configuration window;
GUI: graphical interface;
CLI: Command line interface;
Take the CD as an example, the installation start-up process of the CentOS system:
1.post
2. Read Mbr,boot.cat, which is the bootloader;/isolinux/boot.cat of the CD
3.stage2:/isolinux/isoinux.bin
Configuration file:/isolinux/isolinux.cfg
Label Linux
Tag name, which can be used to refer to the generic name of all the following commands;
Menu label ^install or upgrade an existing system
The specific contents of the menu options and the corresponding hotkey;
Menu default
Use this menu item as the default menu item;
Kernel Vmlinuz
Specify the kernel file name
Append initrd=initrd.img
To pass additional parameters to the kernel, the commonly used parameters are:
Initrd=initrd.img
Text: Starting from a textual interface
Method: Manually select the installation method
Ip=address
Netmask=mask
Gateway=gw
Dns=dns_server
Rescue: Activate emergency rescue mode
DD: Use Kickstart to start an unattended installation, indicating where the kickstart configuration file is located:
On CD: Ks=cdrom:/path/to/kickstart_file
Local hard drive: Ks=h:/device/path/to/kickstart_file
A remote Web site: ks=http://host[:p ort]/path/to/kickstart_file
A remote FTP site: ks=http://[[email protected]]host[:p Ort]/path/to/kickstart_file
A remote security Web site: ks=http://host[:p ort]/path/to/kickstart_file
4. Load the Rootfs and start the Anaconda
Note: If the memory is not 512M, the Anaconda is started with a text interface, and if the memory is greater than 512m,anaconda, it is started by default in graphical interface;
"ECS" key--Boot:linux text
Note: All of the above content is generally located in the boot device, and subsequent Anaconda and other packages or package groups used in the installation can be sourced from the Yum Repository, the location of the Yum Warehouse:
Local Disc
Local hard disk
FTP Server
HTTP Server
Server for NFS
If you want to manually specify a package installation Source:
"ECS" key---Boot:linux method
Anaconda's working process:
Pre-Installation Preparation configuration phase:
1. Language used in the installation process: Simplified Chinese;
2. Keyboard layout type: American English style;
3. Target storage device installed by the system;
Basic storage, local disk;
Special storage, networked storage, Iscsi,nas,san, ... ;
4. Set the host name;
5. Configure the network interface;
6. Select the time zone;
7. Administrator password;
8. Set the partition mode and the location of the MBR installation;
9. Select the package or package group to install;
Installation phase:
1. It is possible to run some pre-installation scripts to complete the initialization work;
2. Partition creation and execution of the format installation file system and mount all file systems to the specified mount point according to the partition format planned in the preparation phase;
3. Install the selected package or package group to the target location;
4. Install the bootloader to the MBR and boot partitions;
5. Making RAMDisk files;
6. If necessary, the post-installation script may be run;
First boot:
1. Select the license information;
2. Create a regular user;
3. Configure Kernel Core dump (Kdump,core dump), if memory is less than 2gb,kdump does not turn on;
When the kernel core crashes at some point, Kdump creates an image file of all the data in memory when the kernel crashes and finds out the direct or indirect cause of the kernel crash by analyzing the contents of the file;
1. Whether to configure iptables firewall; beginners suggest to close;
2. Whether to configure the startup of the SELinux security mechanism, beginners are advised to close;
Kickstart file Format:
Command section: Indicates the configuration of various pre-installation;
Required command:
Authconfig: Configuration of authentication Mode
Authconfig--useshadow--passalgo=sha512
Bootloader: Defining the installation location and related configuration options for bootloader
bootloader--loaction=mbr--driveorder=sda--append= "Crashkernel=auto rhgb quiet"
Keyboard: Setting the type of keyboard
Keyboard US
Lang: Language type during installation
Lang Zh_cn. UTF-8
Part: partition layout and how partitions are used
Part/boot--FSTYPE=EXT4--size=200
Part swap--size=2048
Part Pv_name--size=51200--grow
Clearpart: Clear Partition
Clearpart--none--DRIVES=SDA
Volgroup: Command to create a volume group
Vo the group vg_name--pesize= 8192 pv_name
Logvol: The command to wear a logical volume
Logvol/home--FSTYPE=EXT4--name=lv_home--vgname=vg_name--size=10240
Logvol/var--FSTYPE=EXT4--name=lv_home--vgname=vg_name--size=10240
LOGVOL/USR--FSTYPE=EXT4--name=lv_home--vgname=vg_name--size=10240
ROOTPW: Indicates the root password of Superuser
ROOTPW--iscrypted $6$salt$encrypted_pass
TimeZone: Time zone
TimeZone Asia/shanghai
The command can be selected:
Install: New operating system installed
Upgrade: Upgrading and installing the operating system
Text: Install the operating system using the interface, default is GUI;
Network: Configuring the Networking Interface
Network--onboot Yes--device eth0--bootproto static--ip 172.16.72.1--netmask 255.255.0.0--noipv6--hostname a.link.co M
Firewall: Firewall settings
Firewall:--disabled
Firewall:--service=ssh
Settings for Selinux:selinux
SELinux--disabled
SELinux--enforcing
Off Topic:
If you plan to have the firewall and SELinux enforcement mode turned on, you can turn it off in dozens of ways:
Firewall
CentOS 6:
# Service Iptables Stop
#chkconfig iptables off
CentOS 7:
# Systemctl Stop Firewalld.service
# systemctl Disable Firewalld.service
If you want the firewall to temporarily not take effect;
# iptables-f applies to all CentOS system versions;
SELinux
1. Edit the SELinux configuration file/etc/sysconfig/selinux (/etc/selinux/config), in the configuration file, a line of statements is: selinux={disabled|enforce|permissive }
2. Edit the Grub startup profile/boot/grub/grub.conf
Kernel/vmlinuz-version-release ARGS selinux=0
If you want SELinux to temporarily not restrict user behavior:
# Setenforce 0 = = enforcing-permissive
# setenforce 1 = = permissive-Enforcing
# Getenforce
Repo: Install the system with the use of the repository
Repo--name= "CentOS"--baseurl=cdrom:sr0--cost=100
Repo--name= "CentOS"--baseurl=http://host[:p ort]/path--cost=100
Reboot: Restart after installation is complete
Halt/poweroff: Shut down the system after installation is complete
URL: Indicates the repository used at installation, but must use URL format;
URL--url=http://host[:p Ort]/path
Firstboot--disable: First boot off
Script segment:
%per: The beginning of the pre-installation script
Operating environment: The Linux system environment running on the installation ring;
%end
%post: The beginning of the post-installation script
Running Environment: Install the operating system after
%end
Package/Package Group segment: Indicates the package or package group to install and does not install the package;
%packages
@pack_group_name: Install a package group;
Pack_name: Installs a single specified package;
-pack_name: Explicitly indicate a package that is not installed; Sometimes the specified package may be installed (installed in other packages or dependent on other programs), even if it is explicitly indicated;
%end
How to create a Kickstart file:
1. Directly to the Anaconda-ks.cfg template, after the copy can be modified;
2. Tools can be used to create;
If the command does not exist, the Yum install System-config-kickstart installs;
# System-config-kickstart &
Can be created entirely new, can also be based on other KS files (such as anaconda-ks.cfg) to modify the generation of new configuration files;
3. Check the KS file syntax for errors:
Ksvalidator
If the command does not exist, you can install the Pykickstart-1.74.20-1.el6.noarch
Http://172.16.72.1/ks.cfg
Build a Web server with a CentOS7 by using one of the following methods:
Temporarily clean up the firewall rules and set SELinux to permissive mode:
~]# iptables-f
~]# Setenforce 0
Start the Web service
~]# systemctl Start Httpd.service
View the running status of the Web service, as long as there is a green text display of active (running), which is the normal start of the service;
~]# systemctl Status Httpd.service
Provides repository for CentOS 6
~]# Mkdir/var/www/html/centos_6_repo
~]# Mount/dev/sr0/mnt/cdrom
Note: The CD-ROM is placed in the CentOS6 installation CD CD1;
~]# cp-a/mnt/cdrom/*/var/www/html/centos_6_repo
To this, the configuration of the Web server is complete;
Create a bootable CD using one of the installed CentOS 6 operating systems:
Write the following to the kickstart file;
~]# vim/root/centos6-ks.cfg
#platform =x86, AMD64, or Intel EM64T
#version =devel
# Firewall Configuration
Firewall--disabled
# SELinux Configuration
SELinux--disabled
# Install OS instead of upgrade
Install
# Use Network Installation
Network--onboot Yes--device eth0--bootproto DHCP
URL--url= "Http://172.16.72.1/myrepo"
# Root Password
ROOTPW--iscrypted $1$irhppr42$vmesh73wbqhutjkp6oyod.
# System Authorization Information
Auth--useshadow--passalgo=sha512
# Use text mode install
Text
Firstboot--disable
# System Keyboard
Keyboard US
# System Language
Lang en_US
# SELinux Configuration
SELinux--disabled
# Reboot after installation
Reboot
# System TimeZone
TimeZone Asia/shanghai
# System Bootloader Configuration
Bootloader--append= "RHGB crashkernel=auto quiet"--location=mbr--driveorder= "SDA"
# Clear the Master Boot Record
Zerombr
# Partition Clearing Information
Clearpart--all
# Disk Partitioning Information
Part/boot--fstype= "Ext4"--size=200
Part pv.008--size=61440
Volgroup MYVG--pesize=4096 pv.008
Logvol/--FSTYPE=EXT4--name=root--VGNAME=MYVG--size=20480
Logvol Swap--name=swap--VGNAME=MYVG--size=2048
LOGVOL/USR--FSTYPE=EXT4--name=usr--VGNAME=MYVG--size=10240
Logvol/var--FSTYPE=EXT4--name=var--VGNAME=MYVG--size=20480
#repo--name= "CentOS"--baseurl=cdrom:sr0--cost=100
%post
Echo-e ' Qhdlink Linux for Learning services\nhttp://www.linklinux.com\n ' >>/etc/issue
Sed-i ' 1,[email protected]:[0-9]:initdefault: @id: 3:initdefault:@g '/etc/inittab
Ifconfig eth0 172.16.69.2/16
%end
%packages
@base
@core
@debugging
@basic-desktop
@desktop-debugging
@desktop-platform
@desktop-platform-devel
@development
@directory-client
@fonts
@general-desktop
@graphical-admin-tools
@input-methods
@internet-applications
@internet-browser
@java-platform
@legacy-X
@network-file-system-client
@office-suite
@print-client
@remote-desktop-clients
@server-platform
@server-platform-devel
@server-policy
@workstation-policy
@x11
Mtools
Pax
Python-dmidecode
Oddjob
Wodim
Sgpio
Genisoimage
Device-mapper-persistent-data
Systemtap-client
Abrt-gui
Desktop-file-utils
Jpackage-utils
Samba-winbind
Certmonger
Pam_krb5
Krb5-workstation
Openmotif
Libxmu
Libxp
%end
To create a bootable disc:
~]# mkdir Myiso
~]# Cp-r/mnt/cdrom/isolinux/root/myiso/
Note: This method of replication is to copy the Isolinux directory directly into the Myiso directory, that is, Isolinux is a subdirectory of Myiso;
~]# vim/root/myiso/isolinux/isolinux.cfg
Label Linux
Menu label ^install or upgrade an existing system
Menu default
Kernel Vmlinuz
Append initrd=initrd.img ks=cdrom:/centos6-ks.cfg
~]# cp/root/centos6-ks.cfg/root/myiso/
~]# mkisofs-r-j-t-v--no-emul-boot--boot-load-size 4--boot-info-table-v "CentOS 6 x86_64 Boot"-B isolinux/isolinux . bin-c Isolinux/boot.cat-o/root/boot.iso myiso/
Create a USB drive boot disk
Method One:
~]# DD If=/dev/sr0 OF=/DEV/SDB
Method Two:
~]# Fdisk/dev/sdb (divides the entire USB drive into one partition and modifies its partition type to VFAT, that is, use the T-to-B command to complete the conversion in Fdisk interactive mode)
~]# MKFS.VFAT/DEV/SDB1
~]# Mount/dev/sdb1/mnt/usb
~]# mkidr-p/mnt/usb/grub
~]# cp/mnt/cdrom/isolinux/{vmlinuz,initrd.img}/MNT/USB
~]# vim/mnt/usb/grub/grub.conf
Default=0
Timeout=5
Title The Linux boot from USB
Root (hd0,0)
Kernel/vmlinuz
Initrd/initrd.img ks=http://172.16.72.1/ks.cfg (Place the Centos6-ks.cfg file in the/var/www/html directory of CentOS7 and change the name to Ks.cfg)
~]# Grub
grub> Root (hd1,0)
grub> Setup (HD1)
Installation of #27 Linux system: CentOS department