之前写过相关文章
Linux 服务器扩盘 终极版
现在 出一个 扩盘 pro/plus 版本文章来源:https://www.toymoban.com/news/detail-848424.html
#!/bin/bash
echo -e "\n=== START DISK LVM initial ===\n"
DISK="/dev/sdb"
echo -e "\n -- 1. check disk --\n"
lsblk
echo -e "\n -- 2. check filesystem --\n"
df -hT
echo -e "\n -- 3. initial DISK ${DISK} --\n"
echo "d
n
p
w" | fdisk $DISK
sleep 3
echo -e "\n -- 4. format/fix DISK ${DISK} --\n"
parted -l
partprobe
sleep 3
echo -e "\n -- 5. new physical volumes (pv) --\n"
echo -e "\n -- 5.1 before new pv --\n"
pvs
echo -e "\n -- 5.2 start new pv --\n"
pvcreate ${DISK}1
echo -e "\n -- 5.3 after new pv --\n"
pvs
sleep 3
echo -e "\n -- 6. new volume groups (vg) --\n"
echo -e "\n -- 6.1 before new vg --\n"
vgs
echo -e "\n -- 6.2 start new vg --\n"
vgcreate vgdata1 ${DISK}1
echo -e "\n -- 6.3 after new vg --\n"
vgs
sleep 3
echo -e "\n -- 7. new logical volumes (lv) --\n"
echo -e "\n -- 7.1 before new lv --\n"
lvs
echo -e "\n -- 7.2 start new lv --\n"
lvcreate -l +100%FREE -n lvdata1 vgdata1
echo -e "\n -- 7.3 after new lv --\n"
lvs
sleep 3
echo -e "\n -- 8. format LV xfs --\n"
mkfs.xfs /dev/vgdata1/lvdata1
sleep 3
echo -e "\n -- 9. check new add block uuid --\n"
blkid
echo -e "\n -- 10. config /etc/fstab --\n"
echo -e "\n -- 10.1 before config --\n"
cat /etc/fstab
echo -e "\n -- 10.2 new create /data1 directory --\n"
mkdir -v /data1
echo -e "\n -- 10.3 start config --\n"
echo "$(blkid | tail -n1 | awk '{print $2}' ) /data1 xfs defaults 0 0" >> /etc/fstab
echo -e "\n -- 10.4 after config --\n"
cat /etc/fstab
sleep 3
echo -e "\n -- 11. mount ${DISK} --\n"
mount -a
sleep 3
echo -e "\n -- 12. check disk --\n"
lsblk
echo -e "\n -- 13. check filesystem --\n"
df -hT
echo -e "\n=== FINISH DISK LVM initial ===\n"
我们下期见,拜拜!文章来源地址https://www.toymoban.com/news/detail-848424.html
到了这里,关于Linux 数据盘分区自动化脚本 pro/plus 版本的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!