sfdisk for automated partitioning?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sfdisk for automated partitioning?
# 1  
Old 08-22-2008
sfdisk for automated partitioning?

Hi guys,

I want to write a script to automate partitioning for some project that I'm working on. I tried using fdisk but it was too painful... so, turned to sfdisk but now I'm getting strange results...or at least I think so.

What I want to do is, to get the disk size to be created from another script and create a partition of that size on the specific disk (also sent by the same script).

i.e. I want to create a partition with size of 5GB on /dev/hda.
First of all, do I need to convert GB to cylinders or blocks or sfdisk supports "GB" or "MB"?

Here's from my command prompt. Here's the strange thing that happens:

I have this:

Quote:
root# fdisk -l

Disk /dev/hda: 8589 MB, 8589934592 bytes
16 heads, 63 sectors/track, 16644 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System
/dev/hda1 1 1000 503968+ 83 Linux
/dev/hda2 1001 16644 7884576 5 Extended
/dev/hda5 1001 2939 977224+ 83 Linux
/dev/hda6 2940 4878 977224+ 83 Linux
/dev/hda7 4879 5848 488848+ 83 Linux
/dev/hda8 5849 7787 977224+ 83 Linux
/dev/hda9 8781 10719 977224+ 83 Linux
/dev/hda10 10720 16644 2986168+ 83 Linux
/dev/hda11 7788 8036 125464+ 83 Linux

Partition table entries are not in disk order

Disk /dev/hdd: 5604 MB, 5604638720 bytes
16 heads, 63 sectors/track, 10859 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System
/dev/hdd1 1 3876 1953472+ 83 Linux
/dev/hdd2 3877 7752 1953504 83 Linux
/dev/hdd4 7753 10859 1565928 5 Extended
/dev/hdd5 7753 10859 1565896+ 83 Linux
and I want to add a new partition to /dev/hda:

Quote:
root# sfdisk /dev/hda
Checking that no-one is using this disk right now ...
OK

Disk /dev/hda: 16644 cylinders, 16 heads, 63 sectors/track
Old situation:
Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/hda1 0+ 999 1000- 503968+ 83 Linux
/dev/hda2 1000 16643 15644 7884576 5 Extended
/dev/hda3 0 - 0 0 0 Empty
/dev/hda4 0 - 0 0 0 Empty
/dev/hda5 1000+ 2938 1939- 977224+ 83 Linux
/dev/hda6 2939+ 4877 1939- 977224+ 83 Linux
/dev/hda7 4878+ 5847 970- 488848+ 83 Linux
/dev/hda8 5848+ 7786 1939- 977224+ 83 Linux
/dev/hda9 8780+ 10718 1939- 977224+ 83 Linux
/dev/hda10 10719+ 16643 5925- 2986168+ 83 Linux
/dev/hda11 7787+ 8035 249- 125464+ 83 Linux
Input in the following format; absent fields get a default value.
<start> <size> <type [E,S,L,X,hex]> <bootable [-,*]> <c,h,s> <c,h,s>
Usually you only need to specify <start> and <size> (and perhaps <type>).

/dev/hda1 :,,
/dev/hda1 0+ 16643 16644- 8388575+ 83 Linux
/dev/hda2 :
What happens is, when I want to keep the same size and everything for the rest of the partitions (by entering ",,"), it allocates the entire space for hda1...

What am I doing wrong guys? Please help!

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Need help Partitioning

I am getting ready to install RHEL6 server. I have to create these partitions: / 10GB SWAP 3GB /opt/kent 10GB /opt/kent/logs /backup 20 GB Will Gparted do this? or whats the easiest way? or even a tutorial?I am so new to this (4 Replies)
Discussion started by: linux4noob
4 Replies

2. Shell Programming and Scripting

Partitioning in AIX

I am working in AIX ver 5 rel 3. It shows as follows. @:on(cluster302)/home/abcde00-> shiusr1c is LPAR (Logical PARtition). Then what is "shiissra" called? Thanks Krishna Please use code tags next time for your code and data. (1 Reply)
Discussion started by: kmanivan82
1 Replies

3. Ubuntu

About partitioning

Hi folks, Ubuntu 10.04-1 64-bit HD - 1T SATA3 I ran graphic installation installing Ubuntu-10.04-1 desktop from Live CD The partition on the new HD is as follow; /root /home /kvm (kvm is for keeping the guests of KVM, the virtualizer) Installion went through without problem abd... (0 Replies)
Discussion started by: satimis
0 Replies

4. Filesystems, Disks and Memory

Understanding sfdisk and df results

Hi, Using fdisk I created a partition of 15.7 GB. I entered +15700M Using sfdisk there is a heading called blocks and there is a number which is approximatly 400 BM less. When I mount the partition and use df -l the 1K block column displays only 15GB! I need to understand these numbers if... (2 Replies)
Discussion started by: mojoman
2 Replies

5. Filesystems, Disks and Memory

Udev label removes corresponding fdisk, sfdisk or lsvdev entry

I'm curious about the behavior where any udev labeled device causes that corresponding listing to disappear from fdisk, sfdisk, or in the case of RDAC, lsvdev. I have seen this on both EMC clariion and Sun Storagetek/Engenio 6540 arrays. We use RHEL5.1 and udev to create persistent labels for... (2 Replies)
Discussion started by: Radar
2 Replies

6. Solaris

disk partitioning

Total disk size is 38912 cylinders Cylinder size is 32130 (512 byte) blocks Cylinders Partition Status Type Start End Length % ========= ====== ============ ===== === ====== === ... (2 Replies)
Discussion started by: seyiisq
2 Replies

7. Red Hat

Partitioning?

Hey, this question is generated purely out of my lack of knowledge. Ok, obviously you can partition hard drives, I have Windows 2k, and can partition it from administrative tools, however, all of the help sections have utterly failed to give me any information other than "when you partition, it... (5 Replies)
Discussion started by: Mal_Zapatos
5 Replies

8. UNIX for Dummies Questions & Answers

Partitioning

Hiya folks, Before I install Linux, I want to partition my HD, basically I want to split my 80GB HD in half so I can run Linux but still keep Windows XP. I tried doing through the windows workstation and browsing the XP help files but it either didnt work or I was doing something wrong. I dont... (7 Replies)
Discussion started by: Mr_Pinky
7 Replies

9. UNIX for Dummies Questions & Answers

Partitioning HD

I would like to install Redhat 7.2 on my Windows machine. I only have one hard drive and I dont want to lose Windows. Which method is best for partitioning the HD? I tried it once with Partition Magic and I was installing Corel Linux First Edition and Corel wiped out my entire HD (not good when... (2 Replies)
Discussion started by: primal
2 Replies

10. UNIX for Dummies Questions & Answers

Partitioning

I'm looking for a Partitioning Tool preferably with a GUI preferably free that is easy to use if anyone has any suggestions they will be greatfully recieved, Thanks. (4 Replies)
Discussion started by: OSNovice
4 Replies
Login or Register to Ask a Question