ramstrong
Posts: 36
Joined: Thu Aug 15, 2013 11:14 pm
Contact: Website

Gparted in command line? SD formatting

Tue Oct 08, 2013 10:54 pm

I'm having trouble using fdisk, cfdisk, and parted to format my SD card. I researched some topics in the forum, but most of the messages specifies Windows, Mac, or digital camera solution. Not at all what I'm looking for.

I'm totally baffled with fdisk interface with sectors, cylinder and what not. cfdisk has clear interface that I like, but for some reason, operations aren't carried out. I can delete the partition just fine, but although I can install new partition, (default Linux fs), I can't do anything about it. And for some reason, changes aren't written?

I tried using dd. I copied image file from virgin SD card (image file is 3MB). So I decided to copy the image file back to external SD card to "format" the card. That didn't work. How come?

Finally, I use gparted. Click-click easy! I formatted a new FAT32 partition no problem.

Then I dropped back into the command line and run parted. I'm utterly confused again.

So, does anybody have a good resource that explain the SD formatting process using command line? It's for my script, so unfortunately Win, Mac, or even gparted solution isn't acceptable. Will a textfile fed into sfdisk format the card properly?
Raspberry Pi Journal: http://simpletongeek.blogspot.com/p/raspberry-pi-journal-directory_4.html

confuseling
Posts: 144
Joined: Mon Aug 26, 2013 1:41 pm

Re: Gparted in command line? SD formatting

Wed Oct 09, 2013 12:40 am

With both fdisk and cfdisk in interactive mode you have to do a 'w' to write the changes after you've finished.

I doubt that applies to scripting them though...

Did you try the man pages? They can normally get you a fair way through something, and then you can be more specific with your query and hopefully get a less vague answer... :D
http://forums.debian.net

ramstrong
Posts: 36
Joined: Thu Aug 15, 2013 11:14 pm
Contact: Website

Re: Gparted in command line? SD formatting

Wed Oct 09, 2013 12:58 am

I did use the Write option on cfdisk. That's what I don't understand. The man pages are describing the issues in general terms. Which means I can't be specific. But the question boils down to "How do I format SD card in various sizes, in various file system?"

It's a common question, one that I thought would be avoidable using dd, but since that also fails, it is clear that I do not understand the issues. I have had success using gparted, so if somebody has a tutorial for explaining what the gparted process is going on behind the scene and translate that to console programs equivalent then hopefully I can understand the process better.

So, less reference, more tutorial.
I also mentioned sfdisk. That program can take scripts. Is feeding a textfile to sfdisk be enough to "format" SD cards? If so, what would be inside the text file?

All my attempts using fdisk so far involves deleting old partition before trying to put one on. I'm pretty sure that's not how NOOBS work. How does NOOBS work on partitioning and formatting the SD card, exactly?
Raspberry Pi Journal: http://simpletongeek.blogspot.com/p/raspberry-pi-journal-directory_4.html

ramstrong
Posts: 36
Joined: Thu Aug 15, 2013 11:14 pm
Contact: Website

Re: Gparted in command line? SD formatting

Thu Oct 10, 2013 1:28 am

In the end, I "formatted" the SD card using sfdisk fed with text data. Like this:

echo "# partition table of /dev/sda
unit: sectors

/dev/sda1 : start= 16384, size= 7684096, Id= b
/dev/sda2 : start= 0, size= 0, Id= 0
/dev/sda3 : start= 0, size= 0, Id= 0
/dev/sda4 : start= 0, size= 0, Id= 0
" | sudo fdisk /dev/sda

And that seems to do it, although when I tried it with NOOBS partitions, only the /boot would come up.
Raspberry Pi Journal: http://simpletongeek.blogspot.com/p/raspberry-pi-journal-directory_4.html

Return to “Beginners”