I'm ridiculously new to rpi and I've been following lots of tutorials in order to try to get face recognition working on my pi. I've run out of disk space and it seems that through following tons of tutorials, I've loaded up on junk.

I saw in another discussion on partitions that I can run a command to see mine. Here is what it shows.

pi@raspberrypi ~ $ sudo fdisk -l

Disk /dev/mmcblk0: 7969 MB, 7969177600 bytes
4 heads, 16 sectors/track, 243200 cylinders, total 15564800 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: 0x000c27cb

    Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            8192     1685546      838677+   e  W95 FAT16 (LBA)
/dev/mmcblk0p2         1687552    15499263     6905856   85  Linux extended
/dev/mmcblk0p3        15499264    15564799       32768   83  Linux
/dev/mmcblk0p5         1695744     1818623       61440    c  W95 FAT32 (LBA)
/dev/mmcblk0p6         1826816    15499263     6836224   83  Linux

Did I somehow get 5 partitions? How can I free up space?

EDIT: output of df -h

pi@raspberrypi ~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       6.3G  6.0G   25M 100% /
devtmpfs        428M     0  428M   0% /dev
tmpfs            87M  336K   86M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           173M     0  173M   0% /run/shm
/dev/mmcblk0p5   60M   20M   41M  33% /boot
/dev/mmcblk0p3   27M  397K   25M   2% /media/SETTINGS
  • How big is the SD card? What is the output of df -h? Did you run sudo raspi-config and expand the root file system (option 1 - I believe)? Commented Jan 16, 2016 at 21:33
  • 8gig card, I did expand it.
    – Forklift
    Commented Jan 16, 2016 at 21:37
  • is this "just" raspbian or noobs? I don't know what this second FAT partition would be for.
    – Ghanima
    Commented Jan 16, 2016 at 21:38
  • IT is NOOBS yes. Do I need to start over? Should I reinstall without NOOBS?
    – Forklift
    Commented Jan 16, 2016 at 21:39
  • 1
    Check du / |sort -n first, what's eating up space, e.g. logs (if logrotate works not right) or the package manager's cache. Steve's commandline with the -sh is better to do so.
    – Ghanima
    Commented Jan 16, 2016 at 21:56

8 Answers 8


Here's what works for me. You can try this set of commands to purge unneeded package files:

sudo apt-get autoremove
sudo apt-get clean

It won't work a miracle, but sometimes gets me a couple hundred MB's freed up.

If you want to run just raspbian, I have had great luck with Jessie Lite and adding packages as I need. Here's an example on an 8GB uSD card:

Filesystem      Size  Used Avail Use% Mounted on
/dev/root       7.8G  1.1G  6.4G  15% /
devtmpfs        224M     0  224M   0% /dev
tmpfs           229M     0  229M   0% /dev/shm
tmpfs           229M  4.6M  224M   2% /run
tmpfs           5.3M  4.1k  5.3M   1% /run/lock
tmpfs           229M     0  229M   0% /sys/fs/cgroup
/dev/mmcblk0p1   63M   21M   43M  34% /boot
  • That seems helpful. I'll try that in the morning. I did "clean" but not autoremove. Thanks for the suggestion.
    – Forklift
    Commented Jan 17, 2016 at 1:40
  • I'll also look into Jessie Lite but that might set me back some time. I wish there was a way to just download snapshots of OS with stuff I need :)
    – Forklift
    Commented Jan 17, 2016 at 1:40
  • AFAIK, "apt-get autoremove" only removes out of date package files, whereas "apt-get clean" removes them all. If you plan on reinstalling some packages, the former action may be advisable in order to save some time and bandwitth.
    – derjoachim
    Commented Jan 17, 2016 at 6:26

If you installed Jessie on a 8gb, look at the applications you don't use. I removed Mathematica, and gained more than 600 MB with

sudo apt-get purge wolfram-engine
  • And other packages that take space: lifehacker.com/…
    – nsof
    Commented Jan 17, 2018 at 16:57
  • Also: scratch, scratch2 for another 100 MB or so. Commented May 6, 2021 at 17:19

Another solution would be to use a larger (32G) USB stick or SD Card (with a USB SD Card reader) and transfer your root filesystem to the new device. See Expanding size of the root / using external HDD.

If you want to start over without losing what you have on a larger SD Card, here is a way to install bootable Raspbian OS on a new SD Card. After the install, swap the new SD Card with your boot SD Card and you will have a clean system with access to all your old information.

