Automating Partition


Results 1 to 2 of 2

Thread: Automating Partition

  1. #1
    Join Date
    Jan 2013
    Posts
    1

    Question 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.

  2. #2
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,948
    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.)
    Last edited by saikee; 01-05-2013 at 08:06 PM.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •