欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 建筑 > 第八章 磁盘管理未完待续

第八章 磁盘管理未完待续

2025/4/30 15:47:40 来源:https://blog.csdn.net/qq_32789063/article/details/147620905  浏览:    关键词:第八章 磁盘管理未完待续

1.磁盘管理

磁盘简介

1.硬盘分类
磁盘/硬盘/disk存储设备类型从工作原理区分说明图示
机械机械硬盘即是传统普通硬盘,主要由:盘片,磁头,盘片转轴及控制电机,磁头控制器,数据转换器,接口,缓存等几个部分组成。磁道大小4K在这里插入图片描述
固态固态驱动器(Solid State Disk或Solid State Drive,简称SSD),俗称固态硬盘,固态硬盘是用固态电子存储芯片阵列而制成的硬盘在这里插入图片描述
2.尺寸

尺寸 3.5 、2.5 、1.8 英寸

3.磁盘接口类型
类型说明图示
SATA(Serial ATA)类型:串行接口(替代旧式并行IDE接口)在这里插入图片描述
SAS(Serial Attached SCSI)类型:企业级串行接口(兼容SATA设备)在这里插入图片描述
NVMe(Non-Volatile Memory Express)类型:基于PCIe通道的协议(非物理接口)在这里插入图片描述
IDE(PATA,已淘汰)类型:并行接口(旧式)在这里插入图片描述
SCSI(Small Computer System Interface,逐渐淘汰)类型:并行/串行接口(企业级)在这里插入图片描述
4. 转速

5400/7200/10000/15000rpm

5.厂商

西部数据/希捷(美国)
三星(韩国)
日立/金士顿(日本)

6.术语
  • 盘片(platter)
    一块硬盘有若干盘片,每个盘片有可以存储数据的上、下两盘面
    (Side)。这些盘面堆叠在主轴上高速旋转,它们从上至下从“0”开
    始依次编号。

  • 磁道(track)
    每个盘面被划分成许多同心圆,这些同心圆轨迹叫做磁道;磁道从
    外向内从0开始顺序编号。

  • 扇区(sector)
    扇区是磁盘的最小组成单元,通常是512字节。(由于不断提高磁盘的大小,部分厂商设定每个扇区的大小是4096字节)

  • 扇面
    同一角度的扇区被叫扇面

  • 柱面(cylinder)
    所有盘面上的同一磁道构成一个圆柱,称作柱面

  • 簇/块 (block)
    磁盘块/簇(虚拟出来的)。 块是操作系统中最小的逻辑存储单位。操作系统与磁盘打交道的最小单位是磁盘块。
    通俗的来讲,在Windows下如NTFS等文件系统中叫做簇;在Linux下如Ext4等文件系统中叫做块(block)。每个簇或者块可以包括2、4、8、16、32、64…2的n次方个扇区。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

kernel对不同接口硬盘命名方式
RHEL9/centos9

7.块设备命名
设备类型设备命名模式
SATA/SAS/USB 附加存储(SCSI 驱动器)/dev/sda、​/dev/sdb、​/dev/sdc …​
virtio-blk 半虚拟化存储 (VM)/dev/vda、​ /dev/vdb、​/dev/vdc …​
virtio-scsi 半虚拟化存储 (VM)/dev/sda、​/dev/sdb、​/dev/sdc …​
NVMe 附加存储 (SSD)/dev/nvme0、​/dev/nvme1 …
SD/MMC/eMMC 存储(SD 卡)/dev/mmcblk0、​/dev/mmcblk1 …
IDE(并口)/dev/hda、/dev/hdb

说明
/dev设备文件目录
sda是一个文件
s代表sata就是串口
d代表磁盘
a第一块
/dev/sdb 表示第二块sata盘

8.磁盘分区类型

MBR
主引导记录(MBR,Master Boot Record)是位于磁盘最前边的一段引导MBR支持最大的磁盘容量是 <2TB。设计时分配4个分区,如果希望超过4个分区,需放弃主分区,改为扩展分区和逻辑分区。
fdisk命令

