多磁盘自动分区自动挂载脚本

#!bin/bash
#mkfs.ext4
mkdir /data/disk{1,2,3,4,5,6}
yes | mkfs.ext4 /dev/sdb
yes | mkfs.ext4 /dev/sdc
yes | mkfs.ext4 /dev/sdd
yes | mkfs.ext4 /dev/sde
yes | mkfs.ext4 /dev/sdf
yes | mkfs.ext4 /dev/sdg

#mount
mount -t ext4 /dev/sdb /data/disk1
mount -t ext4 /dev/sdc /data/disk2
mount -t ext4 /dev/sdd /data/disk3
mount -t ext4 /dev/sde /data/disk4
mount -t ext4 /dev/sdf /data/disk5
mount -t ext4 /dev/sdg /data/disk6

#auto mount
cp /etc/fstab /etc/fstab.bak
blkid /dev/sdb |awk '{print $2 " /data/disk1 ext4 defaults 0 0"}' >>/etc/fstab
blkid /dev/sdc |awk '{print $2 " /data/disk2 ext4 defaults 0 0"}' >>/etc/fstab
blkid /dev/sdd |awk '{print $2 " /data/disk3 ext4 defaults 0 0"}' >>/etc/fstab
blkid /dev/sde |awk '{print $2 " /data/disk4 ext4 defaults 0 0"}' >>/etc/fstab
blkid /dev/sdf |awk '{print $2 " /data/disk5 ext4 defaults 0 0"}' >>/etc/fstab
blkid /dev/sdg |awk '{print $2 " /data/disk6 ext4 defaults 0 0"}' >>/etc/fstab

  

转载于:https://www.cnblogs.com/pythonal/p/7519809.html

你可能感兴趣的:(多磁盘自动分区自动挂载脚本)