Linux文件系统:ext(2,3,4), xfs, reiserfs(suse),
VFS虚拟文件系统node
硬连接和符号连接:windows
设备文件:
b
c异步
mknod [option] NAME TYPE [MAJOR MINOR]
-m modeasync
/dev/null是无硬件设备与之对应的: 软件模拟的设备ide
/dev/sd[a-z]#
1-4:
5+: 逻辑分区模块化
IDE:/dev/hd工具
分区:根据柱面来划分 cylinderui
fdisk, sfdisk, partedspa
建立文件系统:
mkfs : make file system
mkfs - build a Linux file system
mkfs [-V] [-t fstype] [fs-options] filesys [blocks]
-t FSTYPE [DEVICE]
-t fstype
Specifies the type of file system to be built. If not specified, the default file system type
(currently ext2) is used.
mkfs -t FSTYPE 自动映射为 mkfs.FSTYPE
mkfs -t ext4 = mkfs.ext4命令行
注意:CentOS
文件系统必须在内核中支持才行,
Linux内核是模块化的,这些模块支持动态装载和卸载;
文件系统可能会被直接打包进内核,也能够被编译成内核模块;
# lsmod
lsmod - program to show the status of modules in the Linux Kernel
若是指望将某分区格式化成某特定文件系统,一般须要一个与之对应的在用户空间
可以使用命令行工具来实现;
# yum -y install xfsprogs
文件系统的日志功能:Journal
ext2: 无日志功能
ext3, ext4, xfs: 日志文件系统
[root@localhost ~]# mkfs.xfs /dev/vg_lvm/test
meta-data=/dev/vg_lvm/test isize=256 agcount=4, agsize=327680 blks
= sectsz=512 attr=2, projid32bit=0
data = bsize=4096 blocks=1310720, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@localhost ~]# blkid /dev/vg_lvm/test
/dev/vg_lvm/test: UUID="5579e5eb-566b-4fa1-8869-38b37a09920c" TYPE="xfs"
mke2fs:
mke2fs - create an ext2/ext3/ext4 filesystem
-t {ext2|ext3|ext4}:指定文件系统 不写是ext2的文件系统
-b {1024|2048|4096}:指定块大小
-L LABEL: 打标
-j: 至关于 -t ext3
-i #: 每多少字节给建立一个inode,此字节数不该该小于块大小
-N #: 直接指定可用的inode数;
-m #: 指定预留空间占整个分区空间的百分比;默认为5;
-O:指定分区特性
blkid: 查看指定块设备的信息
[root@localhost ~]# mke2fs -t ext3 -L TEST /dev/vg_lvm/test
mke2fs 1.41.12 (17-May-2010)
Filesystem label=TEST
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost ~]# blkid /dev/vg_lvm/test
/dev/vg_lvm/test: LABEL="TEST" UUID="5184aef4-aff9-422d-8efa-e68efd2725fc" SEC_TYPE="ext2" TYPE="ext3"
e2label:查看或设定卷标
e2label - Change the label on an ext2/ext3/ext4 filesystem
e2label device [ new-label ]
[root@localhost ~]# e2label /dev/vg_lvm/test
TEST
查看超级块信息:
# tune2fs -l DEVICE
[root@localhost ~]# tune2fs -l /dev/vg_lvm/test
tune2fs 1.41.12 (17-May-2010)
Filesystem volume name: TEST
Last mounted on: <not available>
Filesystem UUID: 5184aef4-aff9-422d-8efa-e68efd2725fc
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype sparse_super large_file
Filesystem flags: signed_directory_hash
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 327680
Block count: 1310720
Reserved block count: 65536
Free blocks: 1254785
Free inodes: 327669
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 319
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
Filesystem created: Tue Dec 2 09:27:01 2014
Last mount time: n/a
Last write time: Tue Dec 2 09:27:02 2014
Mount count: 0
Maximum mount count: 31
Last checked: Tue Dec 2 09:27:01 2014
Check interval: 15552000 (6 months)
Next check after: Sun May 31 09:27:01 2015
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: 31bb1af6-f45d-4900-a205-d38dd742de29
Journal backup: inode blocks
# dumpe2fs -h DEVICE 此时显示是不包括块组信息,去除-h则会显示块组信息
修改分区属性:tune2fs
块大小在格式化的时候已经决定了,所以块大小没法调整;
-j: ext2 --> ext3
-L LABEL:修改卷标
-m #: 修改预留空间百分比;
-O [^]FEATURE: 不加^启用指定特性,特性前加^,表示关闭此种特性
-o [^]mount-options: 开启或关闭指定的挂载选项
因进程意外停止或系统崩溃等状况导入写入操做非正常停止时,可能会致使文件损坏;此
时,应该修复文件系统:
注意:离线修复 先卸载,在修复
fsck
fsck - check and repair a Linux file system
-t fstype
-a: 自动修复错误
-r: 交互式修复错误
fsck [-sAVRTMNP] [-C [fd]] [-t fstype] [filesys...] [--] [fs-specific-options]
e2fsck: 专用于修改ext系列文件系统
e2fsck - check a Linux ext2/ext3/ext4 file system
-y: 对问题自动回答为yes
-f: 强制进行检测
-f Force checking even if the file system seems clean.
补充:windows不能识别Linux的文件系统
U盘的文件系统FAT32
# mkfs -t vfat
交换分区:swap
缓解物理内存资源不够用的状况;
建立交换分区:
mkswap [-L LABEL] DEVICE
文件系统挂载:默认只有管理员才有权限
将额外的分区与根文件系统上的某目录创建关联关系的过程;
目录中的原有文件会被隐藏
挂载点:另外一个文件系统的访问入口
挂载: mount DEVICE MOUNT_POINT
固定挂载点:/mnt, /media
mount - mount a filesystem
mount [option]... [-t fstype] [-o option] 设备 挂载点
挂载点要求:
一、事先存在;
二、使用空闲目录;
不跟选项时,显示已挂载的设备
经常使用的挂载选项[option]:
-t fstype:指定文件系统类型
-r: readonly, 只读挂载
-w: read and write, 读写挂载
-L LABEL:以卷标方式指定设备, mount -L MYDATA 挂载点
-U UUID: 以UUID的方式指定设备,mount UUID='uuid' 挂载点, mount -U uuid 挂载点
-a: 自动挂载全部(/etc/fstab文件中定义的)的支持自动挂载设备
-n: 挂载时,不更新/etc/mtab文件
-o option:
async:异步I/O,数据写操做先于内存完成,然后再根据某种策略同步至持久设备中
sync: 同步I/O,
atime/noatime: 文件和目录被访问时是更新最近一次的访问时间戳
auto/noauto:设备是否支持mount的-a选项自动挂载
diratime/nodiratime: 目录被访问时是更新最近一次的访问时间戳
dev/nodev: 是否支持在此设备上使用设备;
exec/noexec: 是否容许执行此设备上的二进制程序文件
suid/nosuid: 是否支持在此设备的文件上使用suid
remount: 从新挂载,一般用于不卸载的状况下从新指定挂载选项
ro: 只读
rw: 读写
user/nouser: 是否容许普通挂载此文件设备
acl: 在此设备是支持使用facl,默认不支持;
例如:以指定挂载后支持acl为例:
方法1:
mount -o acl DEVICE MOUNT_POINT
方法2:
tune2fs -o acl DEVICE
为设备设定默认挂载选项
mount DEVICE MOUNT_POINT
查看全部已经挂载的设备:
# mount
# cat /proc/mounts
# cat /etc/mtab 追踪当前系统已经挂载的设备
卸载:挂载点没有被进程访问时方能够卸载 ;
卸载:umount DEVICE
umount MOUNT_POINT
查看哪些进程正在访问挂载的设备:
fuser -v 挂载点
停止正在此挂载点的进程: fuser -km 挂载点