Linux Basic Knowledge Learning-linux architecture

Source: Internet
Author: User
Tags generator dmesg

Hard disk partition:

First sector (512bytes):
Msr:master Boot Record (446bytes) primary boot partition
Partion table: (64bytes) partition table, four. It can be a primary partition (primary) or an extended partition (Extended), with each table pointing to a segment of the disk. There is at most one extended partition where multiple logical partitions can be extended.
Remaining sectors (cylinders (cylinder)): where they are actually stored


In Linux (\etc/fstab):
IDE bus in different form (A~D)
/dev/hda

Sata,scsi,usb (A~P)
/DEV/SDA1 C Primary partition (extended partition)
/dev/sda2 D
/dev/sda3 E
/DEV/SDA4 F

/DEV/SDA5 Logical Partitioning
/dev/sda6
/DEV/SDB1 u disk hangs to/mnt
/dev/cdrom->sr0 disc to/media or/mnt


Linux ext2 File System:
Block0, Block1, Block2, Block3 ...
Boot sector
Superblock Super block, storage disk overall information, inode number, block number
Usage of inode bitmap inode
Use of block bitmap block
Inode table Each file corresponds to an inode, which holds the permissions and attributes of the file. bytes
The data block stores the actual information of the file. There are 1k, 2k, 4k.

Linux System kernel Modules
1.MMU Memory Management Module 123456

2.FS File System Management
3. Process Management
4. Process scheduling
5. Network Device Interface

Linux system hierarchy

1.linux Kernel (kernel)
Linux 3.1.0-7.fc16.i686. Kernel version, odd beta, number of modifications
2.linux API Interface
3.shell
4.utilities Utility Program

Start loading in Windows:
BIOS: Firmware program, after power on the Hardware detection box resource allocation, the boot program read into memory, jump to the boot program entrance.
Boot: GRUB (or LILO), reads the kernel into memory and jumps to the kernel entry point to run.
Linux system boot Boot mode:
Bootloader: (Vivi,u-boot)
Stage1:=bios
Stage2:=grub

Operating level:
/etc/inittab Storage

Start the first run: Inix process, PID 1;


LINUXT System Terminal mode:
1. Character Terminal runlevel 3:tty1~tty6 (command line)
2. Graphics Terminal runlevel 5:tty7 (init->x window SYSTEM->X11->->->GNOME,KDE Administrator)

View all logged Linux system users (end users)
W.H.O.
pts/0: Virtual end user (under graphical interface)
Tty1: Login System User (Tty1-tty6 under character terminal)

The control terminal automatically runs a shell, that is, the/bin/bash process, to parse the input command at any time, once the command input LS, fork to create a child process/bin/bash,exec will/bin/ls the program's code data replacement, that is, the execution of LS code.

Log in to the system user name
WhoAmI

Linux file system
Fhs:filesystem Hierarchy standard file system layering standards
/boot system related (boot restore repair, partition to small)
/usr software installation, execution related (Unix software resource, partition Large)
/var system operation (variable, partition large point)

*********************************************************************
Bin: A program that can be executed in single-user mode, which can be executed by the root user and the general user

Sbin: Important System program, only the root user can execute (generally used to set the system environment)
Other system commands, Server software program/usr/sbin self-installing software program/usr/local/sbin

