查看当前服务器磁盘状态
[root@log-es-47 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.9G 0 7.9G 0% /dev
tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs 7.9G 476K 7.9G 1% /run
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
/dev/vda1 40G 2.7G 35G 8% /
tmpfs 1.6G 0 1.6G 0% /run/user/0
查看服务器分区及磁盘情况:(/dev/vdb为新磁盘)
[root@localhost ~]# 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: 0x000bf3aa
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83886046 41941999+ 83 Linux
Disk /dev/vdb: 214.7 GB, 214748364800 bytes, 419430400 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
格式化新磁盘为xfs格式
[root@localhost ~]# mkfs.xfs /dev/vdb
meta-data=/dev/vdb isize=512 agcount=4, agsize=13107200 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=52428800, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=25600, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
格式化完成后,查看/dev/vdb磁盘的UUID
[root@localhost ~]# blkid /dev/vdb
/dev/vdb: UUID="3cs654gf-5643-87ft-5n1p-c54332bc391d" TYPE="xfs"
将UUID及需要挂载目录内容写入/etc/fstab
[root@localhost ~]# cat >> /etc/fstab <<EOF
>UUID=3cs654gf-5643-87ft-5n1p-c54332bc391d /data xfs defaults 1 1
>EOF
创建挂载目录并重新加载fstab内容
[root@localhost ~]# mkdir /data
[root@localhost ~]# mount -a
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.9G 0 7.9G 0% /dev
tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs 7.9G 480K 7.9G 1% /run
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
/dev/vda1 40G 2.7G 35G 8% /
tmpfs 1.6G 0 1.6G 0% /run/user/0
/dev/vdb 200G 33M 200G 1% /data
此致,新磁盘已挂载成功