Skip to content

How to downsize a 4GB compact flash card to 2gb

August 9, 2010

I recently had to put a new CF card in an older infrared camera for one of our field sites. Unfortunately the camera only supports up to 2GB sized CompactFlash cards but local retailers only carry 4GB cards these days and I didn’t have time to order one online. After a few hours of online research and trial and error, I finally figured out how to do it using the windows “diskpart” utility.  This hack will only work in in Vista and Win7 because diskpart in XP won’t recognize the card.

[Note that in the example below, things in italics are commands you type.]

Before starting, please remember that you can seriously mess things up if you make a mistake using command line disk management. Please make 150% sure you are selecting the correct disk so you don’t format your hard drive. You are solely responsible for anything that happens as a result of using this code  🙂

Instructions for reducing the partition size of a compact flash (CF) card:

  1. Open a command Window (Windows-> Start -> cmd)
  2. Type diskpart
    A new window will open up with a “diskpart>” prompt
  3. list disk
  4. select disk n (where n is the number of your CF card)
  5. list volume
  6. select volume n (where n is the number of CF card volume)
  7. clean all (this completely reformats the disk – it will take a while and appear to hang but be patient)
  8. create partition primary (this gives the newly formated CF card a partition so it can be resized)
  9. shrink querymax
    This will tell you how much space is currently on available on your CF card. Subtract this from the filesize in MB you want for the final disk than add 1.
    For my 4GB disk, shrink querymax returns:
    “The maximum number of reclaimable bytes is: 3824MB”
    I wanted a final disk size of 2GB which a google search told me is 1954MB so 3824 – 1954 + 1= 1871
  10. shrink desired = 1871 (This tells diskpart to try and shrink the disk by 1871 MB)
  11. Now that the disk is the right size, you can format the partition…
    format fs=fat label=”volumelabel”

That’s all it takes.

More info on diskpart commands here:
http://technet.microsoft.com/en-us/library/cc766465(WS.10).aspx


