Dell 服务器CENTOS批量大硬盘上线脚本
;查看硬盘设备
lsblk
;批量分区
parted /dev/sdf
mklabel gpt
mkpart primary 0% 100%
quit
parted /dev/sdd
mklabel gpt
mkpart primary 0% 100%
quit
parted /dev/sdb
mklabel gpt
mkpart primary 0% 100%
quit
parted /dev/sdk
mklabel gpt
mkpart primary 0% 100%
quit
parted /dev/sdi
mklabel gpt
mkpart primary 0% 100%
quit
parted /dev/sdg
mklabel gpt
mkpart primary 0% 100%
quit
parted /dev/sde
mklabel gpt
mkpart primary 0% 100%
quit
parted /dev/sdc
mklabel gpt
mkpart primary 0% 100%
quit
parted /dev/sdl
mklabel gpt
mkpart primary 0% 100%
quit
parted /dev/sda
mklabel gpt
mkpart primary 0% 100%
quit
parted /dev/sdj
mklabel gpt
mkpart primary 0% 100%
quit
parted /dev/sdh
mklabel gpt
mkpart primary 0% 100%
quit
;格式化
mkfs.ext4 /dev/sdf1
mkfs.ext4 /dev/sdd1
mkfs.ext4 /dev/sdb1
mkfs.ext4 /dev/sdk1
mkfs.ext4 /dev/sdi1
mkfs.ext4 /dev/sdg1
mkfs.ext4 /dev/sdc1
mkfs.ext4 /dev/sdl1
mkfs.ext4 /dev/sda1
mkfs.ext4 /dev/sdj1
mkfs.ext4 /dev/sdh1
;建立挂载目录
cd ..
mkdir data data1 data2 data3 data4 data5 data6 data7 data8 data9 data10
;查看UUID
sudo blkid -s UUID
得出的UUID分列,得到
UUID="d8e15465-5204-49d2-b46c-f866aaf6e74a"
UUID="fe9a0eed-c98a-45d3-8bd5-421777a31bb6"
UUID="ad8ecc38-3b0f-4a39-90e1-0c3d0404506e"
UUID="2e2e14af-4d07-4040-a441-ba91146b992c"
UUID="bfca2d33-18ce-4aa5-b3fd-3276281698e8"
UUID="831e17fe-d464-4453-be99-e302718652e7"
UUID="5fad9768-a873-469e-b15e-8dcdbbb8137f"
UUID="644ce50d-2fad-4a98-a44c-3a18f78c5976"
UUID="2d608336-37da-485c-a5e7-77af8d853862"
UUID="1cabcbd3-149f-4671-8615-9fe03146861b"
UUID="132564f4-f85d-4ce7-9453-6b073efd05cf"
;fstab写入
UUID="d8e15465-5204-49d2-b46c-f866aaf6e74a" /data10 ext4 defaults 0 0
UUID="fe9a0eed-c98a-45d3-8bd5-421777a31bb6" /data1 ext4 defaults 0 0
UUID="ad8ecc38-3b0f-4a39-90e1-0c3d0404506e" /data2 ext4 defaults 0 0
UUID="2e2e14af-4d07-4040-a441-ba91146b992c" /data3 ext4 defaults 0 0
UUID="bfca2d33-18ce-4aa5-b3fd-3276281698e8" /data4 ext4 defaults 0 0
UUID="831e17fe-d464-4453-be99-e302718652e7" /data5 ext4 defaults 0 0
UUID="5fad9768-a873-469e-b15e-8dcdbbb8137f" /data6 ext4 defaults 0 0
UUID="644ce50d-2fad-4a98-a44c-3a18f78c5976" /data7 ext4 defaults 0 0
UUID="2d608336-37da-485c-a5e7-77af8d853862" /data8 ext4 defaults 0 0
UUID="1cabcbd3-149f-4671-8615-9fe03146861b" /data9 ext4 defaults 0 0
UUID="132564f4-f85d-4ce7-9453-6b073efd05cf" /data ext4 defaults 0 0;raid1(查看smartctl --all /dev/sdl)