查看磁盘挂载情况
df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 17M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/vda2 36G 2.6G 31G 8% /
tmpfs 783M 0 783M 0% /run/user/0
可以看到已挂载磁盘中没有申请的 500G 存储
查看磁盘挂载情况
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 40G 0 disk
├─vda1 253:1 0 4G 0 part [SWAP]
└─vda2 253:2 0 36G 0 part /
vdb 253:16 0 500G 0 disk
可以看到 vdb 处于未挂载状态
查看磁盘详情
fdisk -l | less
Device Boot Start End Blocks Id System
/dev/vda1 2048 8390655 4194304 82 Linux swap / Solaris
/dev/vda2 * 8390656 83886046 37747695+ 83 Linux
Disk /dev/vdb: 536.9 GB, 536870912000 bytes, 1048576000 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
按Q键退出
由上可知未挂载设备 /dev/vdb的详细信息
创建分区
1.创建分区
parted /dev/vdb
2.显示
GNU Parted 3.1
Using /dev/xvde
Welcome to GNU Parted! Type 'help' to view a list of commands.
3.输入
(parted) mklabel gpt
(parted) mkpart primary 0% 100%
(parted) print
(parted) quit
4.格式化分区
mkfs.ext4 /dev/vdb
5.创建挂载点
mkdir /data
6.挂载
vim /etc/fstab
7.添加并保存
/dev/vdb /data ext4 defaults 0 0
8.全部挂载
mount -a
9.验证
df -hT
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 3.9G 17M 3.9G 1% /run
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/vda2 ext4 36G 2.6G 31G 8% /
tmpfs tmpfs 783M 0 783M 0% /run/user/0
/dev/vdb ext4 493G 73M 467G 1% /data
最后一行说明 /dev/vdb 成功挂载到了 /data 目录下