[] Shell script automatic disk partition, format, mount === autoMount.sh

 

#!/bin/bash
# Automatic disk partition, format, mount
# Of vdb virtual machine disk format the partition, use << partition command will need to import to the program fdisk
# N (create a new partition), p (create a primary partition), 1 (partition number 1 ), two blank lines (two carriage returns, the equivalent of the entire disk sub-district)
# Note: 1 behind the two carriage return (blank line) is a must! 
Fdisk / dev / VDB << EOF
n
p
1
 
 
wq
EOF
 
# Format the partition you just created good
mkfs.xfs   /dev/vdb1
 
# Create a mount point directory, date to determine whether there is a directory, does not exist, create
if [ -e /data ]; then
exit
be
mkdir /data
 
# Automatically mount the partition you just created and set boot automatically mount the partition
echo '/dev/vdb1     /data    xfs    defaults        1 2'  >> /etc/fstab
mount -a

 

Guess you like

Origin www.cnblogs.com/HeiDi-BoKe/p/11683566.html