-
Automating Partition
Hi,
I am trying hard to create bash script to automate partitioning so i can use it on several systems. below is the script that not running quite well. I am getting errors like:
Code:
Error: you requested a partition from 0.00B to 1075 MB
The closest location we can mange is 17.4 KB to 1075 MB
and when i change 0B to 17.4kB i get more errors like:
Code:
you requested a partition from 1074MB to 5369MB
the closest location we can manage is 1127MB to 5369MB
This is the script:
Code:
# parted -s -- /dev/sdb mklabel gpt mkpart boot ext2 0B 1025MiB mkpart swap linux-swap 1GiB 5GiB mkpart dos fat16 5GiB 6GiB mkpart root ext2 6GiB -1 set 1 boot on
What i am trying to do is to create 8 partitions and with sdb8 be the fat partition, sdb1 is /boot, sdb2 is / , sdb3 is swap, sdb4 extended and sdb5-sdb7 linux partition.
Appreciate your help.
-
Been a while since I last used a script to partition a GPT disk. Enclosed is what I found from my scraps of previous information. I did 128 partitions and it worked but the partitions were the same size.
Code:
echo "mkpart sdb1 1cyl 200cyl" > gpt128; for ((i=2;i<=10;i++)); do k1=$[(i-2)*10000+200] k2=$[k1+10000];echo "mkpart sdb$i $[k1]cyl $[k2]cyl"; done >> gpt128; for ((i=11;i<=128;i++)); do k1=$[(i-11)*2327+90200] k2=$[k1+2327];echo "mkpart sdb$i $[k1]cyl $[k2]cyl";done >> gpt128; echo "q" >> gpt128
The above script produces a text file called gpt128 and that is the format you need.
I prefer cylinder as the unit for partitioning because many Linux partitioning software still use cylinder as a partition boundary. Using Mb can leave small unusable spaces which some operating systems may react to them rather unfriendly (thinking they are signs of disk corruptions as no one know how to deal with them and one of the ways to safeguard the OS is to treat a dead space potentially another partition.)