今天在虚拟机内玩了一下centos7 添加虚拟硬盘并分区,结束之后总结并写出来分享下。
磁盘分区挂载
先添加一块虚拟硬盘默认20G就可以了,最好是虚拟机关机的情况下去做。不然添加硬盘后有可能虚拟机识别不了,还需要重新启动虚拟机。
图一:
添加之后查看系统盘,sda是我的系统盘。sdb是刚刚添加的硬盘。
[root@linuxprobe Desktop]# ls -l /dev/sd*
brw-rw----. 1 root disk 8, 0 Jul 5 2019 /dev/sda
brw-rw----. 1 root disk 8, 1 Jul 5 2019 /dev/sda1
brw-rw----. 1 root disk 8, 2 Jul 5 2019 /dev/sda2
brw-rw----. 1 root disk 8, 16 Jul 5 2019 /dev/sdb
继续对磁盘进行分区,关于分区理论如果不是太明白的话推荐参考一下鸟哥的linux私房菜。里面介绍的很详细。
[root@linuxprobe Desktop]# 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.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x87d45f61.
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 **n参数用于创建新的分区**
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p **参数p是创建主分区,e是创建扩展分区**
Partition number (1-4, default 1): **输入创建分区编号,默认为1**
First sector (2048-41943039, default 2048): **输入开始扇区,此处无需输入默认即可**
Using default value 20