![]() ![]() |
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 |
|
|
|
Oct 30 2007, 06:48 AM
Post
#2
|
|
![]() Group: Admin Posts: 1,209 Joined: 20-January 06 From: York, Pennsylvania Member No.: 8,961 |
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 |
|
|
|
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 |
|
|
|
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 |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 20th June 2013 - 03:11 AM |