first, disk basic knowledge
1, disk and hard disk are all the unified address of the disk storage system. When the disk is working, the head is suspended in a radial motion above the disk platter, without touching each other.
2. Purchase Disk:
(1) Spindle speed speed fast (r/min), 5400/7200/10000/15000;
(2) interface type:sata/sas/scsi/ide; SAS usage in the enterprise environment is more common .
(3) Read and write more sensitive heads;
(4) Large capacity, enterprise-class SAS mainstream hard disk capacity of 300G, 600G, 1000G, the proposed 300G, 600G is preferred, more for the online services to serve the Business Server; Enterprise SATA mainstream HDD capacity 1T, 2T, 4T, It is used for servers that do not provide services offline or do not have a large number of concurrent business visits.
SAS for online business use, SATA for offline business, tape library, high-volume, low-capacity business SSD (with hard disk plus memory caching technology to solve large-scale concurrency problems).
(5) SSD hard disk performance is much larger than mechanical hard disk;
3. The Linux system uses the physical memory that the system does not use as the buffer or buffers, buffer is the write buffer, Synca writes the buffer data to the disk, and the cache is the buffer to read the data.
4, mechanical hard disk read and write speed is too slow, so in the portal architecture site, read and write to use cache buffering technology.
5. Internal disk structure
(1) A disk has multiple platters, each with two discs and two heads (head) per disc.
(2) on the same platter, all concentric circles with different radii are called tracks.
(3) At the center of the disc, a straight line is drawn to the edge of the disc, and a plurality of sector regions are called sectors (sector).
(4) a cylinder (cylinder) is a cylindrical set of all tracks of the same radius on all disks, from top to bottom, and the number of cylinders equals the number of tracks on the disc.
(5) The size of each sector is typically 512 bytes.
(6) A cylinder contains multiple tracks with the same radius, and one track contains multiple sectors.
(7) Track size = sector size (512 bytes) x sector number;
Disk size = track size x number of tracks;
Disk size = cylinder size x number of cylinders;
Cylinder size = Track size x number of heads;
Disk capacity = Disc size X number of discs = sector size x sectors x number of tracks x number of tracks (heads).
6. Disk Partitioning
(1) The 0 heads of the disk 0 tracks 1 sectors are stored with the master boot record MBR and the hard disk partition table DPT. The role of the master boot record MBR is to check that the partition table is correct and that the partition is the boot partition, and that the boot partition's boot program is transferred to memory usage at the end of the MBR boot.
(2) disk partition in the real 64bytes partition table to be reset, mainly dividing the beginning of the end of the magnetic number, sector code, cylinder number.
(3) The partition table of a disk is only 64bytes in size, and each partition table is 16bytes, so a disk can support up to 4 partitions, i.e. no more than 4 primary partitions + extended partitions.
(4) Disk partitioning is divided by cylinder.
(5) A hard disk can only have one extended partition, the extended partition cannot be used directly, and the logical partition must be created on the extended partition. An extended partition has its own partition table, so you can create multiple logical partitions.
(6) The primary partition is a partition that must exist on the disk, and the system can be installed on the primary partition.
(7) The logical partition must exist in the extended partition, and the logical partition number starts at 5.
7. Partitioning Tools
(1) is generally installed after the system with Fdisk partition, the system before the partition, most of the system ISO inside the tool points, or RAID sub-small disk.
(2) Fdisk can only be used by the root user.
(3) MBR cannot support hard disk partition larger than 2T, GPT can support hard disk partition larger than 2T;
(4) Disk partitioning tool: fdisk (suitable for less than 2T of disk partition), parted (good at more than 2T disk partition, also can give less than 2T disk partition), preferred Fdisk, more than 2T disk partition and then select parted
(5) Partitioning with FDISK is appropriate for partitioning the remaining space after the system is installed, such as not all partitions when installing the system or installing the system and adding partitions.
(6) Disk partitioning tool parted each step is in real time, and Fdisk does not take effect if no w is executed.
8. Swap partition Construction
(1) Swap partition in the actual work, especially in the Java environment, the program writes a problem when the memory leak occurs, will occupy the swap partition. (Workaround: Generally modify the program, or enlarge swap, or swap off and then on)
(2) Using physical partitions (or using files) to expand Swap:fdisk/dev/sdb #分一个分区/dev/sdb1 out; mkswap/dev/sdb1 #将分区fdisk/dev/sdb1 set to swap; Free #查看; swapon/dev/sdb1 #使分区/dev/sdb1 effective; free #查看;
9. File System:
(1) file system is a mechanism or method of storing and organizing computer data, which makes access to computer internal data easy (the file system is a set of abstract data model which realizes data storage, hierarchical organization, access and acquisition etc.). Common file systems: Ext2,ext3 (CentOS 5.x), Ext4(CentOS 6.x),xfs, Zfs,reiserfs,fat,NFS,ISO9660.
(2) The disk partition is not directly hanging in the directory to hold the data entity, but also need to format the operation to store data, format is to write to the disk partition to the file system before the system can be recognized to store data.
(3) the data in the operating system is divided into file content and file attributes, the operating system writes file attributes to the Inode, writes the contents of the file to block, and the operating system also adds the overall information of the filesystem (called the metadata metadata). Includes the total number of inode and block for the entire file system, the amount of usage, unused information, written in Superblock.
(4) File system disk layout
(5) File System selection
10, Mount point
(1) Mount: An operation that combines a file system with a directory tree is called a mount.
(2) Mount point must be a directory, mount point is the directory into the file system entrance.
11. File System Operation command
(1) DF lists the disk usage of the file system;
(2) du evaluation file system usage
(3) ln link file
(4) fdisk/parted disk partition
(5) MKFS disk partition format
(6) fsck (e2fsck)/badblocks ext4 (ext2) disk inspection (normal use of the disk must not be used!)
(7) Mount/unmount mount/Uninstall
(8) Partprobe notify the kernel of changes to the partition table
(9) Mkswap formatted swap partition
Swap on/off/non-use swap partition
(one) DUMPE2FS view ext file System Information
(TUNE2FS/RESIZE2FS) modify file system parameters
(MEGACLI) View raid information
(ipmitools) View hardware information
Second, the disk array (redundant Arrays of inexpensive disks,raid), a number of independent physical disks in different technical ways to form a disk group, expand the disk capacity, improve the disk system security and stability performance and read and write performance, Provides a technique for varying levels of redundancy.
RAID technology is divided into: soft raid technology and hard raid technology. Soft raid technology, cost-saving, poor performance, affected by the system, rarely used in the work. Hard RAID technology, excellent performance, with detection and error correction repair capabilities, common use in the work
1, RAID 0: Also known as stripe mode, RAID 0 continuously split the data in bits or bytes, parallel execution read/write on multiple disks. Fast, no redundancy, no loss of capacity, at least 2 pieces of disk required. Enterprise Flixbox also to be made into RAID 0, otherwise cannot be used.
2, RAID 1: It is through the disk data mirroring to achieve data redundancy, on paired independent disks to produce data backed up to each other.
There is redundancy, no increase in speed, half the capacity loss, only 2 disks (preferably using the same size of two disk).
3, RAID5: Do not back up the stored data, but the data and the corresponding parity information stored on the various disks that make up the RAID5, and the parity information and the corresponding data are stored on separate disks. When one of the RAID5 disk data is damaged, the remaining data and the corresponding parity information are used to recover the corrupted data. A minimum of 3 disk RAID5 after the disk capacity =n-1,n the total number of disk bits.
Multi-use RAID 5 + hot spare in enterprise (redundant backup)
4, RAID 10: (also known as RAID 0+1) is a combination of disk segmentation and mirroring, using 2 groups of RAID0 disk arrays to mirror each other, they become a RAID1 array. The high speed and RAID 1 data of RAID 0 are also highly reliable, but the CPU usage is higher and the disk utilization ratio is low. At least 4 disks are required.
Redundancy from good to bad: Raid1 raid10 RAID5 raid0;
Performance from Good to Bad: raid0 raid10 RAID5 RAID1;
Cost from low to High: RAID0 RAID5 raid10 RAID1;
Select the corresponding level according to the storage and access requirements.
Single server, disk not many, data important, select RAID 1;
Database server, main library RAID 10, from library RAID 5 (for cost also optional RAID0 or RAID 10);
Web server, not much data, RAID 5 or RAID0, monitoring or other application server, single-disk RAID0, multi-disk RAID5.
Third, LVM: Logical volume management, for flexible dynamic management of disk capacity, efficient use of disk space.
1, LVM: Flexible dynamic management of disk capacity, has a certain degree of redundancy performance, but very weak; RAID: Focus on performance and data security.
Linux disk knowledge, RAID,LVM