Jump to content











Photo
- - - - -

Formatting/Partitioning a SD/SDHC card ...

format sd sdhc card

  • Please log in to reply
8 replies to this topic

#1 gbrao

gbrao

    Frequent Member

  • Advanced user
  • 354 posts
  •  
    India

Posted 16 August 2015 - 04:47 PM

Hope this is the right section.

 

I just bought a microSD card, my first, and was about to partition/format it like I do to hard disks. Luckily I did not.

 

Formatting/Partitioning a SD/SDHC card seems to be much more complicated than for HDDs. Searching the net I came across :

- use any modern partition manager, most recommended Minitool Partition Wizard.

- use Windows format but stick to FAT32/exFAT.

- use the SD Formatter provided by the SD Association.

finally I came across this :

- http://wiki.laptop.o..._Storage_Device

 

... Putting it Together

How is the filesystem layout relevant to our problem? Allocation data accesses are very common, as are cluster-sized data writes. So we want those operations to be efficient. If the allocation data starts on a NAND FLASH page boundary, a given allocation map write is less likely to span two pages, so the FTL gets to do things the "easy" way, which is faster and causes less NAND wear. If the cluster size is a power-of-two multiple of the NAND FLASH page size and the first cluster is aligned on an erase block boundary, cluster writes are similarly "easy".

Conversely, if the layout is bad, every cluster write might "split" two pages, forcing the FTL to perform four internal I/O operations instead of one.

 

Factory formatting

The manufacturers of FLASH storage devices understand this. When they format the device at the factory, they know which filesystem they are putting on (typically either FAT16 or FAT32), the page and erase sizes for the NAND FLASH chips inside, and the characteristics of the FTL software in the internal microcontroller. (Actually, there is yet another factor - multiple NAND chips or multi-plane chips can further influence the locations of "efficient" boundaries.) Knowing this, they can choose a layout that encourages "easy case" internal operations.

 

How to win

It boils down to the fact that you need to micro-manage a lot of details to ensure that things fall on suitably-aligned boundaries. You need to consider both the partition map and the filesystem layout in concert. One way to separate the problems is to make each partition begin on an erase block boundary, then layout the filesystems so their subordinate data structures (particularly the cluster or "fs block" array) fall on erase block boundaries assuming that the partition itself begins erase-block-aligned. What is a good alignment boundary? Well, 256 KiB is good for most new chips, but to give some breathing room for the future, maybe 1 MiB would be better - or perhaps even 4 MiB.

 

Better yet, try to avoid reformatting FLASH-based devices when you have the choice.

 

So can some one please tell me if the above is right.

 

And, if what I propose to do makes sense :

 

I will first use the card in a Windows PC, before actually using it, I propose to make a Ghost image of the entire SD card. If I ever need to format the card, I will restore this image to the card.

 

EDIT : Just came across : http://rmprepusb.blo...d-or-flash.html



#2 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13649 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 16 August 2015 - 05:14 PM

Well, you first need to decide if you want it partitioned or not.

If you want it partitioned, then you should partition it aligned to page size (normally 4096 bytes) and if you are using NTFS (why on a SD card?) everything will be as cool and dandy as possible.

If you want it non partitioned or however using FAT32 it would be a good idea to align the filesystem to the same 4Kb, see:
http://reboot.pro/to...-under-windows/
http://reboot.pro/to...-memory-drives/

If you prefer alignment of partition does not make a difference whilst alignment of filesystem might, in NTFS, since the filesystem is inherently aligned to 4096 bytes, the partition alignment is needed, on FAT you need to operate on the filesystem.

Of course an even number of Kb, multiple of 4, will do nicely, and all in all there is not that many choices, as usually everything (chip sizes or "pages" or "cache") goes along the "power of two": 8,16,32,64,128,256,512,1024 if you are OK with losing a whole Mbyte it will cover all the smaller sizes.

