Linux System Management Sixth week job "Linux Micro Jobs"

Source: Internet
Author: User
Tags gpg network function

1. Please describe in detail the start-up process of the CentOS system (detailed to what each process system does)

The CentOS system startup process is as follows:

POST--Boot Sequence (BIOS)--Boot Loader (MBR)--GRUB--Kernel (RAMDisk)--Rootfs --/sbin/init


(/etc/inittab,/etc/init/*.conf)--Set default run level--system initialization script--Shut down or start service at the corresponding level--start terminal


The specific work of each process is described below:

1. Power On Self test post

After the host power on, the first hardware self-test. After the host is powered on, the motherboard will automatically read the program in ROM and load BIOS information from the CMOS to check the integrity of various hardware devices, such as memory, hard disk, graphics card and various I/O devices. In case of hardware failure, will be processed in two cases: for serious failure (fatal failure) is directly down, at this time due to the various initialization operation is not completed, can not give any hint or signal, for non-serious failure, will give the corresponding prompt or sound alarm signal, waiting for the user to process. If no fault is encountered, the power-on self-test passes and the subsequent work is handed over to the BIOS for processing.

2. Boot sequence boot Sequence

After the post is completed, the system control is transferred to the BIOS (basic input/output system), the BIOS identifies the underlying hardware device with the preset parameters, initiates the hardware initialization, and then searches the boot devices in sequence according to the system boot order. The first device that has a boot program is the device (typically a local hard disk) for this boot. After the BIOS completes the related work, the subsequent work is handed over to the bootloader processing in the MBR.

3. Start Loading bootloader

The No. 0 first 0-channel 1th sector on the hard disk is called the MBR (Master boot Record), which is the master boot record. Although the MBR has only 512 bytes, it holds the first 446 bytes of the boot loader (Bootloader, which contains grub), the middle 64 bytes of the partition table (disk Partition table), and the last 2 bytes of the end identifier (Magic Number). The boot device reads the first 446 bytes of bootloader in the MBR looking for grub, then reads the sector after the MBR to identify the partition table DPT and the region where the kernel kernel, and finally starts grub.


4. Boot loader grub (GRand Uniform Bootloader)

Phase 1th (Stage 1)

Reads the MBR of the No. 0 first 0-channel 1th sector on the disk device, and is used to load the 2nd stage, storing only part of the bootloader code.

Phase 1.5 (Stage 1.5)

Reads the sector after the MBR, allowing the bootloader in phase 1th to identify the file system on the partition where the 2nd stage resides

Phase 2nd (Stage 2)

Locate the Grub configuration file (/boot/grub/grub.conf <--/etc/grub.conf or/boot/grub2/grub.cfg) and provide the user with an optional menu based on the preset content. Use to select the system or kernel version you want to start. Other core files, such as Linux kernel files (vmlinuz files) and virtual file system files (INITRAMFS), are also available under the Stage2-/boot/directory.

Finally, grub extracts, expands, and transfers control of the system to the kernel kernel by loading the user's selected boot system or kernel into a specific space in memory.


5. Load kernel

Self-initialization

Detect all the hardware devices that can be identified;

Load the hardware driver (it is possible to load the driver with RAMDisk);

Mount the root file system Rootfs in read-only mode;

Switch to root file system switchroot;

The first application running user space:/sbin/init

At this point, the kernel initialization is complete, the successor task to the user space program, only when the mode switch or system interruption, the kernel will participate.


6. Initialize Init

/sbin/init's main function is to prepare the system operating environment, including the host name of the system, network configuration, language processing, file system format and other services start-up, etc.

Types of init programs:

CentOS 5:SYSV Init

Configuration file:/etc/inittab


CentOS 6:upstart Init

Configuration files:/etc/inittab,/etc/init/*.conf


CentOS 7:systemd Systemd

Configuration files:/usr/lib/systemd/system,/etc/systemd/system


7. configuration file/etc/inittab, setting the default run level

Operating level: For the operation of the system or maintenance and other applications for the purpose of setting;

0-6:7 Levels

0: Turn off the machine

1: Single user mode (root, no login required), one, maintenance mode;

2: Multi-user mode, will start the network function, but will not start NFS; maintenance mode;

3: Multi-user mode, normal mode, text interface;

4: Reserved level, can be the same as 3 levels;

5: Multi-user mode, Normal mode, graphical interface;

6: Restart


8. configuration file/etc/rc.d/rc.sysinit, run the system initialization script, complete the system initialization

(1) Set the host name;

(2) Set welcome information;

(3) Activate Udev and SELinux;

(4) Mount the file system defined in the/etc/fstab file;

(5) Detecting the root file system and re-mounting the root file system in read-write mode;

(6) Set the system clock;

(7) Activate swap device;

(8) Set kernel parameters according to/etc/sysctl.conf file;

(9) Activating LVM and software RAID devices;

(10) Loading the drivers for additional devices;

(11) Cleaning operation;

9. Corresponding script, close the need to shut down the service, start the need to start the service

Depending on the runlevel, the system will run a/ETC/RC.D/RC0.D to/ETC/RC.D/RC6.D response script to complete the shutdown and startup of the corresponding service, and execute the user-defined boot loader script/etc/rc.d/rc.local.


10. Configuration file/sbin/mingetty, set the startup terminal

Mingetty will call the/etc/login program, after the successful login, the entire system startup process is complete.



2. Add a new piece of hardware to the CentOS 6 running on the virtual machine, providing two primary partitions;

(1) Create a new two primary partition for the hard disk, and install grub for it;

[[Email protected] desktop]# fdisk /dev/sdbwarning: dos-compatible mode is  deprecated. it ' s strongly recommended to          switch off the mode  (command  ' C ')  and change display  units to         sectors  (command  ' u '). command  (M&NBSP;FOR&NBSP;HELP): pdisk /dev/sdb: 21.5 gb, 21474836480  Bytes255 heads, 63 sectors/track, 2610 cylindersunits = cylinders of  16065 * 512 = 8225280 bytesSector size  (logical/physical):  512  bytes / 512 bytesI/O size  (Minimum/optimal): 512 bytes /  512 bytesdisk identifier: 0xac72d6fd   device boot       start         end      blocks   id   System/dev/sdb1                1         262     2104483+   83  Linux/dev/sdb2              263         524     2104515    83  LinuxCommand  (m for help):  q[[email protected] desktop ]# mke2fs -t ext4 /dev/sdb1mke2fs 1.41.12  (17-may-2010) Filesystem label=OS  type: LinuxBlock size=4096  (log=2) fragment size=4096  (log=2) stride=0  blocks, stripe width=0 blocks131648 inodes, 526120 blocks26306 blocks  (5.00%) &NBSP;RESERVED&NBSP;FOR&NBsp;the super userfirst data block=0maximum filesystem blocks=54106521617  block groups32768 blocks per group, 32768 fragments per group7744  inodes per groupSuperblock backups stored on blocks: 32768,  98304, 163840, 229376, 294912writing inode tables: done                              Creating journal  (16384 blocks): donewriting  Superblocks and filesystem accounting information: donethis filesystem will  be automatically checked every 28 mounts or180 days, whichever  comes first.  use tune2fs -c or -i to override. [[Email protected] desktop]# mke2fs -t ext4 /dev/sdb2mke2fs 1.41.12  (17-may-2010) Filesystem label=OS  type: linuxblock size=4096  (log=2) fragment size=4096  (log=2) Stride=0 blocks,  Stripe width=0 blocks131648 inodes, 526128 blocks26306 blocks  (5%)  reserved for the super userFirst data block=0Maximum filesystem  Blocks=54106521617 block groups32768 blocks per group, 32768 fragments  per group7744 inodes per groupSuperblock backups stored on  Blocks: 32768, 98304, 163840, 229376, 294912writing inode tables: done                              Creating journal  (16384 blocks):  donewriting superblocks and filesystem accounting information: donethis filesystem will  be automatically checked every 24 mounts or180 days, whichever  Comes first.  use tune2fs -c or -i to override. [[email protected] desktop]# mkdir -p /mnt/myboot /mnt/myroot[[email  protected] desktop]# mount /dev/sdb1 /mnt/myboot/[[email protected] desktop]#  mount /dev/sdb2 /mnt/myroot/[[email protected] desktop]# ls /mnt/myboot/ lost+found[[email protected]ocalhost ~]# grub-install --root-directory=/mnt/myboot / Dev/sdbprobing devices to guess bios drives. this may take a  long time. Installation finished. no error reported. This is the contents of the device map&nbSp;/mnt/myboot/boot/grub/device.map.check if this is correct or not. if  any of the lines is incorrect,fix it and re-run the  script  ' Grub-install '. (fd0)/dev/fd0 (hd0)/DEV/SDA (HD1)/dev/sdb[[email protected] ~]# ls /mnt/myboot/boot/grub


(2) Provide kernel and RAMDisk files for the first primary partition of the hard disk, and provide rootfs for the second partition;

[[email protected] ~]# cp /boot/vmlinuz-2.6.32-573.el6.x86_64 /mnt/myboot/boot/ vmlinuz[[email protected] ~]# cp /boot/initramfs-2.6.32-573.el6.x86_64.img /mnt/ myboot/boot/initramfs.img[[email protected] ~]# ls /mnt/myboot/boot/grub   Initramfs.img  vmlinuz[[email protected] ~]# mkdir -pv /mnt/myroot/{bin,dev , etc/{rc.d/init.d,sysconfig/network-scripts},lib/modules,lib64,proc,sbin,sys,tmp,usr/local/{bin,sbin},var/{ lock,log,run}}mkdir: created directory  '/mnt/myroot/bin ' mkdir: created directory   '/mnt/myroot/dev ' mkdir: created directory  '/mnt/myroot/etc ' mkdir: created  directory  '/mnt/myroot/etc/rc.d ' mkdir: created directory  '/mnt/myroot/etc/rc.d/init.d ' mkdir: created directory  '/mnt/myroot/etc/sysconfig ' mkdir: created directory  '/ Mnt/myroot/etc/sysconfig/network-scripts ' Mkdir: created directory  '/mnt/myroot/lib ' mkdir: created directory  '/mnt/myroot/lib/ Modules ' mkdir: created directory  '/mnt/myroot/lib64 ' mkdir: created directory  '/ Mnt/myroot/proc ' mkdir: created directory  '/mnt/myroot/sbin ' mkdir: created directory   '/mnt/myroot/sys ' mkdir: created directory  '/mnt/myroot/tmp ' mkdir: created  directory  '/mnt/myroot/usr ' mkdir: created directory  '/mnt/myroot/usr/local ' mkdir:  created directory  '/mnt/myroot/usr/local/bin ' mkdir: created directory  '/mnt/myroot/ Usr/local/sbin ' mkdir: created directory  '/mnt/myroot/var ' mkdir: created directory   '/mnt/myroot/var/lock ' mkdir: created directory  '/mnt/myroot/var/log ' mkdir: created  directory  '/mnt/myroot/var/run '


(3) for Rootfs to provide bash, LS, cat programs and the library files that depend on;

[[email protected] ~]# cp ' Ldd/bin/{bash,ls,cat} | Grep-oe "/lib.*[[:space:]" | Sort-u '/mnt/myroot/lib64/[[email protected] ~]# chroot/mnt/myroot/bash-4.1# Lsbin Dev etc lib lib64 lost+found PR OC sbin systmp usr varbash-4.1# exitexit[[email protected] ~]# sync


(4) Provide the configuration file for grub;

[Email protected] ~]# vim/mnt/myboot/boot/grub/grub.conf[[email protected] ~]# cat/mnt/myboot/boot/grub/ Grub.confdefault=0timeout=5title mycentos6root HD (0,0) kernel/vmlinuz ro root=/dev/sda2 selinux=0 init=/bin/ Bashinitrd/initramfs.img


(5) The new hard disk is set as the first boot item and can start the target host normally;

[[Email protected] ~]# Init 6

After rebooting, enter BIOS settings to adjust the drive boot sequence after saving exit.



3. Make a kickstart file and a boot image. Describe its process.

1. Make a Kickstart file

Typically through the System-config-kickstart tool (default system does not come with, need to install separately) or manually edit (can refer to/root/anaconda-ks.cfg) to create ks.cfg Kickstart file

The key fields are described below:

#version =rhel7# system authorization informationauth --enableshadow --passalgo=sha512 # use cdrom installation media#  installation media, either the optical drive or the specified URL path (HTTP or FTP) cdrom# run the  Setup Agent on first boot#  First boot Disable proxy firstboot --disableignoredisk -- only-use=sda# keyboard layouts#  keyboard style keyboard --vckeymap=us --xlayouts= ' US ' #  system language#  system language Lang en_us. utf-8# network informationnetwork  --bootproto=dhcp --device=eno16777728 -- onboot=off --ipv6=autonetwork  --hostname=localhost.localdomain# root password#  Encrypted root password rootpw --iscrypted $6$vrl5auhw0kqkjl36$nkjrp/ jgtipv65zahksa.t2jrehzbeqluu1vhqhfldaj2zin4p74mg6o96ac3nkjnddw2vvq4kisw7wt8x2tj.# system timezone#   System time Zone timezone asia/shanghai --isutc# x window system configuration  informationxconfig  --startxonboot# system bootloader configuration#  system Boot configuration, bootloader --the MBR installation boot program location=mbr --boot-drive=sdaautopart --type=lvm# partition clearing information#   Empty all disk contents and initialize clearpart --all --initlabel# disk partitioning information#  Custom partition Part /boot --fstype= "Ext4"  --size=500part swap --fstype= "swap"  --size= 2000part / --fstype= "Ext4"  --grow --size=1# Firewall configuration#  The firewall is set to off Firewall --disabled# selinux configuration# selinux set to Disabled selinux --disabled#   Package Segment% Packages@base@core@desktop-debugging@dial-up@fonts@gnome-desktop@guest-agents@guest-desktop-agents@input-methods@internet -browser@multimedia@print-client@x11%end


2. Prepare the system ISO image (RHEL7) and copy to the boot image you want to create

[[email protected] ~]# mount /dev/cdrom /media/cdrom/[[email protected] ~]#  cd /media/cdrom/[[email protected] ~]# mkdir /mnt/iso[[email protected]  cdrom]# ls -altotal 819dr-xr-xr-x. 10 root root   4096  May  7  2014 .drwxr-xr-x.  3 root root    &NBSP;&NBSP;18&NBSP;AUG&NBSP;&NBSP;2&NBSP;&NBSP;2016&NBSP, .... dr-xr-xr-x.  4 root root   2048 may  7  2014  Addons-r--r--r--.   1 root root     48 May  7   2014 .discinfodr-xr-xr-x.  3 root root   2048 May   7  2014 efi-r--r--r--. &NBSP;&NBSP;1&NBSP;ROOT&NBSP;ROOT&NBSP;&NBSP;&NBSP;8266&NBSP;APR   4  2014 eula-r--r--r--.   1 root root  18092 mar  6  2012 gpldr-xr-xr-x.  3 root  Root   2048 may  7  2014 imagesdr-xr-xr-x.  2 root  root   2048 may  7  2014 isolinuxdr-xr-xr-x.  2  root root   2048 may  7  2014 liveos-r--r--r--.    1 root root    108 May  7  2014  media.repodr-xr-xr-x.  2 root root 774144 may  7  2014  packagesdr-xr-xr-x. 24 root root   6144 may  7  2014  release-notesdr-xr-xr-x.  2 root root   4096 may  7   2014 repodata-r--r--r--. &NBSP;&NBSP;1&NBSP;ROOT&NBSP;ROOT&NBSP;&NBSP;&NBSP;3375&NBSP;APR   1  2014 rpM-gpg-key-redhat-beta-r--r--r--.   1 root root   3211 apr  1   2014 rpm-gpg-key-redhat-release-r--r--r--.   1 root root    1568 may  7  2014 trans. Tbl-r--r--r--.   1 root root   2166 may  7  2014  .treeinfo[[email protected] cdrom]# cp -a * /mnt/iso/[[email  protected] cdrom]# cp .discinfo /mnt/iso/


3. Integrate the completed KS file with the image file

[[email protected] cdrom]# cp /root/ks.cfg /mnt/iso/isolinux/[[email protected]  cdrom]# cd /mnt/iso/isolinux/[[email protected] isolinux]# lltotal 72840- R--r--r--.  1 root root     2048 may  7  2014  boot.cat-r--r--r--.  1 root root       84 may   7  2014 boot.msg-r--r--r--.  1 root root       321 may  7  2014 grub.conf-r--r--r--.  1 root root  35544564 may  7  2014 initrd.img-r--r--r--.  1 root root     24576 may  7  2014 isolinux.bin-r--r--r--.  1  root root     3166 may  7  2014  ISOLINUX.CFG-RW-------.  1 root root     1044 jun 21 00:48 ks.cfg-r--r--r--.  1 root  Root   176500 jan  2  2014 memtest-r--r--r--.  1 root  root      186 Mar  3  2014  Splash.png-r--r--r--.  1 root root     2438 May  7   2014 trans. Tbl-r--r--r--.  1 root root 33744152 May  7  2014  Upgrade.img-r--r--r--.  1 root root   155792 feb 28  2014  vesamenu.c32-r-xr-xr-x. 1 root root  4902000 May  5   2014 vmlinuz


Modify the Isolinux.cfg configuration file to add the KS file read path in append initrd=initrd.img inst.ks=cdrom:/isolinux/ks.cfg

[Email protected] isolinux]# vim isolinux.cfg [[email protected] isolinux]# Cat Isolinux.cfg | grep ks append initrd=initrd.img inst.ks=cdrom:/isolinux/ks.cfg inst.stage2=hd:label=rhel7 quiet


4. Create a bootable disc

[Email protected] isolinux]# mkisofs-r-j-t-v--no-emul-boot--boot-load-size 4--boot-info-table-v "RHEL 7.0 x86_64 Boot "-B isolinux/isolinux.bin-c isolinux/boot.cat-o/root/rhel7.iso/mnt/iso/[[email protected] isolinux]# LL/ROOT/RH El7.iso-rw-r--r--. 1 root root 3843938304 June 01:11/root/rhel7.iso

Linux System Management Sixth week job "Linux Micro Jobs"

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.