ETC: Configuration file
Boot configuration:/etc/inittab,/etc/rc.d/*,/etc/init/*
Service startup script:/etc/init.d/*
Boot script:/etc/rc.d/init.d/*
System configuration:/etc/sysconfig/*
XINETD Service Management Service configuration:/etc/xinetd.d/*


Dev: Device mapping file.
hd*, sd*, sdb1u disk, CDROM disc, lp* printer, TTY terminal,
NULL, zero
Stdin,stdout,stderr

LIB: library file (. So)
1. The link library to use when booting up
/lib/modules driver modules loaded at boot time
2./bin and/sbin commands used in the link library

*********************************************************************

Boot: System boot file (Grub boot directory)
1.Linux Kernel file vmlinuz-2.6.32-131.12.1.1.ky3.2.x86_64
2. Memory virtual file system for booting initramfs-2.6.32-131.12.1.1.ky3.2.x86_64.img
3.grub Catalog
MENU.LST Boot Program Grub configuration file
Other boot profiles

*********************************************************************

Usr:unix software resources that can be shared immutable.
The bin software program, most of the users can use commands are placed here. (Boot Independent)
Header files included in the Include program
LIB program runs the link library
Local software, including directories such as Bin,etc,include,lib
USR General place software source code

*********************************************************************

var: dynamically generated files after the system runs the service
LIB Storage program data file
Mysql:mysql database,
rpm:rpm Database
Log file
Messages error Log
WTMP Login Log
Spool queue data
At once execution script
Cron Cycle Routine Work script
Run Process PID
Mail Personal e-mail

*********************************************************************

Root: Administrator Directory
Home: User home Directory

Media: Mount Disc/media/cdrom
MNT: Mount directory. Similar to/media, it can be used to mount a USB flash drive.

TMP: Temporary data is stored, accessible by anyone, and can be deleted periodically

Data for the SRV Network service. WWW,FTP and other data Catalog

LOST+FOUND:EXT2/EXT3 file system, when an error occurs, place some missing fragments in this directory.

Proc: In-memory kernel, process, device, network status and other data
SYS: in-memory kernel, file system and other data

OPT: Third party software catalog, similar to/usr/local
*********************************************************************

Linux file Type: (7 Types of S_isreg (St->st_mode))
-:reg General Documents
D:dir Directory File
L:lnk Link File
B:block Block device files
C:CHR Character device files
P:pipe Pipeline File
S:socket Socket File


File Mode (mode_t St_mode s_irusr,s_iwgrp,s_ixoth)
rwx-w-r--read4,write2,execute1 111 010 0724 (octal)


Various:
uboot:ftp://ftp.denx.de/pub/u-boot/
Linux kernel:http://www.kernel.org
busybox:http://www.busybox.net/

Hardware->bootloader->kernel Kernel->utilities utility
(Process 0->init1->tty terminal, command (program), thread)

Linux Boot details:
First, the BIOS
System Information CMOS, hardware detection, read MBR go to Grub

Second, mbr-grub,bootload boot loader program
When installing Windows and Linux, each of the respective file system partitions has a separate grub,windows. Grub is installed in the MBR by default, and Linux can choose not to install in the MBR.
Bootload:
1. Startup options
2. Loading the kernel
3. Transfer other loader (Windows None, Linux has. )

Iii. loading the kernel kernel and initrd making the virtual file system to load the driver module
Bootload load/boot/vmlinux-2.6.18-92.e15, unzip the kernel files into memory, and use the kernel functions to start testing and driving various peripherals, including storage devices, CPUs, network cards, sound cards and so on. At this point, the Linux kernel will re-detect the hardware with its own functionality, rather than using the hardware information detected by the BIOS.
(At this time the kernel does not have the drive does not know the SATA disk, unable to load the/lib/modules/directory system module, IDE,EXT2/EXT3 can.) )

Bootload load/boot/initrd-2.6.18-92.e15.img, unzip to Initialram disk virtual file system root directory (read-only), kernel to load the required/boot/modules under the System module (hardware-driven) , eventually release the virtual file system and mount the actual directory file system.


Iv. start the first process init
/etc/inittab:
1.id:5:initdefault: Get the default run level setting
# 0-halt (do not set Initdefault to this)
# 1-single user mode single customer Maintenance mode
# 2-multiuser, without NFS (the same as 3, if you don't have networking)
# 3-full Multiuser mode
# 4-unused
# 5-x11 Graphical interface
# 6-reboot (do not set Initdefault to this)
2.si::sysinit:/etc/rc.d/rc.sysinit Boot System Environment initialization configuration
? Access to network environment and host type
? Test mount and Mount devices/proc and USB devices/sys
? Decide whether to start SELinux
? Random number generator to start the system
? Set the terminal font
? Set the Welcome screen to be displayed during startup
? Set system time and time zone settings: Read-in/etc/sysconfig/clock setting value
? Detection of interface devices and testing of Plug and Play parameters
? User-defined module loading
? Loading the relevant settings for the kernel
? Setting the hostname and initializing the Power management module
? Initialize the software disk array: mainly through/etc/mdadm.conf
? Initialize the file system capabilities of LVM
? Check disk File system with Fsck: FileSystem check
? Conversion of disk quota quota
? To mount system disks again in read-write mode
? Start the quota function, so we don't need to customize the Quotaon operation
? Start System pseudo-random number generator
? Clear the temporary files for the startup process
? Loads the information about the launch/VAR/LOG/DMESG

A lot of work is configured in/etc/sysconfig.
Custom Module Loading:/etc/sysconfig/modules/* configuration file/etc/modprobe.conf
Launch related information on/VAR/LOG/DMESG

3.10:0:WAIT:/ETC/RC.D/RC x Service Program to start Renlevel x
Execute RC to start the service script under/etc/rcx.d/under the/etc/init.d/of each link file, kxx,sxx is executed in numerical order,
These linked files can be managed using the Chkconfig command.
/etc/rc.d/rc.local for each service after the start of the customized boot script, you can add their own script.
Use RunLevel to get the current run level. Later in the run when you want to modify the operating level, with the Init X, then two/etc/rcx.d K and s file comparison, keep the same, close redundant, Start No. You don't have to restart it.


4. Set Ctrl+alt+del Restart key
5. Set up the power system ups
6.1:2345:respawn:/sbin/mingetty Tty1 runs at 2345 levels, it opens the Tty1-tty6 terminal, which can be removed.
7.x:5:respawn:/etc/x11/prefdm-nodaemon the command that executes when running at level 5.

Init configuration file after the 2.6.32 version:
# Inittab is a used by upstart for the default runlevel.
# ADDING Other CONFIGURATION here would have NO EFFECT on YOUR SYSTEM.
# System initialization is started by/etc/init/rcs.conf
# individual runlevels is started by/etc/init/rc.conf
# Ctrl-alt-delete is handled by/etc/init/control-alt-delete.conf
# Terminal Gettys is handled by/etc/init/tty.conf and/etc/init/serial.conf,
# with configuration In/etc/sysconfig/init.
[[email protected] init]# ls
control-alt-delete.conf rc.conf serial.conf
init-system-dbus.conf rcs.conf splash-manager.conf
kexec-disable.conf rcs-sulogin.conf start-ttys.conf
plymouth-shutdown.conf readahead-collector.conf tty.conf
prefdm.conf readahead.conf vmware-tools.conf
Quit-plymouth.conf readahead-disable-services.conf


Kernel and kernel modules

Kernel:/boot/vmlinuz
RAMDISK:/BOOT/INITRD required to decompress the kernel
Kernel module:/lib/modules//$ (uname-r)/kernel
Kernel Source:/usr/src/kernels
Kernel version:/proc/version
System kernel function:/proc/sys/kernel


Module Management:
Kernel module dependencies:/lib/modules/$ (uname-r)/MODULES.DEP
The Depmod analyzes the dependencies of the relevant modules, and the results are written to the Modules.dep file.
Additional parameters for kernel modules:/etc/modprobe.conf

Lsmod
Insmod
Modprobe can overcome the dependency problem of the module.
Rmmod


Related Article

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.