<> one , Disk diagram

<> two , Disk classification

( one ) Common disk interfaces

*
IDE(Intergrated Device Electronics): Cheap cheap

IDE There is usually a flat cable connection , A flat cable can be connected 2 individual IDE Hard disk , A computer generally provides 2 Flat cable , Therefore, it is generally allowed 4 block IDE Hard disk .IDE After years of development , mature , cheap , stable . This kind of hard disk is usually installed in old computers . at present 2011 The mainstream hard board is already SATA Hard drive .
IDE It is transmitted in parallel , and SATA Serial transmission .

*
SATA(Serial-ATA): Emerging fast

SATA Is serial ATA, It is an emerging technology in recent years , More complete data verification , Transmission speed is also faster , How fast ?SATA1.0 Our standards have been met 150M/s Yes , As for the follow-up 2.0 and 3.0, Can be achieved 300M/S and 600M/S of . in short SATA It's a new technology , In every respect IDE Better , So in general ,IDE Sooner or later SATA Completely replaced , It's just a matter of time .

*
SCSI(Small Computer System Interface: Small computer system interface ): Stable high price

SCSI The emergence of is mainly due to the original IDE The hard disk speed of the interface is relatively low , The transmission efficiency is relatively slow . because SCSI The hard disk works independently of the system bus , So its biggest advantage lies in the low occupancy rate of the system , Of course, it has some advantages , High speed , Fast transmission rate , More stable . But there are also some disadvantages , high price , No installation IDE convenient .

<> three , Disk operation process

<>1. Identify hard disk
[root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 30G
0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 29G 0 part ├─centos-root 253:0
0 27G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 10G 0 disk sr0 11
:0 1 4.3G 0 rom
<>2. Zoning planning model

(1)MBR pattern ( Master start record )

* Maximum space support 2.2TB
* type ( Primary partition ( most 4 individual ), Extended partition , Logical partition )

With the development of the times, it is gradually found that 4 One primary partition cannot meet the actual needs , Great scientists began to think about taking out one of the partitions , As an extended partition , However, the partition cannot be used directly , The extended partition needs to be divided into one or more logical partitions , Then use
Generally, a disk can be divided into three primary partitions at most , Then the remaining space is an extended partition , When you partition again, you will find that the newly divided partition is displayed as a logical partition ( stay windows Next test )
So the final partition you can use is : Primary partition , Logical partition .

(2)GPT pattern

<>3.MBR Zoning planning practice

(1)fdisk Interactive partition command

*
fdisk Common parameters

*
Try to sdb The disk is divided into two sectors , One 1G, One 2G
[root@localhost ~]# fdisk /dev/sdb # n, Create a new partition Command (m for help): n Partition
type: p primary (0 primary, 0 extended, 4 free) e extended #
You are prompted to select a partition type , Primary partition selected by default (e: Extended partition ), You can enter directly , You can also enter `p` Select (default p): #
4 Partitions , Default selection 1, According to their own needs , The general default is 1, Just enter Partition number (1-4, default 1): #
Select a start address ( Default start address from 2048,2048 The previous is used to save information such as disk partition table , It is recommended not to modify , Direct enter ) First sector (2048-
20971519, default 2048): Using default value 2048 #
Select a termination address , for example `+2G`,`+1024K`,`+512M`, Input here as required `1G`, Then enter Last sector, +sectors or +
size{K,M,G} (2048-20971519, default 20971519): +1G Partition 1 of type Linux and
of size1 GiB is set # Prompt you to continue , We can use `p` Select View partition Command (m for help): p Disk /
dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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 Disk label type: dos Disk identifier:
0x177de0a3 # Can see `/dev/sdb1` partition Device Boot Start End Blocks Id System /dev/sdb1
2048 2099199 1048576 83 Linux # If we don't want the partition , Direct input `d`, Delete the partition you just Command (m for help)
: d Selected partition 1 Partition 1 is deleted # Let's look at the partition again , It is found that the partition information just does not exist
Command(m for help): Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520
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 Disk
labeltype: dos Disk identifier: 0x177de0a3 Device Boot Start End Blocks Id
System# Next, repartition , Enter after both partitions are divided `w` preservation Command (m for help): n Partition type: p
primary(0 primary, 0 extended, 4 free) e extended Select (default p): Using
default response p Partition number(1-4, default 1): First sector (2048-20971519
, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G}
(2048-20971519, default 20971519): +1G Partition 1 of type Linux and of size 1
GiBis set Command (m for help): n Partition type: p primary (1 primary, 0
extended, 3 free) e extended Select (default p): Using default response p
Partition number(2-4, default 2): First sector (2099200-20971519, default
2099200): Using default value 2099200 Last sector, +sectors or +size{K,M,G} (
2099200-20971519, default 20971519): +2G Partition 2 of type Linux and of size 2
GiBis set Command (m for help): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks. [root@localhost ~]#
lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 30G 0 disk ├─sda1 8:1 0
1G0 part /boot └─sda2 8:2 0 29G 0 part ├─centos-root 253:0 0 27G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP] # You can see our `sdb` The disk has been divided into two sectors, the size of which is `1G` and `2G`
sdb8:16 0 10G 0 disk ├─sdb1 8:17 0 1G 0 part └─sdb2 8:18 0 2G 0 part sr0 11:0 1
4.3G 0 rom [root@localhost ~]#
* /dev/sdb/sdb5 Express meaning
SCSI Hard disk of the device , The fifth partition of the second block ( First piece :sda, Stand back sdb,sdc)
SCSI Hard disk of the device , Second block first logical partition (sdb1-sdb3 Primary partition ,sdb4 Partition for expansion , therefore sdb5 Is the first logical partition within the extended partition )

