• aliyun centos7-8 添加一个数据盘

参考网址
https://help.aliyun.com/document_detail/25426.htm?spm=a2c4g.11186623.0.0.34111800PkqrBK#concept-jl1-qzd-wdb

  • centos7 默认文件系统为xfs
fdisk -l  
yum install -y parted
yum install -y e2fsprogs 

#分区
parted /dev/vdb
mklabel gpt 
mkpart primary 1 100%
align-check optimal 1
print
quit

partprobe

fdisk -lu /dev/vdb

mkfs -t xfs /dev/vdb1
mkfs -t ext4 /dev/vdb1
cp /etc/fstab /etc/fstab.bak


echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` /data xfs defaults 0 0 >> /etc/fstab
echo `blkid /dev/sda1 | awk '{print $2}' | sed 's/\"//g'` /data xfs defaults 0 0 >> /etc/fstab
cat /etc/fstab
echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` /data ext4 defaults 0 0 >> /etc/fstab
cat /etc/fstab

mount -a


df -h

umount /dev/vdb1 卸载一个分区或者文件系统

#重作系统挂分区 挂不上重新格式化
mkfs -t ext4 /dev/vdb1 
cp /etc/fstab /etc/fstab.bak
echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` /data ext4 defaults 0 0 >> /etc/fstab

mount -a
#

二、扩展一个数据盘

选项三:扩展已有GPT分区
参考网址
https://help.aliyun.com/document_detail/25452.html

mount | grep "/dev/vdb"
umount /dev/vdb1
mount | grep "/dev/vdb"

parted /dev/vdb
print
rm 1
mkpart primary 1049KB 100%
print
quit
fsck -f /dev/vdb1

mount /dev/vdb1 /data
xfs_growfs /data