8.1.1, Linux file system storage space is divided into (data area and metadata area), GeneralHardDisksector is2 bytes, a block (block) can contain (2, 4, 8 different sectors), a piece can belong to only one file but a file may contain more than one block, stat can view the metadata (file name, size, timestamp, permissions, owner, genus, the corresponding data stored on which disk block), LS- I can view the inode number of the file, and each number corresponds to the storage area on the disk, but the file name is not stored in the inode but is stored in the parent directory, so the file name and inode correspondence are stored in the directory data area.
8.1.2, because the inode number is too many to find whether the inode uses the comparative consumption of resources, in order to find the unused inode more quickly to index the inode is called the bitmap (bitmap index) inode bitmap, the corresponding block will also do block bitmap (block bitmap), So the metadata area is stored (inode, Ionde Bitmap, block bitmap), data storage method: Each time will take 8 unused disk blocks for storage, if only one will put unused blocks back enough to take 8 unused disk blocks, There are 2 evaluation models for evaluating disk performance (random IO and continuous IO: The disk reads and writes are done by the robotic arm, and if the data is continuous storage will increase read and write speed, and the chaos will affect read and write performance)
8.1.3, in order to facilitate the management of the block divided into block groups, each block group has a separate data area and metadata area, block group of metadata information and block groups run between the Super block coordination, and in multiple block groups will have super block backup, TUNE2FS can view the partition's Super Block information example: tune2fs-l/ DEV/SDA1, you can also view the block group information in the partition by DUMPE2FS example: DUMPE2FS/DEV/SDA1 plus-H can also view the Super block information
8.1.4, linked files: 2 files point to the same inode, at which point a file is called a hard link to another file, when a file points to another file path when this file is called a soft connection also known as the word linked, LN-SV create a soft link, An inode can be referenced several times with its counter calculation: it will not be marked as unused until the reference is reduced to 0.
8.1.5, hard links (you cannot create hard links to a directory, you cannot span partitions, you increase the Inode reference count, soft connections can be created on a directory, are not restricted by zoning, and do not increase the reference count). File deleted: Delete path only, Inode point to disk block is marked as free, file copy: Create a new file and write the original file to disk block again, file move: Move in same partition: File only changes file access path, move across partition: Create file in new partition, copy data past, Delete the original partition data.
8.2.1, device files: Special files only Ionde and no data, associated to a driver to deal with the corresponding hardware, generally in the/dev directory, in the device metadata each device has a device number (main device number: For the tag driver (device type), Secondary device number: Mark different devices in the same class of devices, such as multiple hard drives, Mknod can create device files, and device file names are developed by ICANN.
8.2.2, Mknod (-M set permissions, create file name, Unit B device main device number secondary device number, example: mknod-m 660/dev/test1 B 120 0), disk device file (/DEV/SD[A-Z],USB: Serial, SATA: Serial, SCSI: and Line, SAS: Serial, with digital ID partition number such as:/DEV/SDA1, First partition), the disk is divided into tracks (track) each track consists of multiple sectors (sector) each sector 512 bytes, 0 Track 0 sector is called the Master boot record (Mbr:master boot Record) is used to boot the operating system (OS), MBR512 bytes are divided into (446bytes:bootloader, 64bytes: Partition table, each 16bytes marked a partition, there can be only 4 primary partition, 2BYTES:MBR validity tag).
8.2.3, partition (primary partition, extended partition (the extended partition cannot be directly used to divide into 1 or more logical partitions), logical partition), partition number: primary + extension 1-4, logical partition is 5. N,fdisk can view disk information example: Fdisk-l | Grep-a "^disk/dev/[sh].*", Cylinder (cylinder) partition more cylinder division, through the cat/proc/partitions can also view the disk partition information
8.2.4, view partition: Fdisk-l, create partition: Fdisk + not using cylindrical hard drives such as: Fdisk/dev/sdb (M View Help, p display disk partition table, n new partition, d delete partition, T modify partition System ID, W save partition, q do not save partition, L List all known system numbers), the new partition requires the kernel to reread the partition table before it can be used (centos5:partprobe,centos6:partx-a or KPARTX-AF,CENTOS6 read 2 commands need to take turns to perform the last pass/proc/ partitions to see if the kernel is recognized), Partition creation tools: Sfdisk and parted
8.2.5, practice writing a script, 1, prompted to enter a partition of the new hardware device files, 2, remind the user to destroy all the data, you continue? (Y or Yes: Continue, N, or no: Exit, other characters: reminder wrong, try again;) 3. Create a new partition on the disk: (primary partition 1: Size 512M, primary partition 2: Size 2G) 4, display the created results after the creation is complete;no perfect post-modification
650) this.width=650; "Src=" https://note.wiz.cn/api/document/files/unzip/cf6fe2dc-e32d-4bb9-8618-5c7c32315798/ 8135db5b-8f26-07a6-890e-2ec0b1e677ce.4301/index_files/fb8edf98430d3cfa836d1b630c0281ca.png "style=" border:0px; " alt= "Fb8edf98430d3cfa836d1b630c0281ca.png"/>
8.3.1, File system creation: The Mkfs:make file System,linux kernel is modular, these modules support dynamic loading and unloading, the file system may be directly packaged into the kernel, or can be compiled into a kernel module, lsmod can see the kernel has loaded those modules, If you need to format a particular file system, you will typically need to install the corresponding command tool to implement it. For example, use RPM or yum to install.
8.3.2, mkfs-t fstype = mkfs. Fstype Example: mkfs-t ext3 = Mkfs.ext3 (MKFS.EXT3/DEV/SDB1), there is also a command to create a file system MKE2FS it contains many options (-b specifies the block size {1024|2048|4096},-t specifies the file system { EXT2|EXT3|EXT4},-L Specify the volume label,-j equivalent to the specified file system ext3,-I specify how many bytes to create an inode,-n directly specify the number of Inode creation,-m reserved space as a percentage of the entire partition space (-M 2))
8.3.3, Blkid view partition file system Information, E2label view Set label example: E2LABEL/DEV/SDB1 Hello, set the volume labeled Hello, tune2fs Modify the partition properties, Block size cannot be adjusted (-j: You can upgrade ext2 file system ext3,-l Modify volume label,-m modify reserved space percentage,-o ^feature: Enable specified attribute, pre-attribute ^, to turn off this feature)
8.3.4, due to an unexpected process abort or a system crash, such as an abnormal abort of the import write operation, may result in file corruption, fsck repair file system A file system repair must first uninstall (-T specify the repair file system (can omit automatic detection of what file system repair),-a automatic repair,- R Interactive Repair, example: Fsck-t ext3-a/dev/sdb1), E2fsck used to repair the Ext file system (-y: Automatic answer to the question Yes,-f: Mandatory detection, Example: E2fsck-y-f/dev/sdb1), mkfs-t vfat You can create a FAT32 file system, swap a partition: Swap to alleviate the physical memory resource is not sufficient to use the situation; Mkswap [-L LABEL] DEVICE: Example: Mkswap-l swap1/dev/sdb2 (note that you need to modify the partition type to swap type before creating With Fdisk)
8.3.5, mount mount a device or file system that needs to be mounted to a directory that becomes the access point for another device or file system, such as (MOUNT/DEV/SDB1/MNT mount Partition), Mount common Mount option (-r: Read-only Mount,-W: Write-mount, -T: Specify file system type), view all mount information mount, cat/proc/mounts, Cat/dev/mtab
8.4.1, Mount-o option (Async: Disk Asynchronous I/o,sync: Disk synchronization i/o,atime/noatime: Files and directories are accessed when the last access timestamp is updated, auto/ Noauto: Whether the device supports Mount's-a option to mount automatically, Diratime/nodiratime: When the directory is accessed is the update of the last access timestamp, Dev/nodev: whether to support the use of devices on this device, Exec/noexec: Whether to allow the execution of binary files on this device, Suid/nosuid: whether to support the use of Suid,remount on files on this device: re-mount Example: Mount-o remount,acl/mnt, typically used to re-specify mount options without unloading, RO : Read-only, RW: Read-write, User/nouser: Allow normal mount of this file device, ACL: This device is supported using FACL, default is not supported, Mount mode: (Mount-o acl/dev/sdb1/ You do not need to specify this option when MNT is mounted or the ACL feature is turned on for this partition: Tune2fs-o acl/dev/sdb1))
8.4.2, Umount Uninstall Umount/mnt,fuser (-v View Mount device on the Access user example: Fuser-v/dev/sdb1,-km directly put forward the mount point for all users example: FUSER-KM/DEV/SDB1), DF (- H Unit conversion After display device space,-I display device inode usage, du (-s non-accurate calculation of the current folder overall size,-H unit conversion), Awk basic Usage method (awk-f: ' {print '} '/det/passwd)
8.4.3, swapon enable interactive partitioning, for example: SWAPNO/DEV/SDB2, swapoff Disable swap partition: SWAPOFF/DEV/SDB2,/etc/fstab field description (device name, mount point, File system, mount option, Backup frequency (0 no backup, 1 daily backup, 2 next day backup), self test (0 not self-test, 1 priority self-Test 1 only with root partition, 2....9))
8.4.4, Job 1, list all the disk devices on the current system, 2, let the user select a disk device, and display all the partition information on the specified device after the selection, 3, ask the user whether to erase all existing partitions on this disk after adding three partitions (Y or Yes: Continue, N or no: Abort script, Other characters remind the user to re-enter the valid characters); 4, after the user chooses to do the corresponding partition operation (primary partition 1:512M,EXT4, primary partition 2:512m,swap, primary partition 3:2G,EXT4) 5, the partition will be created as described above respectively format the corresponding file system; 6. Mount the primary partition 1 to the/mnt/boot directory, the primary partition 3 mount to the/mnt/sysroot directory, expand: After the beginning of the 3rd step above, first check if there are any partitions on this device are mounted, and if so, uninstall them first;
#!/bin/bash#date 2015-03-16#author xiangjin#description disk re partitionecho " Current computer disk "ls -l /dev/sd[a-z]read -p " Select the required  DISK INFORMATION VIEW&NBSP: " devnamefdisk -l " $devname " |grep " ^\/ Dev "for i in ' fdisk -l $devname | grep " ^\/dev " | awk " {print $1} ' ';d o if cat /proc/mounts | grep "$i"; then echo " $i uninstall is mounted" fuser -km $i umount $i else echo $i no mount " fidone read -p " delete all partitions on the disk and rebuild a new partition [y|yes]:continue [n |no]:quit " boolidcount=1sumnumber=$ (fdisk -l $devname |grep "^/dev" |wc -l) while [ $ boolid != ""  ];d o if [ $boolid == "y" -o $boolid == "yes" ];then while [ $count -le $sumnumber ];d o if [ $count -lt $sumnumber ];then echo "d $count w " | fdisk $devname else echo "D  &NBsp; w " |fdisk $devname fi let count++ done echo "n p 1 +512m n p 2 + 512m t 2 82 n p 3 +2g w " |fdisk $devnamemke 2fs -j -m 2 -b 1024 ${devname}1mke2fs -j -m 2 -b 1024 ${devname}3mkswap ${devname}2if [ -d /mnt/boot ];then mount ${devname}1 /mnt/bootelse mkdir /mnt/boot mount ${ devname}1 /mnt/bootfiif [ -d /mnt/sysroot ];then mount ${devname}3 / Mnt/sysroot else mkdir /mnt/sysroot mount ${devname}3 /mnt/sysrootfiswapon ${devname}2 exit 44 elif [ $boolid == "n" -o $boolid == "No" ];then echo "Program error" exit 55 else read -p "Invalid characters please input again " boolid fidone
Marco Education Eighth day file system, mount, MKE2FS, fdisk