LVM_DISK_Auto_Partition_Tools.sh 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #!/bin/bash
  2. echo "------------------------------------------------------------------------------------------------------------------------------------------------------"
  3. echo -e "\033[33m LVM DISK Auto Partition Tools Version: 1.0.2 (20190622) \033[0m | Technical support provided by [ https://cxthhhhh.com ] "
  4. echo "------------------------------------------------------------------------------------------------------------------------------------------------------"
  5. echo -e "\033[33m 8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888 \033[0m"
  6. echo -e "\033[33m 8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888 \033[0m"
  7. echo -e "\033[33m 88888888888888888888888 8888888 888888 88 8888888 88888888 88888 8888 888 888 888888888888888888888888888 \033[0m"
  8. echo -e "\033[33m 88888888888888888888888 88888888 888888 888 888888 88888888 88888 888 888 888888888 88 88888888888888888888888888888 \033[0m"
  9. echo -e "\033[33m 88888888888888888888888 888888888 8888 8888 8 8888 8 88888888 8888888 888 888 88888888 8 888888888888888888888888888888 \033[0m"
  10. echo -e "\033[33m 88888888888888888888888 888888888 88 88888 88 88 88 88888888 8888888 888 88888 8888 8888888888888888888888888888888 \033[0m"
  11. echo -e "\033[33m 88888888888888888888888 8888888888 88 88888 888 8 888 88888888 888888 888 888888888 88 8 88888888888888888888888888888 \033[0m"
  12. echo -e "\033[33m 88888888888888888888888 88888888888 888888 888 888 88888888 88888 8888 8888888888 88 88 8888888888888888888888888888 \033[0m"
  13. echo -e "\033[33m 88888888888888888888888 888888 8888888 8888 8888 88888888 888888 888 888 8888 88888888888888888888888888 \033[0m"
  14. echo -e "\033[33m 8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888 \033[0m"
  15. echo -e "\033[33m 8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888 \033[0m"
  16. echo -e "\033[33m 88888888 888888888888888888888888888888888888888888888888 88888888888888888888888888888888888 88888888888 88888888888888888888888888888 \033[0m"
  17. echo -e "\033[33m 8888888 888888888888888888888 88888888888888888888888 888888888888888888888888 88888 8888 88888 88888888888888888888888888888 \033[0m"
  18. echo -e "\033[33m 888888 8 88888888888888888888 88888888888888888888888 8888 88888888888888888888888 888888888888 8888888888888888888888888888888888888 \033[0m"
  19. echo -e "\033[33m 88888 88 88888 88888 88 888 88888888 8888 88 8888 8 88 88 88 8888 8888 88 \033[0m"
  20. echo -e "\033[33m 8888 8888 8888 88888 8888 8888 88888 8888888 888888888 888 88888 88888 8888 88888 888 88888 888 8888 88 \033[0m"
  21. echo -e "\033[33m 888 888 88888 8888 8888 88888 8888888 8888888888 888 888888 88888 8888 88888 88 88888 888 8888 88 \033[0m"
  22. echo -e "\033[33m 888 888888 88 888 8888 8888 88888 88888888 888888888 8888 888 888888 8888 8888 88888 888 88888 888 8888 88 \033[0m"
  23. echo -e "\033[33m 88 8888888 888 8888 888 888888888 888888888 888 8888888 88 88888 88 8888 8888 8888 88 \033[0m"
  24. echo -e "\033[33m 8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888 \033[0m"
  25. echo "------------------------------------------------------------------------------------------------------------------------------------------------------"
  26. echo -e "\033[33m LVM DISK Auto Partition Tools Version: 1.0.2 (20190622) \033[0m | Technical support provided by [ https://cxthhhhh.com ] "
  27. echo "------------------------------------------------------------------------------------------------------------------------------------------------------"
  28. echo "Analyze Disk type (Virtual/Physical)......"
  29. sleep 5
  30. if [ -b /dev/vda1 ]; then
  31. echo "Disk type: Virtual Disk"
  32. echo "Recognition completed, waiting for disk response."
  33. echo "Automatic partitioning will take more than 2 minutes to complete."
  34. sleep 3s
  35. echo "n
  36. p
  37. 3
  38. t
  39. 3
  40. 8e
  41. w
  42. " | fdisk /dev/vda
  43. sleep 10s
  44. echo "In the partition (1/5), waiting for the disk response will take more than 30 seconds."
  45. partprobe
  46. sleep 20s
  47. echo "In the partition (2/5), waiting for the disk response will take more than 15 seconds."
  48. pvcreate /dev/vda3
  49. sleep 11s
  50. echo "In the partition (3/5), waiting for the disk response will take more than 15 seconds."
  51. vgextend centos /dev/vda3
  52. sleep 11s
  53. echo "In the partition (4/5), waiting for the disk response will take more than 15 seconds."
  54. lvextend -l +100%FREE /dev/mapper/centos-root
  55. sleep 11s
  56. echo "In the partition (5/5), waiting for the disk response will take more than 10 seconds."
  57. resize2fs -p /dev/mapper/centos-root
  58. sleep 6s
  59. elif [ -b /dev/xvda1 ]; then
  60. echo "Disk type: Virtual Disk"
  61. echo "Recognition completed, waiting for disk response."
  62. echo "Automatic partitioning will take more than 2 minutes to complete."
  63. sleep 3s
  64. echo "n
  65. p
  66. 3
  67. t
  68. 3
  69. 8e
  70. w
  71. " | fdisk /dev/xvda
  72. sleep 10s
  73. echo "In the partition (1/5), waiting for the disk response will take more than 30 seconds."
  74. partprobe
  75. sleep 20s
  76. echo "In the partition (2/5), waiting for the disk response will take more than 15 seconds."
  77. pvcreate /dev/vda3
  78. sleep 11s
  79. echo "In the partition (3/5), waiting for the disk response will take more than 15 seconds."
  80. vgextend centos /dev/vda3
  81. sleep 11s
  82. echo "In the partition (4/5), waiting for the disk response will take more than 15 seconds."
  83. lvextend -l +100%FREE /dev/mapper/centos-root
  84. sleep 11s
  85. echo "In the partition (5/5), waiting for the disk response will take more than 10 seconds."
  86. resize2fs -p /dev/mapper/centos-root
  87. sleep 6s
  88. else
  89. echo "Disk type: Physical Disk"
  90. echo "Recognition completed, waiting for disk response."
  91. echo "Automatic partitioning will take more than 2 minutes to complete."
  92. sleep 3s
  93. echo "n
  94. p
  95. 3
  96. t
  97. 3
  98. 8e
  99. w
  100. " | fdisk /dev/sda
  101. sleep 10s
  102. echo "In the partition (1/5), waiting for the disk response will take more than 30 seconds."
  103. partprobe
  104. sleep 20s
  105. echo "In the partition (2/5), waiting for the disk response will take more than 15 seconds."
  106. pvcreate /dev/sda3
  107. sleep 11s
  108. echo "In the partition (3/5), waiting for the disk response will take more than 15 seconds."
  109. vgextend centos /dev/sda3
  110. sleep 11s
  111. echo "In the partition (4/5), waiting for the disk response will take more than 15 seconds."
  112. lvextend -l +100%FREE /dev/mapper/centos-root
  113. sleep 11s
  114. echo "In the partition (5/5), waiting for the disk response will take more than 10 seconds."
  115. resize2fs -p /dev/mapper/centos-root
  116. sleep 6s
  117. fi
  118. echo "Automatic partition completion, Please restart."
  119. sleep 3s