Command line for creating partitions

Chris Murphy lists at colorremedies.com
Thu Aug 7 20:14:01 UTC 2014


On Aug 7, 2014, at 12:45 PM, Robert Moskowitz <rgm at htt-consult.com> wrote:

> I am working now more on handcrafting my SD cards for arm testing. Gparted did not do a good job, allowing me to make parititions not on 'cylinder boundaries'.

FWIW cylinder boundaries are legacy and irrelevant, for either SSDs (including SD cards) or HDDs. You have to go back two epochs to get to CHS being relevant. Everything is LBA these days. The boundary you want is simply 2048 for 512 byte (logical) sectors, which is a 1MB boundary. That's the easiest and works well for everything, you don't have to think about it any further. Any recent parted, fdisk, and gdisk do this.


>  And the labels it created were not recognized when I mounted the drive.  I had to use the disk utility to fix the labels.

Not recognized? That's vague. What does happen? The volume label appears garbled, or is blank? What is "disk utility"? There's "Disks" a.k.a. gnome-disks.

Is the SD card being GPT partitioned or MBR partitioned? GPT partitions support partition names, MBR partitioning doesn't. So maybe there's a weird conflict somewhere between volume labels (a filesystem name), and partition names (a GPT only thing).


>  Anyway, to script it and to put this up on some wikis, I really need to do this by command line.
> 
> So I have looked at both fdisk and parted.  Neither are for 'simple' command lines.  Fdisk takes me back to my DOS days (wonder where MS got it from?).
> 
> So first I want a command that will delete all partitions on /dev/sdb

fdisk and gdisk have only interactive modes. parted has both command line and interactive modes, it sounds like you're only familiar with the interactive mode. But I'm not sure if it accepts MB units in command line mode; it does in interactive mode. Possibly cfdisk or cgdisk will offer what you want.


> Of course, I understand how many MB I want each, but I am suppose to (or so from the warnings that 'fdisk -l' provided) maintain boundaries.

If you specify all partition start and end values in MB, or in sectors that are 2048 divisible, it's fine. You can even get away with much less, the only time alignment really matters is 4096 sector HDD's, so that's an 8 sector or 4KB alignment. It's just that 1MB or 1GB units is ultimately all we care about for partition sizes, and they happen to align.



Chris Murphy



More information about the users mailing list