Resizing SD card (Ubuntu 14.02 LTS)

Discuss Ubuntu related items.

Resizing SD card (Ubuntu 14.02 LTS)

Postby kruszi » Wed Jun 22, 2016 8:13 pm

Hey there,

I'm currently on my way to resize the "system" SD card (16GB) with Ubuntu 14.02 LTS. As you can see from the screenshot there is plenty of space unallocated. Now I'd like to have that space available for applications, etc.

temp.JPG (98.65 KiB) Viewed 903 times

I installed GParted but now I don't know which partition to resize. Apparently there is only one available for editing (mmcblk2p1, FAT16)

The other partition (mmcblk2p2, ext4) can't be resized either, because it is mounted.

So how to solve this problem. I just want to use the full size of the SD card for applications (apt-get install ...)

Sorry for the "beginner question".

Posts: 12
Joined: Wed May 11, 2016 2:33 pm

Re: Resizing SD card (Ubuntu 14.02 LTS)

Postby Tapani » Thu Jun 23, 2016 2:13 am


I see your problem.

First: the reason our SD card images do not use the whole space, is that we cannot know how large SD cards people have. We try to have all our OS images usable with a 4GB SD card.

Second: how to resize that partition ... the easiest way I can think of is to use a Linux PC.
Copy the files somewhere, create a new partition to your liking, and copy the files back.

Example process:

1. Mount the second partition of your SD card on a PC, and copy the contents to somewhere (say /tmp/rootfs):
Code: Select all
# mount /dev/sdX2 /media/sdcard
# cp -a /media/sdcard /tmp/rootfs
# umount /media/sdcard

2. Delete the second partition on the SD card
3. Create a new partition, taking up the full space
4. Format the new partition (the extra options are to make the ext4 partition more adapted to the large erase block sizes on SD cards)
Code: Select all
# mkfs.ext4 -E stripe-width=64,stride=64 -O sparse_super -m0 -J size=4 /dev/sdX2
# tune2fs -O ^huge_file /dev/sdX2
# tune2fs -c -1 /dev/sdX2

5. Mount the (now empty) seconds partition, and copy all the files back there
Code: Select all
# mount /dev/sdX2 /media/sdcard
# cp -a /tmp/rootfs/* /media/sdcard/
# umount /dev/sdX2

6. Done!
Site Admin
Posts: 682
Joined: Tue Aug 27, 2013 8:32 am

Return to Software - Ubuntu

Who is online

Users browsing this forum: No registered users and 2 guests