逻辑卷LVM批量初始化脚本

lvm批量初始化脚本

#!/usr/bin/env bash
which lvm||yum install lvm2 -y
which xfs_admin||yum install xfsprogs -y

partition="/data${1}"              #挂载点
vgname=hoolink_vg_${1}             #逻辑卷组名称
lvname=hoolink_lv_${1}             #逻辑卷名称

fdisk /dev/sd${2} << EOF
n
p
1
1

 
t
8e
w
EOF
disk="/dev/sd${2}1"
 
pvcreate $disk
vgcreate $vgname $disk
lvcreate -l 100%VG -n $lvname $vgname
mkfs.xfs /dev/$vgname/$lvname
 
mkdir -p $partition
echo "/dev/$vgname/$lvname  $partition  xfs  defaults  0 0" >> /etc/fstab
mount -a
View Code

 

posted @ 2020-04-13 15:38  雪竹子  阅读(198)  评论(0编辑  收藏  举报