GPT
全局唯一标识分区表(GUIDPartition Table,缩写:GPT)是一个实体硬盘的分区表的结构布局的标准。GPT 支持大于2T的硬盘,支持128个分区。
gdisk命令

操作

1.添加磁盘

VMWARE增加磁盘
先关闭虚拟机电源
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.管理磁盘流程三部曲

分区(MBR或者GPT) ---->格式化/文件系统 Filesystem ----> 挂载
在这里插入图片描述

1.查看磁盘信息
方法1

[root@station ~]# ll /dev/sd*
brw-rw----. 1 root disk 8,  0 Apr 29 23:11 /dev/sda
brw-rw----. 1 root disk 8, 16 Apr 29 23:11 /dev/sdb
[root@station ~]# ll /dev/nvme0*
crw-------. 1 root root 241, 0 Apr 29 23:11 /dev/nvme0
brw-rw----. 1 root disk 259, 0 Apr 29 23:11 /dev/nvme0n1
brw-rw----. 1 root disk 259, 1 Apr 29 23:11 /dev/nvme0n1p1
brw-rw----. 1 root disk 259, 2 Apr 29 23:11 /dev/nvme0n1p2
brw-rw----. 1 root disk 259, 3 Apr 29 23:11 /dev/nvme0n1p3

c(字符设备,Character Device)
b(块设备,Block Device)

方法2

[root@station ~]# lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda             8:0    0    5G  0 disk 
sdb             8:16   0    5G  0 disk 
sr0            11:0    1 1024M  0 rom  
nvme0n1       259:0    0  100G  0 disk 
├─nvme0n1p1   259:1    0  600M  0 part /boot/efi
├─nvme0n1p2   259:2    0    1G  0 part /boot
└─nvme0n1p3   259:3    0 98.4G  0 part └─rhel-root 253:0    0 98.4G  0 lvm  /

名称 设备类型 序号 是否可移动设备 大小 是否只读 磁盘或分区
挂载点

