K8S-数据磁盘挂载
说在前面:如果没有数据盘或者不需要磁盘挂载,请忽略此章节,如果所有机器都需要挂载磁盘,请逐一执行即可
1、查看磁盘
[root@ecs-c024 ~]# fdisk -l
输出:
Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 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: 0x000de1a0
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83886079 41942016 83 Linux
## 待挂载磁盘
Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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
2、格式化磁盘
注意:如果磁盘已经格式化则不需要执行此步骤
[root@ecs-c024 ~]# mkfs.ext4 /dev/vdb
3、创建数据目录
[root@ecs-c024 ~]# mkdir /data
4、挂载磁盘
[root@ecs-c024 ~]# mount /dev/vdb /data
如果输出:
mount: /dev/sdb is write-protected, mounting read-only
mount: unknown filesystem type '(null)'
则执行步骤2
5、开机自动挂载磁盘
[root@ecs-c024 ~]# vim /etc/fstab
将以下配置写入fstab文件
/dev/vdb /data ext4 defaults 0 0
[root@ecs-c024 ~]# cat /etc/fstab
输出:
UUID=b64c5c5d-9f6b-4754-9e1e-eaef91437f7a / ext4 defaults 1 1
/dev/vdb /data ext4 defaults 0 0
6、重启
[root@ecs-c024 ~]# reboot
7、查看挂载
[root@ecs-c024 ~]# df -h
输出:
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 13M 7.8G 1% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/vda1 40G 3.1G 35G 9% /
## 出现 /dev/vdb 表示挂载成功
/dev/vdb 99G 6.5G 87G 7% /data