Install Raspbian on the Raspberry Pi from Linux
  1. SETUP -- Requirements are a Linux (type) system able to connect to the internet, write to the micro SD Card (8G or larger), a disk format program (fdisk), wget would be nice with funzip (unzip requires local storage), and a Raspberry Pi. With the SD Card attached to the Linux system in the card reader or in USB card reader, determine the device address with the lsblk or other commands. In my case, I will use /dev/sdb. Check if the device is mounted with the df command and if so, unmount with the umount /dev/sdb? command.

    pi@RPi3:~ $ lsblk
    sdb           8:16   1  29.8G  0 disk
    └─sdb1        8:17   1  29.8G  0 part
    sda           8:0    0 931.5G  0 disk
    ├─sda2        8:2    0 931.4G  0 part /
    └─sda1        8:1    0   120M  0 part /media/pi/boot1
    mmcblk0     179:0    0  29.7G  0 disk
    ├─mmcblk0p2 179:2    0  29.7G  0 part
    └─mmcblk0p1 179:1    0    63M  0 part /boot
  2. FORMAT -- Format the SD Card to one partition, type fat32 [sudo fdisk /dev/sdb, subcmd p, (if not Disklabel type: dos, subcmd o), subcmd d to delete old partitions, subcmd n to create a new partition (take the defaults, primary p, number 1, first, last), subcmd t for type (number 1, code c), and subcmd w to write].

    pi@RPi3:~ $ sudo fdisk -l /dev/sdb
    Device     Boot Start      End  Sectors  Size Id Type
    /dev/sdb1        8192 62552063 62543872 29.8G  c W95 FAT32 (LBA)
  3. DOWNLOAD, UNZIP and WRITE -- It is possible to download the Raspbian image, unzip it, and install it on the SD Card all at once. The unzip command will work if the Raspbian image is first downloaded and then unzipped (unzip will not work with piped input, funzip will). The image is more than 1.5G, unzipped over 4G, it will take sometime to download.

    pi@RPi3:~ $ wget -qO - https://downloads.raspberrypi.org/raspbian_latest | funzip | sudo dd bs=4M of=/dev/sdb
  4. VERIFY -- The image is now installed with two partition (boot and root). The Linux partition is very small and should be expanded. (It is possible to add more partitions if they are needed, before expanding.) Before expanding the Linux partition, NOTE /dev/sdb2 Start Sector (ie 137216 in my case).

    pi@RPi3:~ $ echo -e "p\nq" | sudo fdisk /dev/sdb | egrep "Dev|^/"
    Device     Boot  Start     End Sectors Size Id Type
    /dev/sdb1         8192  137215  129024  63M  c W95 FAT32 (LBA)
    /dev/sdb2       137216 8581119 8443904   4G 83 Linux
  5. EXPAND PARTITION -- The fdisk command can be used to expand the Linux partition. First delete the Linux partition subcmd d, default 2, add it back subcmd n, default p, default 2,
    using the Start Sector (as noted in step 3), take the default for the End Sector, and write the changes subcmd w if happy (or quit without writing the changes with subcmd q). If the Start Sector is the same as before, the data will be in tack.

    pi@RPi3:~ $ echo -e "d\n2\nn\np\n2\n137216\n\nw" | sudo fdisk /dev/sdb

    pi@RPi3:~ $ sudo e2label /dev/sdb2 root
    pi@RPi3:~ $ sudo e2fsck -f /dev/sdb2
    pi@RPi3:~ $ sudo resize2fs /dev/sdb2
  7. OPTIONS -- It is possible to mount the partitions of the SD Card and do file configurations, which is beyond this scope. Make sure the data is sync and unmount if mounted before removing the SD Card from the running system.

  8. BOOT and CONFIG -- Mount the SD Card in the Raspberry Pi and plug in the power. The Pi should boot up. Configure the Pi with reference to https://www.raspberrypi.org/documentation/configuration/.


Probably you don't want to start all over again. If you are short of space after cleaning your multiple downloads and unused source code, move to a larger memory card.

You need to be able to mount a secondary card on you RPI, either with a 'pen drive' carrier with SD socket or similar.

Your installation is based on NOOBS, so you finished with a few partitions no longer in use, however the amount of wasted space is not that significant, the elimination can be painful. Some open spaces are created for boundary alignment.

Create a clone on a larger SD card (16GB or more).

Using Win32DiskImager create an image backup using the 'read' button on a filename of your preference, then, use 'write' to copy the image to the new SD Card.

Mount the new card and boot. At this point, you must be running a clone with the same original empty space.

