element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Single-Board Computers
  • Products
  • Dev Tools
  • Single-Board Computers
  • More
  • Cancel
Single-Board Computers
Blog Resize an SD Card
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Single-Board Computers to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: oneleggedredcow
  • Date Created: 30 Dec 2014 12:25 AM Date Created
  • Views 2028 views
  • Likes 3 likes
  • Comments 12 comments
Related
Recommended

Resize an SD Card

oneleggedredcow
oneleggedredcow
30 Dec 2014

Most of the single board computer images out there are set up for a 4GB SD card, but what if you have a 16 GB card?  When you fire up the image and check the disk size with:

 

df -h .

image

Sometimes it reports that the size of the drive is just 4GB, even though we know that the real size of the drive is 16GB.  Here’s how to change the partition sizes to use the entire space on the SD card.

 

Change Partition Size

I’m going to do this example on an OlinuXino, but the same procedure will work for a Raspberry Pi, SABRE Lite, or other single board computer.

 

To change the partition sizes, fire up the fdisk program:

 

sudo fdisk /dev/mmcblk0

 

Fdisk is a command line utility that allows you to change disk partition sizes.

 

Once inside the fdisk program, it will ask you for what command you want to do.  The first thing that we want to do is print the partition sizes, which is the “p” command:

image

Ok, now we want to delete the partition that currently exists.  Don’t worry, we are going to recreate partition in a second, but this time it is going to take up all of the available space.  If you have multiple partitions, delete the larger one.  Delete the partition with the “d” command:

image

Now, we go about creating a new (larger) partition.  This is done with the “n” command:

image

We want to create a new partition “n” that’s going to be a primary partition “p”, with the same partition number as whatever you deleted in the previous step.  This partition will have the default start position, so just press enter for that question.  We also want the default stop position, which will be to use up all of the disk space.

 

After the new partition is defined, we need to write that to disk with the “w” command.  This will also exit us out of the fdisk program.

image

Now that we have the new allocations defined, in order for them to take effect, we need to restart the board:

 

sudo shutdown –r now

 

When the reboot has completed, we need to do one more command to finish the resizing:

 

sudo resize2fs /dev/mmcblk0p<#>

 

Where <#> is the number of the partition that you deleted and recreated.  Once that completes, then we can check the disk size with:

 

df -h .

image

And see that our OS has expanded to fill the entire microSD card.  Great success!

  • Sign in to reply

Top Comments

  • mcb1
    mcb1 over 10 years ago in reply to gadget.iom +1
    You can achieve the same result using raspi-config. I think you'll find NOOBs already expands the SD card. Mark
  • Problemchild
    Problemchild over 10 years ago +1
    Shaun when you expand the filesystem like this you will be able to extend the last partition on the card as you wont be able to expand the earlier ones past the preexisting partitions, if your large data…
  • Problemchild
    Problemchild over 10 years ago in reply to mcb1 +1
    You win Mark ...... but he is been generic for any old FS on any old board rather than just RPI This seems to be some Olimex board in this case. As I said before I'd use "parted" mainly so you have less…
  • D_Hersey
    D_Hersey over 10 years ago in reply to mcb1

    That's how these things always start, as liberation movements!

     

    Now, if someone would just teach Das Uboot how to work off of USB.

     

    I think it just loosens the shackles somewhat.  Only large corporations make uPs, it seems.  But I get your point.  We all have to foot the development costs to a degree if we want to be early adopters.  Small companies aren't always better to deal with.  They can have weak customer service or go belly up on you.

     

    I kinda care, I don't like complexity unless it has a justifying purpose.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 10 years ago in reply to D_Hersey

    Don

    I agree that consistency is not always there, and some things for the RPi were done to make it easier for newbies.

    Not sure what that teaches them, but thats the way it is.

     

    Unfortunately Open Source means no-one sets a standard for everyone to follow, so that is one downside.

    It does release you from the shackles of large corporations, but introduces 'differences' in the OS images and/or SBC hardware.

     

    I don't mind what process they use, so long as it is well documented.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 10 years ago in reply to Problemchild

    Problemchild

    John

    NOOBs installs Raspbian onto the SD card, which does the expanding as part of the process.

    It installs the normal raspbian menus, utilities and of course raspi-config is available.

    Unfortunately even if you copy it all to a new card that has more room you still can't expand it, so there must be a flag set somewhere.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Problemchild
    Problemchild over 10 years ago in reply to mcb1

    Yeah this is obviously not even consistent between various releases of say Noobs vs Rasbian. I'm certain older versions used to have the menu selection any way I've just installed the 24/12 Rasbian and it does ask you thus my assumption that NOOBS  did as well. Any way it seems to be wrong to assume that he's using NOOBs /Rasbian or anything in this context since it's an Olimex part he's working withimage

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • D_Hersey
    D_Hersey over 10 years ago

    This (complexity of partition schemes required for SBCs) is becoming more of an issue.  The Pandaboard requires a wintel-compatible boot partition for uboot first than a linux-compatible partition for rootfs.  I just got a board going that requires five partitions to get running, one hidden!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube