OESF | ELSI | pdaXrom | OpenZaurus | Zaurus Themes | Community Links | Ibiblio

IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Sfdisk Partitioning Question
daniel3000
post Oct 30 2007, 05:13 AM
Post #1





Group: Members
Posts: 1,002
Joined: 28-April 05
From: Germany
Member No.: 7,027



Hello,

I need to partition SD cards from a shell script using sfdisk, but don't know how to to that in a safe way.

No matter what the size of the SD card is, I would like to create a 128MB SWAP partition at the END of the card (i.e. as the second partition /dev/mmcda2) and the remaining space at the beginning (/dev/mmcda1) needs to be linux ext2.

I have used something like

CODE
sfdisk /dev/mmcda -uM << EOF
,128,S,
,,L,*
;
EOF


in order to achieve the opposite, i.e. 128MB swap as partition 1 and Linux ext2 as parition 2.

Any idea how to use sfdisk to achieve what I really need?
Thanks a lot!
Daniel

Go to the top of the page
 
+Quote Post
InSearchOf
post Oct 30 2007, 06:48 AM
Post #2





Group: Admin
Posts: 1,210
Joined: 20-January 06
From: York, Pennsylvania
Member No.: 8,961



QUOTE(daniel3000 @ Oct 30 2007, 09:13 AM) *
Hello,

I need to partition SD cards from a shell script using sfdisk, but don't know how to to that in a safe way.

No matter what the size of the SD card is, I would like to create a 128MB SWAP partition at the END of the card (i.e. as the second partition /dev/mmcda2) and the remaining space at the beginning (/dev/mmcda1) needs to be linux ext2.

I have used something like

CODE
sfdisk /dev/mmcda -uM << EOF
,128,S,
,,L,*
;
EOF


in order to achieve the opposite, i.e. 128MB swap as partition 1 and Linux ext2 as parition 2.

Any idea how to use sfdisk to achieve what I really need?
Thanks a lot!
Daniel


Just wondering why you want it at the END of the card?

Late
Go to the top of the page
 
+Quote Post
daniel3000
post Oct 31 2007, 01:33 AM
Post #3





Group: Members
Posts: 1,002
Joined: 28-April 05
From: Germany
Member No.: 7,027



Because most systems only mount the first partition of the SD card, so the data partition should be the first one in favor of maximum compatibility.

daniel
Go to the top of the page
 
+Quote Post
daniel3000
post Nov 2 2007, 01:37 AM
Post #4





Group: Members
Posts: 1,002
Joined: 28-April 05
From: Germany
Member No.: 7,027



Okay guys, I have solved the problem myself.
I use fdisk -l output first to read the total size of the card,
then I calculate the data partition size by substracting the wanted swap partitoin size (here 200MB),
then I create the data partition and swap partition using sfdisk and the calculated data partition size.

CODE
#!/bin/bash

SDSIZE=`fdisk -l /dev/mmcda | grep "Disk /dev/mmcda" | cut -f 3 -d " "`
SWAPSIZE=200
DATASIZE=$[$SDSIZE-$SWAPSIZE]


echo SD card size:            $SSIZE MB
echo Size for data partition: $DATASIZE MB
echo Size for swap partition: $SWAPSIZE MB

sfdisk /dev/mmcda -uM << EOF
,$DATASIZE,L,*
,,S,
;
EOF


Seems to work very well.

daniel
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 18th December 2014 - 01:02 PM