Using fdisk, 'p' print the current partition. Copy-and-paste this information to where you can use as a reference. Will look like as follows (yours will be different):

Device         Boot   Start      End  Sectors   Size Id Type
/dev/mmcblk0p1         8192  1675781  1667590 814.3M  e W95 FAT16 (LBA)
/dev/mmcblk0p2      1679360 30703615 29024256  13.9G 85 Linux extended
/dev/mmcblk0p5      1687552  1810431   122880    60M  c W95 FAT32 (LBA)
/dev/mmcblk0p6      1818624 30703615 28884992  13.8G 83 Linux

Delete /dev/mmcblk0p2 with 'd' and then enter '2', recreate the partition again. the 'secret' is to use the identical 'start' sector.

Create the Linux extended partition with 'n', select extended, enter the first sector (in my sample 1679360) and let fdisk to select the last sector ('default'), then enter 't' to enter partition 'type' of 'partition' 2, should be type '85' (Linux extended).

Now, create the logical partitions that reside inside the extended partition just created.

Use 'n' for new, enter 'l' for 'logical' and 'fdisk' will assign the next available slot, the first sector must be the same one than before, on my sample, 1687552, the last sector, use the original number, on my sample 122880, enter partition 't' type as 'c' (ms-dos).

Repeat the process for your other partitions but, on the last one (p6), let 'fdisk' select your 'last sector'.

Verify your entries with 'p' and make sure that only the last sector on the last partition changed and nothing else including partition type or 'id'.

Now commit your changes with 'w' to write the new partition table.

Reboot and let Linux know your new disk size with:

resize2fs /dev/mmcblk0p6


  • Why not just dd the whole SD card then resize the partitions?. Duplicating the structure of a good Pi SD is non-trivial, in particular ensuring the optimum boundaries for partitions, which are not on the normal fdisk defaults.
    – Milliways
    Commented Jan 17, 2016 at 4:04
  • The problem is to modify the extended partitions, for unknown reason to me, when changing SD brand, I was unable to recreate the modified partitions on the exact initial sector. Creation of new partitions will, probably, not be in boundary but, being solid state and not physical is not an issue. The easy way should be to use Win32DiskImager (or similar): clone the SD card, using fdisk delete and recreate in place, in this case, mmcblk0p6. and then resize2fs
    – fcm
    Commented Jan 17, 2016 at 4:26
  • To change partitions you first need to modify the extended partition then you can extend the active partition. The reason for the boundary is that when a SD needs to recover space it does so on a Erase Block Boundary - usually 4M. If partition boundaries are misaligned you can need 2 block erases. For a SD card you should specify the disk size in blocks not sectors.
    – Milliways
    Commented Jan 17, 2016 at 4:48
  • It would make more sense, save time, and be less prone to error if rather than using dd to copy the partitions you just formatted them with mkfs.ext4, and then copied in the content with rsync. Note is not clear above that you will need to have created larger partitions first if you want to use resizefs on the filesystem inside the partition.
    – goldilocks
    Commented Jan 17, 2016 at 12:41

Make sure you've expanded your file system to use all available space.

Open a terminal and run sudo raspi-config -> Expand Filesystem

If this is not the issue then you simply need to move to a larger disk. Instead of starting over (these instructions assume a Mac but are very similar otherwise):

Back up the disk:

  • Find disk name: put the SD card into your computer and run diskutil list (probably disk2... don't use disk1!!!)
  • Backup image: sudo dd bs=1m if=/dev/disk2 of=/path/to/your/backup.img. Note, this will take a long-ish time. To see progress press CTRL-T
  • Insert new disk and diskutil list
  • Write to new disk: sudo dd bs=1m if=/path/to/your/backup.img of=/dev/disk2
  • Expand filesystem: Insert into Pi and boot, sudo raspi-config -> Expand Filesystem

I suggest to remove the /usr/share/doc folder using rm -rf /user/share/doc i've got 193M free space :D


In my case, I remove all files in ~/.local/share/Trash/file and ~/.local/share/Trash/info, which free up to 8GB disk space :D


Enter this in Terminal :

dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n .

To delete a package , enter "sudo apt-get purge -y packagename ".

clearing the softwares wolfram,libreoffice and oracle-java can free up 1GB space .

delete wolfram : "sudo apt-get purge -y wolfram-engine".

delete libreoffice : "sudo apt-get purge -y libreoffice*".

delete oracle-java : "sudo apt-get purge -y oracle-java*".

(make sure you don't use them at all )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.