Linux 判断是否有未挂载的盘 分区挂载 (挂载所有大小的盘,包括挂载超过2T的盘)
一、查看是否有未挂载的数据盘
1、查看挂载现状
df -h
2、查询未挂载详情
sudo fdisk -l
3、总结
从上面结果可以看出,还有一个一百多G的数据盘没有挂载
已全部挂载显示如下:
二、数据盘分盘并挂载(超过2T的都可以)
1、查看未分区所在盘
sudo fdisk -l
2、开始分区
parted /dev/vdb
GNU Parted 3.1
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p # P
Error: /dev/vdb: unrecognised disk label
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
(parted) mklabel gpt # mklabel gpt
Warning: The existing disk label on /dev/vdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? y # y
(parted) mkpart # mkpart
Partition name? []? vdb1 # vdb1 不要和已分配的名字重复
File system type? [ext2]? ext4 # ext4
Start? 0 # 0
End? 107GB # 107GB 盘的总大小
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore # Ignore
(parted) p # p
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: Number Start End Size File system Name Flags1 17.4kB 107GB 107GB vdb1(parted) quit # quit 退出
Information: You may need to update /etc/fstab.
3、编译挂载
cd /
# 创建挂载的文件夹
mkdir /homeE
# 编译
mkfs.ext4 /dev/vdb1
# 挂载
mount /dev/vdb1 /homeE
# 查看挂载情况
df -h
4、开机自动挂载
vim /etc/fstab......
/dev/vdb1 /homeE ext4 defaults 0 0