No data/experience for exFAT. :(

:duff:
Wonko

#3 gbrao

gbrao

    Frequent Member

  • Advanced user
  • 354 posts
  •  
    India

Posted 16 August 2015 - 05:27 PM

Sorry, I think I did not explain what I was trying to do/achieve.

 

First I thought like HDDs I have to partition and format the SD card before using it. I was wrong there. Since it's already partitioned & formatted.

 

Then I thought in the future, for what ever reason, if I ever needed to format the SD card what method/tool should I use ? That's what lead me to the above "solution".

 

The Ghost image method seems to be the best solution since it will basically "re-create" the SD card to exactly how it was when unused.

 

I got a Samsung EVO+ microSD btw.



#4 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13649 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 16 August 2015 - 05:48 PM

Since it's already partitioned & formatted.

No, 99.99% it isn't.

Unless it is a particular card (exact make/model would be nice to know), cards are usually shipped FAT32 formatted BUT NOT partitioned, as they are intended as "removable media" and thus "super-floppy" or "volume" with no MBR or partition table, the first sector is normally the volume bootsector.

 

:duff:

Wonko



#5 Zoso

Zoso

    Silver Member

  • Advanced user
  • 640 posts
  •  
    Isle of Man

Posted 17 August 2015 - 12:53 AM

hi gbrao

panasonic's "SDFormatter" is freely available for this but only for single partitions.

I have set up a multi-partitioned microSD in windows for booting windows and others from USB ports with an adapter. even partitioned with NTFS. it worked for a while but the first partition was reserved for digital camera use which also worked great until a video being recorded maxed out the space available and when that happened it killed the microSD alltogether. spent alot of time setting up everything on that too. found out the hard way about SDCard formatting I guess but I dont think it would have happened without the camera usage.

Ive multi partitioned them in linux to use ext3 & 4 for modded router usage and havnt had any issues with them. but Im really carfull not to exceed the space available since that camera incident. that deal rendered the SDcard totally inoperable!

#6 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13649 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 17 August 2015 - 09:13 AM

panasonic's "SDFormatter" is freely available for this but only for single partitions.

No. :(

It's not strictly "panasonic" as it is provided by the SD Card Association:

https://www.sdcard.o...ds/formatter_4/

 and it is not really for "single partitions" but rather for NON partitioned media.

 

:duff:

Wonko



#7 Zoso_The_Internet_Tard

Zoso_The_Internet_Tard

    Silver Member

  • Advanced user
  • 545 posts
  • Interests:An investigation is underway to determine whether Trump has any ties to America.

Posted 19 August 2015 - 05:36 PM

Do you intend to use this MicroSD in an (Android) phone? If so, just use Linux's Gparted. Android can work with SDs formatted with either MBR or GPT. My 128GB has 3 partitions, the first is EXT4 for data storage, 2nd is F2FS for use with Link2SD, and third is a swap partition for use with Roehsoft RAM Expander and my chroot Linux installs. Both TWRP and ClockworkMod custom recoveries can format/partition your SD to some extent. There is an app called Aparted that will let you partition/format on-device without a PC (MBR only). If you're technically inclined you can also use a terminal emulator app for this.

 

Both Android and Windows will only mount your SD's first partition by default, you can use a alternative method like an init.d script in /system/etc/init.d to mount the others (or do it manually via CLI). If your partition is for personal data/files then keep this in mind. If ext4 then Windows won't be able to read it, use MTP mode to bypass this. You can use USB mass storage mode but will need to install a driver like Ext2FSD. Linux should have no issues seeing and mounting all of your SD's partition. This is my understanding thusfar and some of this info may not be entirely correct.

 

Also, be warned that some of this may require root access. You should, however, be able to format your phone's SD with a single partition and Android can use it without root access. I personally recommend using EXT4, exFAT, or F2FS, but this will be partially dependent on whether your recovery/kernel/ROM supports these. For universal compatibility use FAT32, but without support for proper Linux permissions or filesizes over 4GB.



#8 gbrao

gbrao

    Frequent Member

  • Advanced user
  • 354 posts
  •  
    India

Posted 20 August 2015 - 01:52 AM

Thanks. Yes I will be using the MicroSD card in a smartphone.

 

1) I thought I would have to format it before using it.

2) I was trying to find out the best way to format it.

 

Ended up with what I mentioned in the OP. I'm going to keep it "factory formated" .



#9 gbrao

gbrao

    Frequent Member

  • Advanced user
  • 354 posts
  •  
    India

Posted 25 August 2015 - 11:33 AM

If anyone is interested, USBInfo from RMPREPUSB 2.1.727 for Samsung EVO+ 32GB microSD card factory formatted :

COMMAND LINE: DRIVE=1 USBINFO USBSTART=P1 SURE 

RMPARTUSB v2.1.720 (c)2014 RM Education plc [SSi]
=================================================

Accessing Drive 1 - "Generic- USB3.0 CRW   -SD" (32,010,928,128 bytes)

Sector at LBA 8192

...


FAT32
000B Bytes Per Sector = 512 (0200h)
000D Sectors Per Cluster = 64 (40h)
000E Reserved Sectors before first FAT = 1124 (0464h)
0010 Number of FATs = 2 (02h)
0011 Root Entries = 0 (0000h)
0013 Total Log Sectors (small) = 0 (0000h)
0015 Media Descriptor = 248 (F8h) HDD
0016 Sectors per FAT table = 0 (0000h)
0018 Sectors per Track = 63 (003Fh)
001A Number of Heads per Cylinder = 255 (00FFh)
001C Hidden Sectors preceding Partition = 8192 (00002000h)
0020 Total Log. Sectors (big) = 62513152 (03B9E000h)
0024 Log. Sectors per FAT = 7630 (00001DCEh)
0028 Mirroring Flags = 0 (0000h)
002A Version No. = 0 (0000h)
002C Cluster No. of Root Dir Start = 2 (00000002h)
0030 Log. Sector No. of FS Info Sector = 1 (0001h)
0032 First logical sector number of a copy of the three FAT32 boot sectors, typically 6 = 6 (0006h)
0040 Physical Drive Number = 128 (80h) First Fixed Disk
0042 Extended Boot Signature = 41 (29h)
0043 Volume ID Serial No. = 2417381112 (90164EF8h)
0047 Volume Label = NO NAME    
0052 FileSystem Type = FAT32   

First FAT begins at LBA 9316
Second FAT begins at LBA 16946
Root Directory begins at LBA 24576
First file data (cluster 0) begins at LBA 24640
Drive 1  Generic- USB3.0 CRW   -SD  F/W Rev.=1.00  Serial No.= [ bytes = 00 00 00 00 00 00 00 00 ]
Reported size 32,010,928,128 bytes (29.8125GiB)  Last LBA 62,521,343
RMPrepUSB Max 32,004,564,480 bytes (29.8065GiB)  Last LBA 62,508,914







1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users