1.虚拟机磁盘的添加

1.1在虚拟机电源关闭的状态下右击“我的计算机下的虚拟机名”选择“设置”或直接在设备下双击硬盘都会进入“虚拟机设置”

虚拟机磁盘的添加到磁盘分区正常访问步骤
虚拟机设置页面
虚拟机磁盘的添加到磁盘分区正常访问步骤

1.2在添加硬盘向导页面中点击到硬盘上在选择“添加”下来点击“下一步”,到选择磁盘类型选择”推荐”点击“下一步”,到选择磁盘选择“创建新的虚拟磁盘”下一步,到“指定磁盘容量”改写“最大磁盘大小”为10G下一步,到“指定磁盘文件”点击“完成”回到了“虚拟机设置’点击”确定“完成磁盘添加;

虚拟机磁盘的添加到磁盘分区正常访问步骤
虚拟机磁盘的添加到磁盘分区正常访问步骤
虚拟机磁盘的添加到磁盘分区正常访问步骤
虚拟机磁盘的添加到磁盘分区正常访问步骤
虚拟机磁盘的添加到磁盘分区正常访问步骤
虚拟机磁盘的添加到磁盘分区正常访问步骤

2 .磁盘管理步骤

硬盘—>分区—>格式化文件系统—>挂载(开机自动挂载)—>正常访问

2.1分区
先使用命令lsblk查看添加的磁盘;

虚拟机磁盘的添加到磁盘分区正常访问步骤
在使用命令fdisk 进行分区
[[email protected] ~]# fdisk /dev/sdb
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)
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-20971519, default 2048): //默认回车
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +200M
Partition 1 of type Linux and of size 200 MiB is set
Command (m for help): w
The partition table has been altered!
[[email protected] ~]# lsblk
sdb 8:16 0 10G 0 disk
└─sdb1 8:17 0 200M 0 part
添加磁盘分区成功

2.2 格式化文件系统
mkfs.格式(Ext3/4 XFS SWAP iso9660) /dve/磁盘名

2.3 挂载(开机自动挂载)

[[email protected] ~]# vi /etc/fstab
虚拟机磁盘的添加到磁盘分区正常访问步骤
[[email protected] ~]# df -h 查看挂载是否成功
虚拟机磁盘的添加到磁盘分区正常访问步骤

或者手动挂载 mount /dev/sdb1 /tmp
mount 命令用于挂载文件系统,把硬盘设备或分区与一个目录文件进行关联,然后就能在这个目录中看到硬设备中的数据了
mount -a #挂载所有在/etc/fstab中定义的文件系统
mount -t #指定文件系统类型
umount 卸载文件系统

2.4 正常访问

tar -czvf /tmp/etc.tar.gz /etc
虚拟机磁盘的添加到磁盘分区正常访问步骤
虚拟机磁盘的添加到磁盘分区正常访问步骤
将/etc打包到/tmp下发现磁盘分区/dev/sdb1 Use% 从6%到10%,磁盘分区正常使用

相关文章: