起源:
准备测试tfs分布式存储,发现一台服务器24块大盘,还有好几台服务器, 想想那么碰分区格式化,UUID自动挂载,还好有自动脚本。
1,yes能在你需要输入y时帮你操作,要不一台服务器不间断24次y还不知道什么时候敲击
2,UUID也能自动获取,这样才能自动挂载且盘符能固定
#!/bin/bash #mkfs.ext4 mkdir /data/disk{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24} 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 yes | mkfs.ext4 /dev/sdh yes | mkfs.ext4 /dev/sdi yes | mkfs.ext4 /dev/sdj yes | mkfs.ext4 /dev/sdk yes | mkfs.ext4 /dev/sdl yes | mkfs.ext4 /dev/sdm yes | mkfs.ext4 /dev/sdn yes | mkfs.ext4 /dev/sdo yes | mkfs.ext4 /dev/sdp yes | mkfs.ext4 /dev/sdq yes | mkfs.ext4 /dev/sdr yes | mkfs.ext4 /dev/sds yes | mkfs.ext4 /dev/sdt yes | mkfs.ext4 /dev/sdu yes | mkfs.ext4 /dev/sdv yes | mkfs.ext4 /dev/sdw yes | mkfs.ext4 /dev/sdx yes | mkfs.ext4 /dev/sdy #mount mount -t ext4 /dev/sbb /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 mount -t ext4 /dev/sdh /data/disk7 mount -t ext4 /dev/sdi /data/disk8 mount -t ext4 /dev/sdj /data/disk9 mount -t ext4 /dev/sdk /data/disk10 mount -t ext4 /dev/sdl /data/disk11 mount -t ext4 /dev/sdm /data/disk12 mount -t ext4 /dev/sdn /data/disk13 mount -t ext4 /dev/sdo /data/disk14 mount -t ext4 /dev/sdp /data/disk15 mount -t ext4 /dev/sdq /data/disk16 mount -t ext4 /dev/sdr /data/disk17 mount -t ext4 /dev/sds /data/disk18 mount -t ext4 /dev/sdt /data/disk19 mount -t ext4 /dev/sdu /data/disk20 mount -t ext4 /dev/sdv /data/disk21 mount -t ext4 /dev/sdw /data/disk22 mount -t ext4 /dev/sdx /data/disk23 mount -t ext4 /dev/sdy /data/disk24 #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 blkid /dev/sdh |awk ‘{print $2 " /data/disk7 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdi |awk ‘{print $2 " /data/disk8 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdj |awk ‘{print $2 " /data/disk9 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdk |awk ‘{print $2 " /data/disk10 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdl |awk ‘{print $2 " /data/disk11 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdm |awk ‘{print $2 " /data/disk12 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdn |awk ‘{print $2 " /data/disk13 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdo |awk ‘{print $2 " /data/disk14 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdp |awk ‘{print $2 " /data/disk15 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdq |awk ‘{print $2 " /data/disk16 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdr |awk ‘{print $2 " /data/disk17 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sds |awk ‘{print $2 " /data/disk18 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdt |awk ‘{print $2 " /data/disk19 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdu |awk ‘{print $2 " /data/disk20 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdv |awk ‘{print $2 " /data/disk21 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdw |awk ‘{print $2 " /data/disk22 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdx |awk ‘{print $2 " /data/disk23 ext4 defaults 0 0"}‘ >>/etc/fstab blkid /dev/sdy |awk ‘{print $2 " /data/disk24 ext4 defaults 0 0"}‘ >>/etc/fstab
本文出自 “jerrymin” 博客,请务必保留此出处http://jerrymin.blog.51cto.com/3002256/1768724
原文地址:http://jerrymin.blog.51cto.com/3002256/1768724