* Extended partition e
1. When the score is finished 3 After primary partitions , Will actively jump to the extended partition , You can also force input at this time p Select primary partition , thus , If you want to divide another area, you will report an error (MBR Maximum support 4 Primary partitions ).
2. If you select extended partition , Then return all the way , Do not enter the termination address , By default, the remaining spaces are extended partitions .
3. Next are logical partitions ,sdb4 Belong to extended partition , It cannot be used .
4. If the partition ends lsblk View found no display , Command required partprobe Refresh partition table

*
format partition

*
The process of assigning a spatial file system

*
file system : Rules for storing data in space

*
Windows file system :FAT,NTFS( Function superior FAT)

*
Linux file system :ext4(REHEL6 Default file system ),xfs(REHEL7 Default file system )

*
Commonly used :mkfs.ext4,mkfs.xfs

(1) format sdb1 partition :mkfs.ext4 /dev/sdb1,( have access to -f Parameter to modify the formatted partition format again )
[root@localhost ~]# mkfs. mkfs.btrfs mkfs.ext2 mkfs.ext4 mkfs.minix mkfs.vfat
mkfs.cramfs mkfs.ext3 mkfs.fat mkfs.msdos mkfs.xfs # take `sbd1` Format partition as `ext4` format [
root@localhost~]# mkfs.ext4 /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) Filesystem
label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=
0 blocks, Stripe width=0 blocks 65536 inodes, 262144 blocks 13107 blocks (5.00%)
reservedfor the super user First data block=0 Maximum filesystem blocks=
268435456 8 block groups 32768 blocks per group, 32768 fragments per group 8192
inodes per group Superblock backups stored on blocks: 32768, 98304, 163840,
229376 Allocating group tables: done Writing inode tables: done Creating journal
(8192 blocks): done Writing superblocks and filesystem accounting information:
done[root@localhost ~]#
(2) View formatting results ( If formatting is successful , There will be output )
[root@localhost ~]# blkid /dev/sdb1 /dev/sdb1: UUID=
"b738f80e-2b71-471b-b311-98a222f984e3" TYPE="ext4" [root@localhost ~]# blkid
/dev/sdb2 [root@localhost ~]# [root@localhost ~]# mkfs.xfs /dev/sdb2 [
root@localhost~]# blkid /dev/sdb2 /dev/sdb2: UUID=
"651b6763-dc5e-48f9-9790-610f508bb67e" TYPE="xfs" [root@localhost ~]#
*
Mount use
# (1) Create a new mount point [root@localhost ~]# mkdir /home/fatpuffer/part1 # (2) Mount the formatted partition
[root@localhost ~]# mount /dev/sdb1 /home/fatpuffer/part1/ # (3) Check whether the mount is successful [
root@localhost~]# df -h | grep /dev/sd /dev/sda1 1014M 234M 781M 23% /boot /dev/
sdb1 976M2.6M 907M 1% /home/fatpuffer/part1
stay /home/fatpuffer/part1 The next write data is actually written to /dev/sdb1 It's in the partition , You can try to create a new file in this directory , Then use umount
/home/fatpuffer/part1 Unmount partition , Then hang it to other mount points , View the mount point , The previously created file will be found

*
Boot auto mount ( If not configured , Power on again after shutdown , The mount point disappeared )
""" configuration file `/etc/fstab`, The format is as follows Device path Mount point type parameter Backup tag Detection sequence /dev/sdb1
/home/fatpuffer/part1 ext4 defaults 0 0 After adding , use `mount
-a` Test ( Use before testing `umount Unload tune `), It is best not to restart the test directly , Once you write it wrong , The virtual machine can't get up """
<> three , Command summary

* Identify hard disk :lsblk
* Planning zoning :fdisk District Name
* Refresh partition :partprobe
* Partition formatting :mkfs.ext4 District Name
* Partition mount :mount partition Mount point
* Unmount partition :umount partition
* Check whether the partition is mounted successfully :df -h | grep /dev/sd

Technology
©2019-2020 Toolsou All rights reserved,
Redis Underlying data structure A person who dissuades others from learning computer , Are not good people win10 System computer C Where's the disc ,c disc users where? (win10c Disk not found users) Freshman c Language student management system ( lower ) hospital WIFI Which family is strong ? utilize Python Script unlimited spoof girlfriend computer C language program design —— Student management system Byte runout - Test development practice - One side cool meridian python Run code at specified time 5 Best style Linux Server system recommendation Anti anxiety life after naked resignation , I believe everything will have the best arrangement