The slice is the smallest storage unit in the house. each slice has a size of bits. a circle is the magnetic column. this is the smallest unit of the partition. B: a block device. data is randomly accessed, such as hard disk C: character device, data line access, such as keyboard, display linux common hard disk interface device ATA (IDE )...
The slice is the smallest storage unit in the house. each slice has a size of bits. a circle is the magnetic column, which is the smallest unit of the partition.
B: block devices. data is randomly accessed, such as hard disks.
C: Character devices, data-line access, such as keyboards and monitors
Common linux hard disk interface devices
ATA (IDE): parallel, 133 MB/s parallel interference causes low speed
SATA: serial, 300 M/s, 600 M/s
SCSI: parallel, high speed, data reading block, built-in controller, great relief of cpu I/O time
Narrowband: Connect to seven hard disks;
Broadband: connect 15 hard disks
SAS: serial SCSI,
USB:
/Dev/hd [a-d] [1-63]: IDE device. up to 63 partitions are supported.
/Dev/sd [a-d] [1-15]: SATA, SCSI, SAS, USB, supports up to 15 partitions
Three hard disks/dev/sda: sata,/dev/sdb: usb,/dev/sdc: scsi. after the host is restarted, the device files are dynamically created, device identification may be chaotic according to the order in which the device is identified. for example, usb is identified as/dev/sda, because the kernel uses udev to identify the hard disk device, we can define the device in udev to avoid this situation.
BLOCK
We know that the hard disk can be stored only after it is formatted. the formatting disk actually splits the disk into blocks of a fixed size, such
1 K, 2 K, 4 K, data is stored in the middle of these block blocks, each block can only store one file, so the block Division
Based on actual needs, for example, if there are many small files on your system, you 'd better divide the block into smaller ones. if many of your files are not larger than 1 kB
The block you divide is 4 K. since a block can only be used to store one file, the remaining space will be wasted, resulting in a waste of disk space.
According to the block size, the size of a single file in the file system and the total size of the file system are also fixed.
1 K: maximum single file-16 GB total file system size-2 TB
2 K: Max single file-256 GB total file system size-8 TB
4 K: maximum single file-2 TB total file system size-16 TB
Note: The ext2 file system indicates that the ext3 or ext4 calculation results are different.
In fact, not all blocks are used to store data after they are divided, and some of them must be used by inode to facilitate file system discovery.
INODE
The inode number corresponding to the file to read data. The other part is allocated to the Super block, which is used to record the size, quantity, and number of inode in the entire file system. Reasonable planning of the number of inode is very important. Although the disk has space but the inode is gone, the space is still unavailable.
The size of each inode is bits, and one inode can only record one file. to store large files, we have
A lot of inode is required, while the inode table only has bits. Therefore, our system divides the bits of inode into 12
Direct, one indirect, one double indirect, and one three indirect.
12 direct: 12*1 K = 12 K, indirect: 256*1 K = 256 K, double indirect: 256*256*1 K, three indirect: 256*256*256*1 K
After the three values are added, the size of a single file in our file system is 16 GB.
Super block
Super blocks are mainly used to record inode and block usage, total amount, idle space, and the time when the partition is mounted.
The time when data is written at a time. There is a valid bit value in the Super block. if it is mounted, this value is 0; otherwise, it is 1.
File system
When the linux file system reads data, it first finds the inode number corresponding to the file, then finds the block on the corresponding disk based on the inode record, and reads the data, it is called an Indexed file system, just like looking for a directory to view some content of a book.
Linux also supports multiple file systems, but different file systems call different systems. to facilitate access, linux uses VFS (virtual file system) as the middle layer, it is used to access different file systems.
Attaching and using a disk
After the disk is formatted, it must be mounted to store data. The so-called mounting means finding an interface to insert the partition into the existing file system.
You can use this interface to access partitions.
There are two files in the system used to store partition mounting information.
More/etc/fstab
/Dev/vol0/root/ext3 defaults 1 1
/Dev/vol0/home ext3 defaults 1 2
LABEL =/boot ext3 defaults 1 2
Tmpfs/dev/shm tmpfs defaults 0 0
Devpts/dev/pts devpts gid = 5, mode = 620 0 0
Sysfs/sys sysfs defaults 0 0
Proc/proc defaults 0 0
LABEL = SWAP-sda3 swap defaults 0 0
The fifth line indicates whether to back up data. 0 indicates no backup, 1 indicates daily backup, and 2 indicates the next day backup.
The sixth line indicates whether to perform self-check. 0 indicates no self-check. 1 indicates the first self-check (generally, only the root directory is set to 1) and 2 indicates self-check.
This file is used to record the partition information to be mounted at startup.
More/etc/mtab
/Dev/mapper/vol0-root/ext3 rw 0 0
Proc/proc rw 0 0
Sysfs/sys sysfs rw 0 0
Devpts/dev/pts devpts rw, gid = 5, mode = 620 0 0
// Dev/mapper/vol0-home/home ext3 rw 0 0
/Dev/sda1/boot ext3 rw 0 0
Tmpfs/dev/shm tmpfs rw 0 0
None/proc/sys/fs/binfmt_misc rw 0 0
Sunrpc/var/lib/nfs/rpc_pipefs rw 0 0
This file is used to record the real-time mounting information, as long as a partition is mounted here, you will see
This article is from the "growth full record" blog