我是新手。我学习Linux已有一段时间了,而且还没有发表文章。我今天刚刚了解了磁盘安装,所以我想写一篇文章!
挂接用于在当前设备(硬盘)和当前根目录下的文件夹之间建立连接关系。
由于LInux操作系统中只有一个根,因此只能从该根目录下的目录执行所有访问,并且如果要使用它,则只能链接到该根目录下的目录。
安装硬盘需要4个步骤。 1添加新硬盘。 2创建一个分区。 3划分硬盘格式。 4个坐骑
1.由于已安装,因此必须添加硬盘。打开VMware,右键单击要操作的虚拟机,然后单击设置

2.单击“添加”以选择硬盘,然后按照说明进行设置

添加3.后,将会有一个额外的硬盘驱动器

4.添加后,您必须扫描系统下新添加的硬盘
此命令可以定义为别名,毕竟每次都键入这么长的命令太麻烦了
[19:58:51 root@localhost ~]#echo - - - > /sys/class/scsi_host/host0/scan;echo - - - > /sys/class/scsi_host/host1/scan;echo - - - > /sys/class/scsi_host/host2/scan;
使用lsblk命令检查是否可以识别新添加的硬盘。 sdb是我新添加的硬盘。如果添加新硬盘,它将以sdc命名,依此类推。
[19:58:09 root@localhost ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 100G 0 part /
├─sda3 8:3 0 4G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 50G 0 part /data
sdb 8:16 0 20G 0 disk
sr0 11:0 1 1024M 0 rom 5.分区,MBE和GPT是最常用的两种分区模式
1) MBR:1982年的主引导记录,用32位代表扇区数和不超过2TMBR的分区:1982年的主引导记录,用32位代表扇区数和分区数不超过2T
2) GPT:GUID(全局唯一标识符)分区表使用64位支持128个分区,使用128位UUID(通用唯一标识符)支持8Z(512Byte /块)和64Z(4096Byte /块)。代表磁盘和分区GPT分区表会在开始和结束时自动备份,并具有CRC校验位。 UEFI(统一可扩展固件接口)硬件支持GPT,因此可以启动操作系统
因为我新添加的硬盘只有20G,所以在这里我使用MBR进行分区,使用“ fdisk”工具,首先使用“ man”命令检查是否安装了fdisk工具,如果没有,请安装它。 yum -y install fdisk”,在安装前检查新添加的磁盘的位置。通常,新添加的硬盘在扫描并添加后将存储在“ / dev /”下

知道位置后,使用fdisk工具进行分区,然后是文件路径和文件名,然后输入交互式系统(模式)
[10:43:00 root@localhost ~]#fdisk /dev/sdb按“ m”以获取帮助
[10:43:00 root@localhost ~]#fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1).
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 0x63f29422.
Command (m for help): m
Help:
DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition #创建新分区
p print the partition table #显示当前分区表
t change a partition type
v verify the partition table
i print information about a partition
Misc
m print this menu
u change display/entry units
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
按“ p”显示当前分区表

Command (m for help): p
Disk /dev/sdb: 20 GiB, 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
Disklabel type: dos
Disk identifier: 0x63f29422
按“ n”创建一个新分区,这里将询问是创建主分区还是扩展分区,
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)如果没有特殊要求,只需对主分区按“ p”。系统将在此处要求您为硬盘分配一个编号。您可以直接输入1-4中的数字,或按Enter键,系统会自动将其分为1。
Select (default p): p
Partition number (1-4, default 1):
系统将要求您指定扇区位置的值,在系统提示的值内输入有效值,然后在此处按Enter键,系统将从默认的起始位置开始分割。
First sector (2048-41943039, default 2048): #也可以自己指定起始位置,不必从2048开始下一步是指定结束扇区位置,该位置与开始位置同义。我将直接按Enter键并接受默认值,即所有值。 (如果要划分1G,请在此行末尾写“ + 1G”)
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039): Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039):
Created a new partition 1 of type Linux and of size 20 GiB.
Command (m for help): p
Disk /dev/sdb: 20 GiB, 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
Disklabel type: dos
Disk identifier: 0x63f29422
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 41943039 41940992 20G 83 Linux #此处为我新创建出的分区,sdb1
最后保存并退出! “ W”
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

使用“ lsblk”进行查看,(*如果使用旧硬盘创建的分区可能无法直接显示新创建的分区,则必须首先同步分区表,使用“ partprobe”进行同步,此命令用于centos 5、 7、 8是常见的,但是centos6有bug,您需要使用“ partx -a / dev /'(添加新创建的分区)”进行同步,我使用的是新添加的硬盘驱动器,因此它可以直接显示)
[11:23:05 root@localhost ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 100G 0 part /
├─sda3 8:3 0 4G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 50G 0 part /data
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 20G 0 part #这就是刚刚创建好的分区
sr0 11:0 1 1024M 0 rom 6创建文件系统
新创建的磁盘尚无系统文件,因此可以理解为未格式化。使用“ lsblk -f”查看硬盘没有分区格式和UUID。

使用“ blkid”查看硬盘的UUID。 sdb1没有UUID。
创建文件系统。诸如ext 2、 ext 3、 ext 4、 xsf之类的存储格式需要手动创建。
[15:04:54 root@localhost ~]#mkfs.ext4 /dev/sdb1 #mkfs. 后加想创建的文件系统格式,跟上创建的磁盘路径。
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 5242624 4k blocks and 1310720 inodes
Filesystem UUID: e9dc87d7-26be-4f78-b33a-d43575a8ad48
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 再次使用“ lsblk -f”和“ blkid”检查文件系统格式和UUDI。

7个坐骑
[15:27:44 root@localhost ~]#mount /dev/sdb1 /mnt ##使用“mount”命令跟上磁盘所在文件在跟上想挂载的位置 回车 (*注意空格)
[15:29:53 root@localhost ~]#lsblk ##再次查看分区
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 100G 0 part /
├─sda3 8:3 0 4G 0 part [SWAP]
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 50G 0 part /data
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 20G 0 part /mnt ##此分区已经挂载到“mnt”目录下
sr0 11:0 1 1024M 0 rom 至此,添加分区和装入磁盘的操作已经完成,希望对Linux小白会有所帮助,如果文章有错误,请在注释部分添加它^-^ >
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/dianqi/article-369110-1.html
反正从来不用小米的东西
你的老师也是白教你了