[root@station ~]# fdisk /dev/sdaWelcome to fdisk (util-linux 2.37.4).
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.
Created a new DOS disklabel with disk identifier 0x258c5ad5.Command (m for help): mHelp:DOS (MBR)a   toggle a bootable flagb   edit nested BSD disklabelc   toggle the dos compatibility flagGenericd   delete a partitionF   list free unpartitioned spacel   list known partition typesn   add a new partitionp   print the partition tablet   change a partition typev   verify the partition tablei   print information about a partitionMiscm   print this menuu   change display/entry unitsx   extra functionality (experts only)ScriptI   load disk layout from sfdisk script fileO   dump disk layout to sfdisk script fileSave & Exitw   write table to disk and exitq   quit without saving changesCreate a new labelg   create a new empty GPT partition tableG   create a new empty SGI (IRIX) partition tableo   create a new empty DOS partition tables   create a new empty Sun partition tableCommand (m for help): n
Partition typep   primary (0 primary, 0 extended, 4 free)e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-10485759, default 2048): ## 一个扇区 = 512KB
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-10485759, default 10485759): +1GCreated a new partition 1 of type 'Linux' and of size 1 GiB.Command (m for help): P
P: unknown commandCommand (m for help): pDisk /dev/sda: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x258c5ad5Device     Boot Start     End Sectors Size Id Type
/dev/sda1        2048 2099199 2097152   1G 83 LinuxCommand (m for help): n
Partition typep   primary (1 primary, 0 extended, 3 free)e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2099200-10485759, default 2099200): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2099200-10485759, default 10485759): +1GCreated a new partition 2 of type 'Linux' and of size 1 GiB.Command (m for help): p
Disk /dev/sda: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x258c5ad5Device     Boot   Start     End Sectors Size Id Type
/dev/sda1          2048 2099199 2097152   1G 83 Linux
/dev/sda2       2099200 4196351 2097152   1G 83 LinuxCommand (m for help): n
Partition typep   primary (2 primary, 0 extended, 2 free)e   extended (container for logical partitions)
Select (default p): Using default response p.
Partition number (3,4, default 3): 
First sector (4196352-10485759, default 4196352): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (4196352-10485759, default 10485759): +1GCreated a new partition 3 of type 'Linux' and of size 1 GiB.Command (m for help): p
Disk /dev/sda: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x258c5ad5Device     Boot   Start     End Sectors Size Id Type
/dev/sda1          2048 2099199 2097152   1G 83 Linux
/dev/sda2       2099200 4196351 2097152   1G 83 Linux
/dev/sda3       4196352 6293503 2097152   1G 83 LinuxCommand (m for help): n # 新建分区
Partition typep   primary (3 primary, 0 extended, 1 free)e   extended (container for logical partitions)
Select (default e): p #p主分区  e扩展分区Selected partition 4
First sector (6293504-10485759, default 6293504): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (6293504-10485759, default 10485759): +1GCreated a new partition 4 of type 'Linux' and of size 1 GiB.Command (m for help): p # 打印分区信息
Disk /dev/sda: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x258c5ad5Device     Boot   Start     End Sectors Size Id Type
/dev/sda1          2048 2099199 2097152   1G 83 Linux
/dev/sda2       2099200 4196351 2097152   1G 83 Linux
/dev/sda3       4196352 6293503 2097152   1G 83 Linux
/dev/sda4       6293504 8390655 2097152   1G 83 LinuxCommand (m for help): w # w保存分区信息,自动退出分区工具
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.# 刷新分区表
[root@station ~]# partprobe /dev/sda
# 查看分区结果
[root@station ~]# fdisk -l /dev/sda
Disk /dev/sda: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x258c5ad5Device     Boot   Start     End Sectors Size Id Type
/dev/sda1          2048 2099199 2097152   1G 83 Linux
/dev/sda2       2099200 4196351 2097152   1G 83 Linux
/dev/sda3       4196352 6293503 2097152   1G 83 Linux
/dev/sda4       6293504 8390655 2097152   1G 83 Linux[root@station ~]# lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda             8:0    0    5G  0 disk 
├─sda1          8:1    0    1G  0 part 
├─sda2          8:2    0    1G  0 part 
├─sda3          8:3    0    1G  0 part 
└─sda4          8:4    0    1G  0 part 
sdb             8:16   0    5G  0 disk 
sr0            11:0    1 1024M  0 rom  
nvme0n1       259:0    0  100G  0 disk 
├─nvme0n1p1   259:1    0  600M  0 part /boot/efi
├─nvme0n1p2   259:2    0    1G  0 part /boot
└─nvme0n1p3   259:3    0 98.4G  0 part └─rhel-root 253:0    0 98.4G  0 lvm  /# 创建文件系统
[root@station ~]# mkfs.ext4 /dev/sda1
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: f47827c9-7275-4a9d-bf7b-6a567a8c96ba
Superblock backups stored on blocks: 32768, 98304, 163840, 229376Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
[root@station ~]# mkfs.ext4 /dev/sda2
[root@station ~]# mkfs.ext4 /dev/sda3
[root@station ~]# mkfs.ext4 /dev/sda4# 挂载mount 
## 手动挂载
## 创建挂载点,一个分区一个挂载点
[root@station ~]# mkdir /mnt/disk1
# -t ext4指定文件系统类型,最好加上,增强可读性
[root@station ~]# mount -t ext4 /dev/sda1 /mnt/disk1# 查看挂载信息
## 方法1 df -hT
[root@station ~]# df -Th
Filesystem            Type      Size  Used Avail Use% Mounted on
/dev/sda1             ext4      974M   24K  907M   1% /mnt/disk1## 方法2 mount
[root@station ~]#  mount
/dev/sda1 on /mnt/disk1 type ext4 (rw,relatime,seclabel)
# mount 看的是磁盘有没有特殊属性,具体属性在后续讲解。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词