I'd like to make a custom BASH script that calls parted or fdisk or whatever, to automatically partition a hard disk accroding to this criteria:
100MB for boot,
256MB for swap,
the rest for root.
If I use "parted" in the script (with -s) and pass the mkpart command with "start" and "end" as numerical values such as:
Code: Select all
DEV=/dev/sda
parted -s $DEV unit MB mkpart primary 0 100
How can I avoid this? How can I properly align the partitions?"The resulting partition is not properly aligned for best performance."
I searched the web and came across a post that suggested using percentage instead.
In fact, if I run:
Code: Select all
parted -s $DEV unit MB mkpart primary 0% 1%
However, I'd prefer to use fixed values to define boot and swap because 1% of a big disk is too much for a boot partition in my case.
Any ideas?
I'm also using plain BASH from a Gentoo livecd so I don't know if I can handle floats.
I get the total disk size this way:
Code: Select all
DEV=/dev/sda
DSIZE=$( parted -s $DEV unit B print | grep "^Disk $DEV:" | cut -f 3 -d " " | tr -d B )
If I compute 104857600 / 250056015872 within BASH then I get 0 (as expected). So I don't know how to get decimal percentages in order for parted not to complain about partition alignment and get my boot and swap partition sizes right.
Any suggestions?
Thanks in advance,
Vieri