30 Comments leave one →
  1. demoez permalink
    December 4, 2010 5:58 pm

    This is exactly what I was looking for. I got a free 4gb card with 1 year picasa hosting… but my old digital could only support standard SD. Thanks for helping me make use of something useless to me. Wish there was a way to make two fat partitions on there and swap them when one side was full and not offloaded for redundancy.

  2. Jim Ratcliff permalink
    April 4, 2012 8:29 pm

    After I type diskpart, the second window opens with a prompt, but I can’t type anything. Any idea why? I’ve been searching for forever for a way to shrink a Compact Flash card.
    Any help would be GREATLY appreciated.
    Am running Windows 7, 64 bit.

    Thanks,

    JR

    • timescience permalink*
      April 5, 2012 8:28 am

      I haven’t tried it in so long I can’t say. If you have the option to try on an XP computer I’d recommend trying it on that. There’s still a bunch of stuff that just doesn’t work right when you try it on win7x64. I’d say 90% of the time when I try the same thing on an old XP box it works fine. Strangely, my wife still doesn’t accept that as an excuse for why there are so many old computers in our basement 😉

      • April 6, 2012 10:18 am

        There was a problem with my keyboard. A new one cured that problem, thanks. I am using a dual boot with Win 7 and XP.
        Here’s the problem I am having…. I am trying to copy a file from one CF to another, or from hard drive to CF card. The problem is, the files have to transfer to the EXACT file size. The file size can’t be off by even a single byte or the file won’t work! I even partitioned a CF card to the exact file size, but when I wrote the file to that CF card, the size exceeded the partition size!
        HOW is that possible??? HELP………..

      • timescience permalink*
        April 6, 2012 11:33 am

        I can’t suggest a quick fix, but note that if you check out the file/disk size properties, there’s always a discrepancy between “size” and “size on disk” so its not too surprising that you can’t render things to be exactly the same size on different media. I’d look into cloning the disk somehow, using something like Acronis or a similar disk imager (or there may be open source options available). I’ve tried cloning SD cards without much success so I can’t say it would work but it seems like it might suit your needs if you can find the way to do it. For hard drives, most disk imaging software lets you clone a partition and and then write that partition to a new storage media. In theory that might write your data to the SD card without having to worry about the existing partition. In practice I think it will be hard to do (I’ve spent a fair bit of time trying to clone an SD card w/o success) but if you find a solution, please post it and let us know since I imagine we’re not the only ones who’d like to know how to do this.

        Good luck!

  3. Jim Ratcliff permalink
    April 5, 2012 2:24 am

    OK, I got the prompt to work on my laptop. Is there anyway I can format a CF card by bytes? I need the card to be the same as the one I am copying down to the exact number of bytes in size as the one I am copying for it to work properly.

    Also, once formatted, can it be formatted again if I were to format it too small?

    Thanks again,

    JR

    • rakesh permalink
      June 22, 2012 12:11 am

      Ya, even I am looking for this solution.By mistake I formatted it too small. can it be formatted back to a bigger size?

      • timescience permalink*
        June 22, 2012 1:00 pm

        I bet you can go into diskpart and delete all the partitions and start over but I can’t say for sure since I haven’t tried it.

  4. rakesh permalink
    June 16, 2012 10:39 am

    I have been searching for this solution for long. thanks

  5. rakesh permalink
    June 16, 2012 11:11 am

    By mistake I shrunk volume to 214 mb instead of 2 gb…can i undo it?
    how?

  6. Mark permalink
    August 9, 2012 7:04 pm

    Thank you for the helpful and informative post!

  7. September 27, 2012 8:09 pm

    hi i can this problem.
    1.command line
    2.diskpart
    3.list disk n
    4.clean all
    5.join my computer
    6.open Flash
    7.asking format
    8.yes

    “ok”
    thanks

  8. uriel permalink
    November 18, 2012 4:52 pm

    how to revert this?

    • Kees permalink
      November 22, 2013 5:27 am

      just follow the instructions above, the ‘clean all’ command reverts, takes out the partitions.

      thanks a lot ts!

  9. July 6, 2013 2:23 am

    Thank-you very much! I didn’t know the “shrink” diskpart’s option, so I formatted my CF for my camera and I learned something new. 😉

  10. August 26, 2013 1:50 pm

    After googling for hours and attempting bad info after bad info, your instructions were simple to follow and the only ones that worked! For an 8g card step #7 took in excess of two hours. Be patient!

  11. Respect permalink
    September 25, 2013 4:57 pm

    Thanks very much, I’m glad to found this site.

  12. Gopikrishnan.A permalink
    November 29, 2013 1:21 pm

    Can i use this method for bios flashing as i have an 8gb that doesnot gets formatted as FAT.??
    Thanks in advance.

  13. January 20, 2014 2:07 pm

    Reverting the formating is by restart from step 7 above in the first tip. I.e. “clean all” and then make a new partition (again).
    NOTE!!!: if you remove and insert the CF card (or another) without exiting DISKPART please redo the “list disk”, “select disk”, “list volume”, and “select volume” commands. Also if you have an external card reader (like me) plug it out and back in between each finished reformatted card, I got formating errors if I didn’t “reset” the disk list by unplugging. Another way of resetting would maybe to exit the DISKPART program and entering it again.
    And also note that my “volume 5” CF card slot suddenly was “volume 4”.
    SO BE CAREFUL WITH WHAT YOU ARE DOING! SELECT THE RIGHT DISK AND RIGHT VOLUME!!!!.
    You can use the up and down keys to repeat previous commands in diskpart.
    Good tip anyway. I can now wipe some old Linux partitioned CF cards! Thnx!

  14. Xilinx permalink
    February 17, 2014 12:42 am

    In the first Step where I do “List Disk” I only get my C-Drive ,

    DISKPART> list disk

    Disk ### Status Size Free Dyn Gpt
    ——– ———- ——- ——- — —
    Disk 0 Online 699 GB 0 B

    then when I do List Volumes, I see my CF-Card…

    DISKPART> list volume

    Volume ### Ltr Label Fs Type Size Status Info
    ———- — ———– —– ———- ——- ——— ——–
    Volume 0 D DVD-ROM 0 B
    Volume 1 C NTFS Partition 699 GB Healthy System
    Volume 2 I FAT32 Removeable 3778 MB

    This looks like very risky to delete…

    Any idea why my Windows XP does not show the removeable disk in ‘list disk’ command?

    • timescience permalink*
      February 17, 2014 4:34 pm

      Yes, Diskpart will let you destroy your whole computer so you don’t want to delete the wrong thing! You always undertake a degree of risk when you are mucking around in with low level software that can reformat your hard drive so be forewarned. It looks like the Vol2 is your SD card but this might be a good time to do a full backup of your computer anyway since you always want to have a full backup anyway and then you can proceed with more confidence.

  15. theamazeman permalink
    June 23, 2014 10:26 pm

    How to reverse?

  16. Ron permalink
    July 1, 2014 8:35 am

    I followed the commands and so far so good. It says it’s done what i wanted. now to try to do what i wanted in the first place. Your looking Good “Houston” Cheers

  17. Ron permalink
    July 2, 2014 2:43 am

    Thanks again for your efforts, i could not achieve what i wanted. To format a 4GB SDHC card to look like a 2GB so i can continue to use my Tom Tom One, since i cant get a 2GB card for much less than 1/4 the price of a new Tom Tom. However it was fun and i learnt a few more DOS commands. God knows if i will ever use them again but it’ll do for party tricks eh!.
    NOW then when it came to reversing the process, 2 back to a usable 4GB, i hit all kinds of snags. I just could not get it back to a usable square one. I did however find this little gem which did it for me!!!!SD Formatter 4.0 for SD/SDHC/SDXC available from “www sdcard.org” This little tool may have the ability to do all kinds of things i have not yet had a chance to explore. good luck m8s

  18. October 6, 2014 8:58 am

    The maximum number of reclaimable bytes was about 50MB higher than what yours was but I still subtracted 1954 and added one. I then formatted the disk like you said but it still won’t work in my digital photo frame. Might be the frame, but do you have any other suggestions?

    • timescience permalink*
      October 6, 2014 7:29 pm

      Sorry, I don’t. Trial and error is you best bet.

      • October 6, 2014 10:55 pm

        what would I have to subtract from my now number of reclaimable bytes to change to a 1gb SD card

Trackbacks

  1. Is it possible to format a 4GB SD card to 2GB so an old device that can't deal with devices larger than 2GB can work with it? - Quora
  2. Mini max geniuses please help ASAP - Dodge Cummins Diesel Forum

Leave a comment