当前位置:网站首页>Disk management and file system
Disk management and file system
2022-07-27 06:51:00 【Thousand tears 1999】
Tips : When the article is finished , Directories can be generated automatically , How to generate it, please refer to the help document on the right
List of articles
One 、 Disk base
1. Disk structure

The physical structure of the hard disk
Disc : A hard disk has multiple disks , Every disc 2 Noodles .
head : One head per side .
2. The data structure of the hard disk
A sector : The disc is divided into sectors , Each sector stores 512 Bytes of data , The smallest storage unit of a hard disk .
Magnetic track : Concentric circles with different radii on the same disk , It is a circular track drawn by the magnetic head on the surface of the disk .
cylinder : A cylindrical surface formed by the same radius of different disks , It consists of multiple tracks of the same radius circle .
Hard disk storage capacity = Number of heads × Magnetic track ( cylinder ) Count × Sectors per channel × Bytes per sector (512 byte )
You can use a cylinder / head / Sector to uniquely locate each area on the disk
Disk interface type
IDE、SATA、SCSI、SAS、 Fibre channel
3.MBR And disk partition representation
MBR In the first physical sector of the hard disk
MBR It contains the main boot program and partition table of the hard disk
The partition table has 4 Zone record area , The recording area of each zone accounts for 16 Bytes
Linux Put the hard disk 、 Devices such as partitions are represented as files
/dev/hda5
/dev/= Hardware directory where the device is located
hd=IDE equipment
a= Hard disk serial number a;b;c And so on in letters
5= The sequence number of the partition , In numbers
4. Disk partition structure
The number of primary partitions in the hard disk is only 4 individual
The number of primary and extended partitions is limited to 1~4
Extended partitions are subdivided into logical partitions
The ordinal number of the logical partition will always be from 5 Start
5. File system type
1.XFS file system
A partition where files and directory data are stored .
High performance log file system , Especially good at dealing with big files , Hold millions TB Storage space .
CentOS 7 The default file system used in the system .
2.swap, Exchange file system
by Linux The system establishes a switch partition
─ Generally set as physical memory 1.5~2 times
6.Linux Other file system types supported
EXT4 、FAT32、NTFS、LVM
Two 、 Check and confirm the new disk
1. fdisk command
fdisk -l [ Disk device ] or
fdisk [ Disk device ]
-n Means to add a new partition
-p Indicates print partition list
-q Exit without saving
-t Indicates that the partition is changed id( type )
-l Show all partition types ( Of id)
-w Save and exit
2. Create system files ( format )
mkfs -t xfs / dev/ sdb1 and mkfs.xfs / dev / sdb1
3./etc/fstab Meaning
stay /etc/fstab
In file , Each line records the mounting configuration information corresponding to a partition or device , This information consists of six fields from left to right ( Use spaces or tabs to separate ), The meaning of each part is as follows .
/dev/sdb1 / xfs defaults 0 0
The first 1 Field : Device name or device volume label .
The first 2 Field : The location of the mount point directory of the file system . The first 3 Field : File system type , Such as xfs、swap etc. .
The first 4 Field : Mount parameters , namely mount command "-o" The parameters available after the option . for example ,defaults、rw、ro、noexec Each represents the default parameter 、 Can write 、 read-only 、 Disable executors .
The first 5 Field : Indicates whether the file system needs dump Backup (dump It's a backup tool ). General set to 1 It is necessary to , Set to o Will be dump Ignore .
The first 6 Field : This number determines the order in which disk checks are performed at system startup .0 It means no inspection ,1 It means priority inspection ,2 Next, check . The root partition should be set to 1, Other partitions are set to 2.
By means of /etc/ fstab
Add the corresponding mount configuration to the file , It can automatically mount the specified partition after startup .
4. expand df command
df The command is used to check the disk space usage of the file system , Permissions are all users .df Format [ options]
One T: Show file system type .
One h: Print out the file system size in an easy to understand format , for example 136KB、24MB、21GB.
Common combinations df -hT
5. Mount command and unmount
Mount file system
mount + Files to mount + Directory to mount to
Unmount the file system
unmount+ Device storage location
or
unmount+ Mount point location
Add lf Enforceability .
6.free command
[[email protected] /]# free
total used free shared buff/cache available
Mem: 3762948 448316 2901128 14736 413504 3075792
Swap: 8191996 0 8191996
Mem: Memory
swap: Swap partition
total: Total amount
usee: Already used
free: not used
free -h Display units
free -m With M Display in units
The cache is memory and cpu Storage area between , Used to store cpu Data read from memory multiple times , Read the same variable multiple times , The variable will be put into the cache , When called again, it fetches... Directly from the cache , Don't take... From memory , When the variable changes in memory , This can lead to memory invisibility problems ; The goal is to access memory faster .
A buffer is a storage area in memory .
Buffer is divided into kernel buffer and user buffer ; Different functions .
The kernel buffer is a network transport buffer , file io, Console input and other operations “ Transfer station ”, Is invisible memory , That is, users cannot directly use .
3、 ... and 、 experiment

Identify disks without restarting :
echo "- - - "> /sys/class/scsi_host/host0/scan
echo "- - - "> /sys/class/scsi_host/host1/scan
echo "- - - "> /sys/class/scsi_host/host2/scan
Restart command : reboot / init 6
[[email protected] ~]# fdisk -l
disk /dev/sda:64.4 GB, 64424509440 byte ,125829120 Sectors
Units = A sector of 1 * 512 = 512 bytes
Sector size ( Logic / Physics ):512 byte / 512 byte
I/O size ( Minimum / The best ):512 byte / 512 byte
Disk label type :dos
Disk identifier :0x000a3ffd
equipment Boot Start End Blocks Id System
/dev/sda1 * 2048 821247 409600 83 Linux
/dev/sda2 821248 109445119 54311936 83 Linux
/dev/sda3 109445120 125829119 8192000 82 Linux swap / Solaris
disk /dev/sdc:21.5 GB, 21474836480 byte ,41943040 Sectors
Units = A sector of 1 * 512 = 512 bytes
Sector size ( Logic / Physics ):512 byte / 512 byte
I/O size ( Minimum / The best ):512 byte / 512 byte
disk /dev/sdb:21.5 GB, 21474836480 byte ,41943040 Sectors
Units = A sector of 1 * 512 = 512 bytes
Sector size ( Logic / Physics ):512 byte / 512 byte
I/O size ( Minimum / The best ):512 byte / 512 byte
2. Plan the partition in the hard disk
Create, delete and change partitions in the hard disk using fdisk command , You can enter the interactive setting page
To the hard disk /dev/sdb Zoning as an example
[[email protected] ~]# fdisk /dev/sdb
Welcome to use fdisk (util-linux 2.23.2).
Changes will stay in memory , Until you decide to write changes to disk .
Think twice before using the write command .
Device does not contain a recognized partition table
Use disk identifier 0x065664db Create a new DOS Disk label .
3.p Instructions - List the partitions in the hard disk , View partition table
command ( Input m get help ):p
disk /dev/sdb:21.5 GB, 21474836480 byte ,41943040 Sectors
Units = A sector of 1 * 512 = 512 bytes
Sector size ( Logic / Physics ):512 byte / 512 byte
I/O size ( Minimum / The best ):512 byte / 512 byte
Disk label type :dos
Disk identifier :0x065664db
equipment Boot Start End Blocks Id System
4.n Instructions - New partition , Create two primary partitions , Respectively 5g and 4g.
command ( Input m get help ):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Zone number (1-4, Default 1):
start A sector (2048-41943039, The default is 2048):
The default value... Will be used 2048
Last A sector , + A sector or +size{
K,M,G} (2048-41943039, The default is 41943039):+^[[GG
G”. Hold the suffix :“
Support :10^N: KB ( kilobytes ), MB ( Megabytes ), GB ( Gigabyte )
2^N: K ( About kilobytes ), M ( About megabytes ), G ( Yogi byte )
Last A sector , + A sector or +size{
K,M,G} (2048-41943039, The default is 41943039):+5GB
Partition 1 Set to Linux type , The size is set to 4.7 GiB
command ( Input m get help ):N
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Zone number (2-4, Default 2):
start A sector (9766912-41943039, The default is 9766912):
The default value... Will be used 9766912
Last A sector , + A sector or +size{
K,M,G} (9766912-41943039, The default is 41943039):+4GB
Partition 2 Set to Linux type , The size is set to 3.7 GiB
5.n Instructions - Allocate all the remaining space to 3 A logical partition .
command ( Input m get help ):n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): e
Zone number (3,4, Default 3):
start A sector (17580032-41943039, The default is 17580032):
The default value... Will be used 17580032
Last A sector , + A sector or +size{
K,M,G} (17580032-41943039, The default is 41943039):
The default value... Will be used 41943039
Partition 3 Set to Extended type , The size is set to 11.6 GiB
6. preservation
command ( Input m get help ):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Synchronizing disk .
7. Press p see
command ( Input m get help ):p
disk /dev/sdb:21.5 GB, 21474836480 byte ,41943040 Sectors
Units = A sector of 1 * 512 = 512 bytes
Sector size ( Logic / Physics ):512 byte / 512 byte
I/O size ( Minimum / The best ):512 byte / 512 byte
Disk label type :dos
Disk identifier :0x065664db
equipment Boot Start End Blocks Id System
/dev/sdb1 2048 9766911 4882432 83 Linux
/dev/sdb2 9766912 17580031 3906560 83 Linux
/dev/sdb3 17580032 41943039 12181504 5 Extended
9. Create system files ( format )
[[email protected] ~]# mkfs.xfs /dev/sdb
mkfs.xfs: /dev/sdb appears to contain a partition table (dos).
mkfs.xfs: Use the -f option to force overwrite.
[[email protected] ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=305152 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=1220608, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
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
[[email protected] ~]# mkfs.xfs /dev/sdb2
meta-data=/dev/sdb2 isize=512 agcount=4, agsize=244160 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=976640, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
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
[[email protected] ~]# mkfs.xfs /dev/sdb3
mkfs.xfs: /dev/sdb3 appears to contain a partition table (dos).
mkfs.xfs: Use the -f option to force overwrite.
10. stay / Create a directory under directory ky21
[[email protected] ~]# mkdir /ky21
11. Permanently mount and view
[[email protected] /]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Jun 21 00:03:15 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
# UUID=f4fa0787-b442-43b8-b146-a8eb38d322be / xfs defaults 0 0
UUID=3f9e0dcc-ec8c-4b14-ad33-a34eedc3dcf8 /boot xfs defaults 0 0
UUID=15a82917-6245-4027-8105-d89b1761f63b swap swap defaults 0 0
/dev/sdb1 /ky21 xfs defaults 0 0
~
:wq Save and exit
[[email protected] /]# mount -a Mount with immediate effect
[[email protected] /]# df -hT see
file system type Capacity Already used You can use Already used % Mount point
devtmpfs devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs tmpfs 1.8G 0 1.8G 0% /dev/shm
tmpfs tmpfs 1.8G 13M 1.8G 1% /run
tmpfs tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup
/dev/sda2 xfs 52G 4.9G 47G 10% /
/dev/sda1 xfs 397M 213M 185M 54% /boot
tmpfs tmpfs 368M 0 368M 0% /run/user/0
tmpfs tmpfs 368M 16K 368M 1% /run/user/42
/dev/sdb1 xfs 4.7G 33M 4.7G 1% /ky21
[[email protected] /]# cat /etc/fstab Or use this to check
#
# /etc/fstab
# Created by anaconda on Tue Jun 21 00:03:15 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
# UUID=f4fa0787-b442-43b8-b146-a8eb38d322be / xfs defaults 0 0
UUID=3f9e0dcc-ec8c-4b14-ad33-a34eedc3dcf8 /boot xfs defaults 0 0
UUID=15a82917-6245-4027-8105-d89b1761f63b swap swap defaults 0 0
/dev/sdb1 /ky21 xfs defaults 0 0
边栏推荐
- Iptables firewall
- 1. CentOS 7 安装 redis
- Shell script backup MySQL database
- Pruning - quantification - turn to onnx Chinese series tutorials
- 备忘录 @RestControllerAdvice与异常拦截类示例
- FTX Foundation funded 15million to help covid-19 clinical trials, which will affect global public health
- shell--自定义变量与赋值
- PSI | CSI and ROC | AUC and KS - memorandum
- LVM与磁盘配额
- 2022上半年英特尔有哪些“硬核创新”?看这张图就知道了!
猜你喜欢

Redis' idea under windows is not connected

向日葵教大家如何防范拒绝服务攻击漏洞?

Raid explanation and configuration

Esxi virtual machine starts, and the module "monitorloop" fails to power on

DNS domain name resolution service

Redis operation of Linux Installation

项目实训经历2

如何让最小 API 绑定查询字符串中的数组

Pruning - quantification - turn to onnx Chinese series tutorials

Linux安装Redis操作
随机推荐
Recommended by the world's most technologically competent smart contract security audit company in 2022
Raid explanation and configuration
MySql数据库
使用密钥方式登录阿里云服务器
DHCP的概念和原理
Basic knowledge of English: juxtaposition structure
Express框架
What is special about the rehabilitation orthopedic branch of 3D printing brand?
FTP服务简介与配置
Redis fast learning
Inventory of the world's six most technologically competent smart contract audit companies in 2022
Px4 source code compilation to establish its own program module
Alibaba cloud SMS authentication third-party interface (fast use)
shell常用命令-备忘录
关于ES6的新特性
向日葵:遇到电脑漏洞别担心,了解清楚再判断向日葵:遇到电脑漏洞别担心,了解清楚再判断向日葵:遇到电脑漏洞别担心,了解清楚再判断向日葵:遇到电脑漏洞别担心,了解清楚再判断向日葵:遇到电脑漏洞别担心,了解
gin-vue-admin 使用docker容器中的数据库
阿里云短信验证第三方接口(快速使用)
FTX.US推出股票和ETF交易服务,让交易更透明
ArcGIS for JS API entry series