Article Directory
Devices and disk
Linux device classification
Block device
block, a storage unit as a "block", disk
Character device
char, the storage unit is "character", keyboard
Disk classification
Mechanical hard drive (HDD)
Solid state drive (SDD)
Device file
1, disk device device name: / dev / DEV_FILE
2, different disk identifier: az, AA, ab ...
/ dev / sda, / dev / sdb, ... / dev / the SDAA, / dev / SDAB
different on the same device Zoning:, 2, 3 ...
/ dev / sda1, / dev / sda5
Linux disk partition
Why partition
1, to optimize I / O performance
2, for disk space quotas
3, increase the rate of repair
4, the isolation system, and program
5, a plurality of mounting the OS
. 6, different file systems
Addressing disk
CHS:
using 24bit bit addressing
the first 10 bits identify the cylinder, intermediate 8 represents a head, behind 6 represents a SECTOR
LBA (Logical Block Addressing):
LBA is an integer, particularly through the disk address in CHS format by converting bit
LBA using 48bit bit addressing
maximum addressable space 128
due to the address space in CHS addressing mode within about 8GB, so the disk capacity is less than about 8GB, or may be used CHS addressing mode LBA addressing mode; disk capacity is larger than about 8GB when you can only use LBA addressing
Partitioning
Two kinds of partitioning: the MBR, the GPT
. 1, the MBR: the Record the Boot Master, 1982 years, the 32-bit numbers representing sector
how partitions: press cylinder
0 track 0 sector: 512bytes
446bytes: Boot Loader
64bytes: partition table
16Bytes: represents a partition
2, GPT:
The system is booting
https://www.zhihu.com/question/21672895
How to use the Linux disk
Linux partition command
List block device
lsblk
fdisk the -l / dev / sda
CAT / proc / Partitions
create partitions
1, fdisk
2, GDisk create a GPT partition
3, parted advanced partitioning operations (create, copy, adjust the size, etc.) real-time, with care. aix, amiga, bsd, dvh, gpt, mac, msdos, pc98, sun, loop can be created.
File system
View supported file systems
in / lib / modules / xxx / Kernel / FS
Linux file system type
ext2 (Extended file system), ext3 , ext4, xfs (SGI), btrfs (Oracle), reiserfs, jfs (AIX), swap
Depending on whether it supports the "journal" function:
Journaled file systems: ext3, ext4, xfs, ...
Non-journaled file systems: ext2, vfat
CD: iso9660
Windows :FAT32, exFAT,NTFS
Unix: FFS (fast ), UFS (unix ), JFS2
网络文件系统:NFS, CIFS
集群文件系统:GFS2, OCFS2 (oracle) 例:11.11 淘宝
分布式文件系统: fastdfs,ceph, moosefs, mogilefs,glusterfs, Lustre
RAW:未经处理或者未经格式化产生的文件系统
创建文件系统
(1)mkfs命令:
mkfs. 能创建很多类文件系统 例:mkfs.xfs /dev/sda1 给/dev/sda1创建xfs类型的文件系统
ext# xfs btrfs vfa
mkfs -t 是个c写的脚本,就是调用mkfs. 命令 例:mkfs -t ext4 /dev/sda1 给/dev/sda1创建ext4类型的文件系统
-f 强制重建,如果这个设备已经分过其他格式的文件系统了
(2)mke2fs :创建文件系统,ext系列文件系统专用管理工具,例:mke2fs -t ext4 -L test /dev/sdc1 给/dev/sdc1创建ext4卷标为test的文件系统
-t {ext2|ext3|ext4} 格式
-b {1024|4096} block快大小
-L ‘LABEL’ 卷标
-j: 于 相当于 -t ext3
mkfs.ext3 = mkfs -t ext3 = mke2fs -j = mke2fs -t ext3
-i #: 为数据空间中每多少个字节创建一个inode ;此大小不应该小于block 的大小
-N # :指定分区中创建多少个inode
-I 一个inode 记录占用的磁盘空间大小,128—4096
-m #: 默认5%, 为管理人员预留空间占总空间的百分比
-O FEATURE[,…] :启用指定特性(只能开启以下特性) -O ^FEATURE 禁用指定特性
(3)tune2fs:修改文件系统信息,重新设定ext 系列文件系统可调整参数的值 例:tune2fs -o acl /dev/sdb2 开启/dev/sdb2的acl功能
-l :查看指定文件系统超级块信息;super block
-L ‘LABEL’ :修改卷标(ext)
mkfs -L ‘LABEL’ 或 mke2fs -L ‘LABEL’ 创建时设置卷标
e2label /dev/sd# 查看卷标
e2label /dev/sd# ‘LABEL’ 重命名卷标
-m # :修预留给管理员的空间百分比
-j: 将ext2 升级为ext3
-O: 文件系统属性启用或禁用, –O ^has_journal
-o: 调整文件系统的默认挂载选项,–o ^acl (centos7里默认开启acl 6 默认不开启)
-U UUID: 修改UUID号
(4)修复文件系统
一定不要在挂载状态下进行修复(centos6、7都 禁止在挂载下修复)fsck、xfs_repair
分区挂载
当我们分完区,并做好文件系统格式化,就到了最后的挂载mount了,挂载完毕就可以使用磁盘设备了。
1、什么是挂载和卸载
挂载: 将额外文件系统与根文件系统某现存的目录建立起关联关系,进而使得此目录做为其它文件访问入口的行为(挂载的设备必须有文件系统)
卸载:为解除此关联关系的过程
2, Mount
3, umount uninstalled
when you uninstall, if the process is running, you can not uninstall error.
See what's access to the specified file system process:
lsof device or mount point can be
fuser -v mount point
to terminate all access to the specified file system is the process:
fuser -km device or mount point can be
continue…
du
df
dmesg
xfs_repaire
fsck
badblocks