Day19-磁盘管理

磁盘的基本概念


每个硬盘中心都是一摞高速运转的圆盘,在圆盘上附着的一圈金属颗粒,每个金属颗粒都有自己的磁化程度,用于储存0和1

当记录数据时,硬盘的磁头开始通电,形成强磁场,数据在磁场的作用下转变成电流,使颗粒磁化,从而将信息记录在圆盘上。

由海量颗粒组成的信息,就是我们存在硬盘里的数据。

磁盘的基本结构:

  • 盘片:硬盘一般有一个或多个盘片,每个盘片可以有两面,即第一个盘片的正面为0面,反面为1面然后依次类推
  • 磁道:每个盘片的盘面在出厂的时候被划分出了多个同心圆环,数据就存储在这样的同心圆环上面,我们将这样的圆环称为磁道(Track),每个盘面可以划分多个磁道。但肉业不可见
  • 扇区:在硬盘出厂时会对磁盘进行一次低格,其实就是再每个磁道划分为若干个弧段,每个弧段就是一个扇区 (Sector)。扇区是硬盘上存储的物理单位,现在每个扇区可存储512字节数据已经成了业界的约定。
  • 柱面:柱面实际上就是我们抽象出来的一个逻辑概念,简单来说就是处于同一个垂直区域的磁道称为 柱面 ,即各盘面上面相同位置磁道的集合。这样数据如果存储到相同半径磁道上的同一扇区,这样可以实现并行读取,主要是减少磁头寻道时间。
  • 磁头:读取磁盘磁道上面金属块,主要负责读或写入数据。

磁盘的预备知识

  • 磁盘的接口
    (1)IDE out
    (2)Scsi out
    (3)SATA III 6Gbps/s 750MB/s 1T 400 100MB/s
    (4)SAS 8Gbps/s 1000MB/s 1T 4500
    (5)SSD 纯电子 抗摔
    两种接口:(1)msata out (2)m.2
    接口类型 :(1)SATA 几乎所有主板都兼容, 便宜 性能差 ,(2)PCI-E 需要看主板是否兼容, 贵, 性能高
    传输通道 :(1)PCI-E AHCI ,(2)NVMe
磁盘接口 特性
IDE out
Scsi out
SATA III 6Gbps/s 750MB/s 1T 400 100MB/s
SAS 8Gbps/s 1000MB/s 1T 4500
SSD 纯电子 抗摔

磁盘的名词

  • 容量 MB GB TB PB EB .............
  • 转速 SATA3 ==7200 SAS 15000 (非常之高) 磁盘阵列RAID
  • 尺寸 3.5 2.5 1.8
  • IOPS Input/Output 输入输出
    (1)顺序读写
    (2)随机读写
设备类型: 硬盘-内置
容量: 73G/146G/300G
尺寸: 2.5英寸/3.5英寸
接口: SAS 6Gb/s
转速: 7200转 /10000转/15000转每分

磁盘的命名规则[a-z][aa-zz]


http://www.udaxia.com/wtjd/6117.html

磁盘的基本分区

1,添加磁盘

[root@oldboy ~]  ll /dev/sd* 
brw-rw----. 1 root disk 8,  0 Aug 19 11:29 /dev/sda
brw-rw----. 1 root disk 8,  1 Aug 19 11:29 /dev/sda1 
brw-rw----. 1 root disk 8,  2 Aug 19 11:29 /dev/sda2 
brw-rw----. 1 root disk 8,  3 Aug 19 11:29 /dev/sda3 
brw-rw----. 1 root disk 8, 16 Aug 19 11:29 /dev/sdb 
brw-rw----. 1 root disk 8, 32 Aug 19 11:29 /dev/sdc

[root@oldboy ~]  lsblk 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT 
sda      8:0    0   40G  0 disk 
├─sda1   8:1    0    1G  0 part /boot 
├─sda2   8:2    0    1G  0 part [SWAP] 
└─sda3   8:3    0   38G  0 part / 
sdb      8:16   0    1T  0 disk 
sdc      8:32   0    4T  0 disk 
sr0     11:0    1  4.3G  0 rom  

2,给磁盘分区

[root@oldboyfang ~]$ fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).

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
Building a new DOS disklabel with disk identifier 0x71756a88.

Command (m for help): m                       #输入m列出常用命令
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)              #主分区
   e   extended                                             #扩展分区
Select (default p): p                                       #选择创建主分区
Partition number (1-4, default 1):                          #默认创建第一个主分区
First sector (2048-41943039, default 2048):                 #默认扇区
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +100M                                                                                    
Partition 1 of type Linux and of size 100 MiB is set

Command (m for help): n              #新建分区
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): e                      #创建扩展分区
Partition number (2-4, default 2): 
First sector (206848-41943039, default 206848): 
Using default value 206848
Last sector, +sectors or +size{K,M,G} (206848-41943039, default 41943039): 
Using default value 41943039
Partition 2 of type Extended and of size 19.9 GiB is set

Command (m for help): n                     #新建分区
Partition type:
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): l                        #创建逻辑分区
Adding logical partition 5
First sector (208896-41943039, default 208896): 
Using default value 208896
Partition 5 of type Linux and of size 19.9 GiB is set
Command (m for help): p             #查看分区创建
Disk /dev/sdc: 21.5 GB, 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
Disk label type: dos
Disk identifier: 0x71756a88

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048      206847      102400   83  Linux
/dev/sdc2          206848    41943039    20868096    5  Extended
/dev/sdc5          208896    41943039    20867072   83  Linux

Command (m for help): w                     #保存分区
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@oldboyfang ~]$ fdisk /dev/sdc -l |grep type      #检查磁盘是否是MBRf分区方式
Disk label type: dos
[root@oldboyfang ~]$ partprobe /dev/sdc                     #刷新内核,立即生效,无需重启

3,使用mkfs对磁盘进行格式化

[root@oldboyfang ~]$ mkfs -t xfs /dev/sdb6                    #使用mkfs对磁盘进行格式化

4,挂载目录

[root@oldboyfang ~]$ mount /dev/sdc data_6                 #挂载目录

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容