Manually Resize SD Card on Slackware using fdisk

Home / Manually Resize SD Card on Slackware using fdisk

This article is similar to this article, except it use fdisk to partitioning.

When write image to CD card for installation of Raspberry Pi, the usable size will only be the size of the image. That means the rest of the space will be waste. On some distribution such as Fedora Remix or Raspbian Wheezy, when final configuration begin the distro run some script to automatically resize and fill the SD card. However not all distro does that. Therefore we need to do manual resize.

In this article we will discuss about how to manually resize SD card on Slackware. Alhtough using Slackware, you can also use other Linux, but we won’t cover that. This article describes activities relating partitions. Incorrectly following instruction is likely to corrupt your system, so please be careful.

On this article I use:

  1. Slackware64 14.0
  2. SD card with Arch Linux ARM  (2GB of 8GB occupied)


Insert the SD card to our machine. Make sure it is now mounted. We will use partition tool to resize the partition.

Following on from the instructions above, keep the newly-written SD card in the card reader, but unmounted. We’ll use the fdisk tool to edit partition record on MBR and other tools to resize the partitions.

Show partition information to find our SD card. Look for a partition that matches the roughly the size of your distribution image. On Arch Linux it should be around 2GB. For example, it is detected as /dev/sdb5. Then unmount that partition. Those can be done by invoking:

umount /dev/sdb5

Note that in this example case, root partition of Arch Linux is on extended partition.


Now use fdisk with root privileges. You can do sudo if you are on sudoer group or use super user account.

Welcome to fdisk (util-linux 2.21.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help):

You are asked for command, let’s print what partition there by type ‘p’ character and enter it. Here is my result:

Disk /dev/sdb: 7952 MB, 7952400384 bytes
64 heads, 32 sectors/track, 7584 cylinders, total 15532032 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00057540

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      186367       92160    c  W95 FAT32 (LBA)
/dev/sdb2          186368     3667967     1740800    5  Extended
/dev/sdb5          188416     3667967     1739776   83  Linux

Command (m for help):

This shows how my SD card was formatted after writing the image.I have 7584 cylinders with total 155352032 sectores.

Notice that nothing use the area from the end of partition /dev/sdb5 (3667967) to the card’s maximum (15532032).

Partition 1 is the boot partition. Nothing to do here, let’s leave that alone. Partition 5 is the root partition which located on the extended partition. This is the partition we will fill in. Some OS versions will have a Partition for swap space, which needs to be moved to the end of the card.

Now grow the root partition. This involves removing the partition, re-creating it, then using resize2fs to grow the filesystem to fill the partition. It won’t destroy any data.

We know that partition 5 (/dev/sdb5) is logical partition and located on Extended partition area. It means we have to remove both partition before creating new one.

First press d to delete the partition 5.

Command (m for help): d
Partition number (1-5): 5
Partition 5 is deleted

Next, press d again to delete the partition 2

Command (m for help): d
Partition number (1-5): 2
Partition 2 is deleted

Next we create them. But now we do it in reverse order.

First create partition 2. This will be extended partition. Because our partition is the last partition, we can omit the value and use all the remain area. In my case, I will start from sector 186368 and end it to the 15532031.

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): e
Partition number (1-4, default 2): 
Using default value 2
First sector (186368-15532031, default 186368): 
Using default value 186368
Last sector, +sectors or +size{K,M,G} (186368-15532031, default 15532031): 
Using default value 15532031
Partition 2 of type Extended and of size 7.3 GiB is set

Now we have extended partition.

Next, create the partition 5. This partition should be built on top of partition 2.

Command (m for help): n
Partition type:
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (188416-15532031, default 188416): 
Using default value 188416
Last sector, +sectors or +size{K,M,G} (188416-15532031, default 15532031): 
Using default value 15532031
Partition 5 of type Linux and of size 7.3 GiB is set

Now write the changes back to the disk by entering ‘w’.

Next clean and resize the root partition. We will do a filesystem check:

e2fsck -f /dev/sdb5

That command will allow it to add lost-and-found.

resize2fs /dev/sdb5

And that’s it, we can enjoy Raspberry again 😀

About Author

about author


A man who is obsessed to low level technology.

Leave a Reply

Your email address will not be published. Required fields are marked *

Social Share Buttons and Icons powered by Ultimatelysocial