感谢支持
我们一直在努力

配置VMware挂载新加入的磁盘

在VMware虚拟机配置中增加磁盘后,启动Linux,使用root登录。

首先查看未分区的磁盘,使用下面命令:

## 查看未使用的磁盘
fdisk -l

 

磁盘/dev/sdb后面没有任何分区,是新挂载的磁盘

输入下面命令来开始对磁盘/dev/sdb进行分区

## 开始格式化磁盘 ##
fdisk /dev/sdb

有如下提示:

[root@localhost dev]# fdisk /dev/sdb
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.


Command (m for help): 

输入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) 

首选使用n来创建一个扩展分区,输入选项n:

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 

选择创建扩展分区,输入选项e,然后选择扩展分区编号、起始位置和大小,我们选择整个磁盘只创建一个扩展分区:

Select (default p): e
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): 
Using default value 41943039
Partition 1 of type Extended and of size 20 GiB is set

扩展分区创建好后,可以在此基础上进行创建逻辑分区,我们创建2个逻辑分区并分别设置为10G:

Command (m for help): n     
Partition type:
   p   primary (0 primary, 1 extended, 3 free)
   l   logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (4096-41943039, default 4096): 
Using default value 4096
Last sector, +sectors or +size{K,M,G} (4096-41943039, default 41943039): +10G
Partition 5 of type Linux and of size 10 GiB is set

Command (m for help): n  
Partition type:
   p   primary (0 primary, 1 extended, 3 free)
   l   logical (numbered from 5)
Select (default p): l
Adding logical partition 6
First sector (20977664-41943039, default 20977664): 
Using default value 20977664
Last sector, +sectors or +size{K,M,G} (20977664-41943039, default 41943039): 
Using default value 41943039
Partition 6 of type Linux and of size 10 GiB is set

最后使用选项p来查看分好的分区:

Command (m for help): p

Disk /dev/sdb: 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: 0x40e44e64

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    41943039    20970496    5  Extended
/dev/sdb5            4096    20975615    10485760   83  Linux
/dev/sdb6        20977664    41943039    10482688   83  Linux 

为磁盘分配好分区后,需要使用选项w来进行保存:

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

在执行partprobe命令来重新读取分区信息,如果有警告可以忽略。

## 重新读取分区信息 ##
partprobe

然后需要对磁盘进行格式化,使用mkfs将磁盘格式化为ext4格式(注意扩展分区不能进行格式化)

mkfs -t ext4 /dev/sdb5
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 655360 inodes, 2621440 blocks 131072 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2151677952 80 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done 

然后我们创建两个目录来挂载这两个逻辑分区:

## 然后创建目录 ##
mkdir /disk5 /disk6

## 使用mount命令来挂载目录 ##
mount /dev/sdb5 /disk5
mount /dev/sdb6 /disk6

最后使用mount命令来查看挂载情况

[root@localhost dev]# ## 使用mount命令来查看挂载情况 ##
[root@localhost dev]# mount | grep "sdb"
/dev/sdb5 on /disk5 type ext4 (rw,relatime,seclabel,data=ordered)
/dev/sdb6 on /disk6 type ext4 (rw,relatime,seclabel,data=ordered)

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-01/139596.htm

赞(0) 打赏
转载请注明出处:服务器评测 » 配置VMware挂载新加入的磁盘
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