1、根目录
文件系统层次标准(Filesystem Hierarchy Standard,FHS)
2、物理设备命名规则
udev设备管理器会自动把硬件名称规范起来
主分区或扩展分区的编号从1开始,到4结束;
逻辑分区从编号5开始。
注意:
1、a,b,c编号不是由插槽决定的,而是由系统内核的识别顺序决定的。
2、分区的数字编码不一定是强制顺延下来的,也有可能是手工指定的。
二、主分区、拓展分区、逻辑分区
主分区3个,拓展分区1个,拓展分区指向拓展分区
所谓扩展分区,严格地讲它不是一个实际意义的分区,而仅仅是一个指向其他分区的指针,这种指针结构将形成一个单向链表。因此扩展分区自身不能存储数据,用户需要在其指向的对应分区(称之为逻辑分区)上进行操作。
3、文件系统与数据资料
常见的文件系统
文件组成
Linux中每个文件都是由一个inode和block组成,其中文件权限与属性记录记录在inode中,每个文件单独占用一个独立的inode表格,默认为128字节,里边记录如下信息:
该文件的访问权限(read、write、execute);
该文件的所有者与所属组(owner、group);
该文件的大小(size);
该文件的创建或内容修改时间(Ctime);
该文件的最后一次访问时间(Atime);
该文件的修改时间(Mtime);
文件的特殊权限(SUID、SGID、SBIT);
该文件的真实数据地址(point)。
而文件的实际内容则保存在block块中(大小一般是1KB、2KB或4KB),一个inode的默认大小仅为128字节,记录一个block则消耗4字节。当文件的inode被写满后,Linux系统会自动分配出一个block,专门用于像inode那样记录其他block块的信息,这样把各个block块的内容串到一起,就能够让用户读到完整的文件内容了。对于存储文件内容的block块,有下面两种常见的情况(以4KB大小的block为例进行说明)。
情况1:文件很小(1KB),但依然会占用一个block,因此会潜在地浪费3KB。
情况2:文件很大(5KB),那么会占用两个block(5KB−4KB后剩下的1KB也要占用一个block)。
虚拟文件系统(Virtual File System,VFS)接口
4、挂载、分区、格式化
mount命令
一次性挂载:mount 设备路径 目录
永久性挂载:/etc/fstab
分区(fdisk)
[root@linuxprobe ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x258aea01.
Command (m for help): n【创建分区】
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p【创建主分区】
Partition number (1-4, default 1): 4【分区编号】
First sector (2048-41943039, default 2048): 直接回车
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039): +400M【结束分区大小】
Created a new partition 4 of type 'Linux' and of size 400 MiB.
Command (m for help): p【查看已创建的分区】
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x258aea01
Device Boot Start End Sectors Size Id Type
/dev/sdb4 2048 821247 819200 400M 83 Linux
Command (m for help): w【保存退出】
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
格式化(mkfs)
[root@linuxprobe ~]# mkfs.xfs /dev/sdb4
meta-data=/dev/sdb4 isize=512 agcount=4, agsize=25600 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=102400, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=1368, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
挂载(mount)
[root@linuxprobe ~]# mkdir /wang
[root@linuxprobe ~]# ls
aa Desktop Downloads Music Public Videos
anaconda-ks.cfg Documents initial-setup-ks.cfg Pictures Templates wang
[root@linuxprobe ~]# mount /dev/sdb4 /wang/
[root@linuxprobe ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 969M 0 969M 0% /dev
tmpfs 984M 0 984M 0% /dev/shm
tmpfs 984M 9.6M 974M 1% /run
tmpfs 984M 0 984M 0% /sys/fs/cgroup
/dev/mapper/rhel-root 17G 4.0G 14G 24% /
/dev/sda1 1014M 152M 863M 15% /boot
tmpfs 197M 16K 197M 1% /run/user/42
tmpfs 197M 2.3M 195M 2% /run/user/0
/dev/sr0 6.7G 6.7G 0 100% /run/media/root/RHEL-8-0-0-BaseOS-x86_64
/dev/sdb4 395M 24M 372M 6% /wang
[root@linuxprobe ~]# vim /etc/fstab
/dev/sdb4 /wang xfs defaults 0 0