linux磁盘sh脚本进行分区

[root@zhaikaiyun ~]# more fdisk.sh 
#!/bin/bash

#Determine whether the disk has been partitioned
if  (( $(fdisk -l /dev/sdb|grep "^/dev/sdb"|wc -l) > 1  ))
then
    echo "This disk has been partitioned. Please check"
    exit
fi

fdisk /dev/sdb < p
n
p

p
w
EOF

echo "########### Partition complete ############ "

echo "fdisk -l /dev/sdb"
fdisk -l /dev/sdb
echo "lsblk -a"
lsblk -a

echo "##############################################"
echp ""

echo "mkfs.ext4 /dev/sdb1"
mkfs.ext4 /dev/sdb1 < y
EOF

echo "/dev/sdb1   /zhiaky  ext4  noatime,defaults  1 1" >>/etc/fstab
mount -a

echo "df -h"
df -h

#echo "======================================="
#echo "Modify disk type "
#fdisk /dev/sdb < #p
#t
#8e
#p
#w
#EOF

#echo "create pv"
#pvcreate /dev/sdb1
#pvdisplay

#echo "create vg"
#vgcreate vgdata /dev/sdb1
#vgdisplay

#echo "create lv"
#lvcreate -L 2559 -n datalv vgdata
#lvdisplay
[root@zhaikaiyun ~]# 
 

你可能感兴趣的:(linux)