if [ `whoami` != 'root' ];then
echo -e "\033[31m 请以root用户执行,Please run as root!\033[0m"
exit 1
fi
clear
function auto_add(){
DISK_SIZE=$(lsblk | awk '{print $4}' | grep -v ^[A-Z] | grep G | grep -o "[0-9]\{3,\}" | grep ^9)
DISK_NAME=$(lsblk | grep ${DISK_SIZE} | awk '{print $1}')
mkfs.ext4 -F /dev/${DISK_NAME}
[ -d /data1 ] || mkdir /data1
chmod -R 777 /data1
cp /etc/fstab{,.bak}
echo -e "UUID=$(blkid /dev/${DISK_NAME} | awk '{print $2}' | awk -F\" '{print $2}') /data1 ext4 rw,user,x-gvfs-show,nosuid,nofail 0 0" >> /etc/fstab
mount -a && echo -e "\033[32m硬盘挂载成功!\033[0m" || echo -e "\033[31m硬盘挂载失败!\033[0m"
e2label /dev/${DISK_NAME} D盘
chmod -R 777 /data1
}
auto_add
|