Disk partitioning, file systems, soft links and hard links, memory and process management

Source: Internet
Author: User
Tags disk usage file permissions pkill

(a) disk partitioning

1. The hard disk is logically divided into: block--track--Magnetic column--partition;

2. Partition classification: Primary partition, extended partition, logical partition

3. Command:

SDB---The 2nd disk of the SCSI interface, the path is/DEV/SDB

/DEV/SRO----discs, like/DEV/SDA/DEV/SDB/DEV/SDB2, which we can call a device name.

The DF command is used to check the disk space usage of the Linux server's file system, Df--diskfilesystem file system

FDISK is adding, deleting, converting partitions to disk

Fdisk-l/DEV/SDA view hard Drive actual usage

FDISK/DEV/SDA Specify hard disk File/Enter hard disk partition mode

Df-t Viewing file types

DF-H displays current disk space and usage in an easier way

Df-i an inode mode shows disk usage

Df-a Show all file system list

4. Disk Partitioning steps:

(1) Partitioning the hard disk

A. Fdisk/dev/sdb

B. N---p--Default--default--W save primary partition settings

C. L Extended partition---E logical partition

(2) Make partition file system (or format file system)

MKFS.EXT4/DEV/SDB1 SDB1 partition into a ext4 format file system

MKFS.XFS/DEV/SDB2 SDB2 partition into XFS-formatted file system

Note: Ext4 and XFS belong to log system files; MKFS----makefiles

(3) Setting up mounts

A. Creating a mount point directory: MKDIR/SDB1

B. Establish a mapping relationship, pull the pipe

MOUNT/DEV/SDB1/SDB1 will/dev/sdb1/open a hole point to/SDB1 data is actually stored in/DEV/SDB1,/SDB1 is a mapping directory

Compared to the MOUNT/DEV/SDB1/SDB1 and Mount/dev/sdb1/sbb1 found/SDB1 and/sdbb1 all point to/dev/sdb1 that a device name can map different hanging points,/sdb1 and/SDBB1 enter/DEV/SDB 1 Like a house with 2 doors open.

Add: Unload mount point: UMOUNT/SDB1 can also be used UMOUNT/DEV/SDB1 general with mount point unloading, with the device name uninstall because the same device name can have multiple mount points, may uninstall chaos, it is recommended to use the Umount + mount point method to unload

(4) can be used: CD/SDB1

5.swap Partitioning

View Swap partitions: swap-s

New Swap partition:

(1) Set up mount point: Mkswapon/dev/sdb8 (/DEV/SDB8 for bare disk, not mounted file system)

(2) Activation mount: Swapon-a/DEV/SDB8 A is activity

(ii) Documentation system

The current file system is etx4 and XFS, both of which are lost in the log file system. File system manages file data. File data sub-file itself (file content i.e. data), file permissions (rwx) and file attributes (owner, genus, time parameters)

1. Units: Block blocks

2. Category: Class 4

(1) Super BLOCK: Super blocks, management records the entire file system overall information, such as the total number of inode and block, the amount of use and the amount of surplus, etc.;

(2) Inode block: Type of storage file, owner, group, permission, pointer (block number);

(3) directory block: directory blocks, only the file name and file name corresponding inode number;

Note: inode block, log file properties, a file occupies a block number, while recording the data of this file block number;

Block blocks: Record the contents of the file, if you can refer to the file inode, you will naturally know the file to place the block number of data, you can read the actual data.

3. Command:

Ls-i/ect/passwd Check the inode number of this file

Df-i using inode numbers to display disk usage

Inode number of the Ll-di/test directory

Ls-i/test/a.txt a.txt inode number

Tune2fs-l/dev/sdb1 View File system parameters (only if the file system is EXT2/3/4)

Touch/sdb7{1..5}.txt set up 1.2.3.4.5.txt 5 files at a time

DU-SH/SDB7 view/SDB7 used space size

4.cat/a.txt internal working mechanism

The operating system actually calls the filesystem to complete the cat/a.txt, which is done by the file system.

----first read the root inode number, permissions, pointers

----"point to the directory block, locate the file name A.txt and the inode number

----"According to the file inode number to the file type in the Inode block, the permission pointer

----the normal block block that points to the actual data stored

(iii) Soft links and hard links

Soft links and hard links involve index nodes in the file system (index node, also called Inode), and the index nodes are one of the four key concepts of the Linux virtual file system.

1. Soft Links: Shortcuts under the same Windows

(1) Command: Ln-s/source/a.txt/dst/aa.txt (aa.txt not exist)

Ln-s source file path Link file path

* Soft link with "l" means file type

* Change the content of the source file, the content of the linked file also changed, changed the content of the linked file, the source file has changed, the source file is deleted, the linked file is not;

* Soft connection files can be cross-partitioned

(2) How source files and soft link files work

How the source file works:

Source Files-(1)-->inode No.-(2)->block data

How the soft link file works:

Linked files-(1)--Source Files-(2)-->inode-(3)->block data

Note: The link file itself also has an inode number, but it first looked for the source file name, the soft link to the file name

2. Hard Links:

(1) Order:

Ln/b.txt/c.txt ln + source file path + link file path

2. How hard links work:

B.txt------------>inode<---------c.txt inode-------->block

* B.txt and C.txt share the same inode number

* Operation B or c.txt, the other side changes synchronously

* Hard Link Delete source file, link file is still in, can continue to use

* Hard links can not cross partitions

(d) Memory

1. Command:

Free view memory Information free-m view memory information in megabytes

Swapo-s Swap Memory partition

SWAPOFF/DEV/SDB8 Uninstalling a Swap partition

Echo 3 >/proc/sys/vm/drop_caches Clean up the virtual machine caching (Cache) command

A more amateur test drive read and write ability of the command:

DD If=/dev/zero of=/a.txt bs=1g count=1 (If---input file of-----output file)

2. Memory mainly consists of buffer and cache

Buffer: Something that has not been written to the disk for data to be stored on the hard disk

Cache: Read into memory from disk, store data read

Shared memory is primarily multiplexed

* Memory is allocated buffer and cache, allocated buffer and cache are divided into the use of buffer and cache, and unused buffer and cache.

* Memory Utilization = buffer and caceh/total in use

* Memory True Remaining amount contains allocated unused buffer and cache;

(v) Process management

1. Concept

Process: A dynamic execution of a program

Daemon: Some processes that run in the background and provide system services

Parent/child Process: When a process creates another process, the first process is called the parent process of the new process, and the new process is called the child process

Zombie Process: The CPU does not invoke processes that are not coming out of the CPU, such as the parent process is dead, the child process is still in

2. Command

PS View process PS aux process details

PS aux | grep Gnome finds information about a process, such as GNOME (grep filtering means)

Pgrep + process name display process PID

Kill PID killing Process kill-9 pid forced kill process

pkill-9 + process Name---> pkill-9 firefox kill Firefox process

Process name + & let the process run in the background to not occupy the current terminal------>firefox &

Pstree Check all user processes

Pstree + Username user name running process

Buffer and Cache

Disk partitioning, file systems, soft links and hard links, memory and process management

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.