pidora running out of space on SD card on raspberry

pidora running out of space on SD card on raspberry

I was having a lot of problem using the debian version of raspberrypi. The problem was lots of dependencies when I was trying to install some packages.
So, I respectfully ditched raspbian and moved to the fedora flavor – pidora

I flashed the OS on it without any problem but I had a problem again when I try to load packages – this time, I am running out space.

Problem

Trying to install git gave me this error

Error downloading packages:
  1:perl-Error-0.17021-1.fc20.noarch: Insufficient space in download directory /var/cache/yum/arm/20/pidora/packages
    * free   0 
    * needed 31 k
  perl-Git-1.9.3-1.fc20.noarch: Insufficient space in download directory /var/cache/yum/arm/20/pidora-updates/packages
    * free   0 
    * needed 53 k
  perl-TermReadKey-2.30-20.fc20.armv6hl: Insufficient space in download directory /var/cache/yum/arm/20/pidora/packages
    * free   0 
    * needed 28 k
  git-1.9.3-1.fc20.armv6hl: Insufficient space in download directory /var/cache/yum/arm/20/pidora-updates/packages
    * free   0 
    * needed 4.2 M

Diagnosis

I was trying to communicate with the raspberrypi headless. And I noticed that the there are only two partitions being used allocated a little more than 2GB from all my 16GB secure disk.

df -h

Gave me the output of

Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.9G  1.8G     0 100% /
devtmpfs        218M     0  218M   0% /dev
tmpfs           218M     0  218M   0% /dev/shm
tmpfs           218M  280K  218M   1% /run
tmpfs           218M     0  218M   0% /sys/fs/cgroup
tmpfs           218M  4.0K  218M   1% /tmp
/dev/mmcblk0p1   50M   23M   28M  45% /boot

As you can see the root is allocated only 2G and it is used of course.

Then I tried to see the partitions

fdisk -l

And that listed

Disk /dev/mmcblk0: 14.5 GiB, 15548284928 bytes, 30367744 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
Disklabel type: dos
Disk identifier: **********

Device         Boot     Start       End  Blocks  Id System
/dev/mmcblk0p1 *         2048    104447   51200   c W95 FAT32 (LBA)
/dev/mmcblk0p2         104448   4233960 2064756+ 83 Linux

If you notice closely, the used partitions start with number 1. And on the top you will see there is another partition with the number 0. That is being unused.

Goal

To extend the partition size of the root using the unused space from /dev/mmcblk0

Process

This can be done in two different processes.
1. Take out the SD card put it in your other computer where you have partitioning software, like on ubuntu you can use gparted which is graphical and easy to use or on mac with disk utility
2. Use the old school fdisk and parted tools for partition
I am old school :)

fdisk /dev/mmcblk0

Hit p for printing the partition information:

Disk /dev/mmcblk0: 14.5 GiB, 15548284928 bytes, 30367744 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
Disklabel type: dos
Disk identifier: **********

Device         Boot     Start       End  Blocks  Id System
/dev/mmcblk0p1 *         2048    104447   51200   c W95 FAT32 (LBA)
/dev/mmcblk0p2         104448   4233960 2064756+ 83 Linux

This will be the information we would be matching against later after the partition is done
Then use the parted tool

parted /dev/mmcblk0

This will provide

GNU Parted 3.1
Using /dev/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit chs                                                         
(parted) print                                                            
Model: SD SA16G (sd/mmc)
Disk /dev/mmcblk0: 1890,77,42
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1890,255,63.  Each cylinder is 8225kB.
Partition Table: msdos
Disk Flags: 

Number  Start     End         Type     File system  Flags
 1      0,32,32   6,127,56    primary  fat16        boot, lba
 2      6,127,57  263,140,45  primary  ext4

Look the Disk /dev/mmcblk0: 1890,77,42 information. The ending point for the disk is at cylinder 1890 while partition two is at 263, the head is at 77 while that of partition 2 is at 140 and 42 vs 45 for the sector. Well, as you can see the limit is higher and we want to use the maximum that is using the Disk ending..

Now delete the partition

(parted) rm 2

Ignore the notice and press i

Now if you type ‘print’ you will see the listing without the partition 2

(parted) print                                                            
Model: SD SA16G (sd/mmc)
Disk /dev/mmcblk0: 1890,77,42
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1890,255,63.  Each cylinder is 8225kB.
Partition Table: msdos
Disk Flags: 

Number  Start    End       Type     File system  Flags
 1      0,32,32  6,127,56  primary  fat16        boot, lba

Now the fun part Making the partition with larger size

(parted) mkpart primary 6,27,57 1890,77,42

This will allocate the space starting from the first partition to the end of the disk

hit print again

Model: SD SA16G (sd/mmc)
Disk /dev/mmcblk0: 1890,77,42
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1890,255,63.  Each cylinder is 8225kB.
Partition Table: msdos
Disk Flags: 

Number  Start     End         Type     File system  Flags
 1      0,32,32   6,127,56    primary  fat16        boot, lba
 2      6,127,57  1890,77,42  primary  ext4

You can see the end information of partition 2 is we instructed it

Then reboot your raspberry

sudo reboot

Then ssh again

ssh root@[raspberrypi.ip.address.here]

Finally do the resizing for partition 2

resize2fs /dev/mmcblk0p2

Then check your bank

df -h

This has listed

Filesystem      Size  Used Avail Use% Mounted on
/dev/root        15G  1.8G   12G  14% /
devtmpfs        218M     0  218M   0% /dev
tmpfs           218M     0  218M   0% /dev/shm
tmpfs           218M  280K  218M   1% /run
tmpfs           218M     0  218M   0% /sys/fs/cgroup
tmpfs           218M  4.0K  218M   1% /tmp
/dev/mmcblk0p1   50M   23M   28M  45% /boot

As you can see the available size of /dev/root has bumped to 12G!

ENjOY the pi!

installing macports

Installing Imagick for php using pecl

2 Comments
  1. mark

    Lovely guide, very clear and helpful. I became slightly worried when you instructed to remove the fs partition that you might be trolling, but then it was clear enough that the partition would be restored before any serious commits. Thanks again!

    1. gullele

      Thanks Mark for stopping by. Glad it helps!

Leave a Reply to gullele Cancel reply

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

*
*