Click here to Skip to main content
15,886,422 members
Articles / Internet of Things / Raspberry-Pi

Raspberry Pi 2 – Running Out Of Space!

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
30 Nov 2016Ms-PL1 min read 11.7K   1   1
Raspberry Pi 2 - Running out of space

So after about two weeks of using the Raspberry Pi 2, it ran out of space. I had only the 4GB SD Card that came with it. Daniel Wayne Amstrong has a detailed blog at his Circuidipity website, that shows exactly how to move the RasPi 2 to a USB drive.

Since I am doing this well after the initial install, and am already running as root, I decided to skip a few of the steps and commands given in Daniel’s post. Here is what I did:

Remember, I am doing this on a system running Raspbian OS “Wheezy” installed on a 4GB SD Card. I already have Bind, Apache and MySQL running on this system and hosting this WordPress blog.

I did not have a USB hard drive ready, so I decided to use an old HP 32GB thumb drive instead. Deviating from Daniel’s blog, I will be using the entire 32GB for my rootfs partition that will be mounted as “/”.

What follows is just the flow on the command line. My comments are interspersed where required with a “//” at the start of the line…

# lsusb
// my device was shown as mounted on /dev/sda

# fdisk /dev/sda

Command (m for help): p
// shows partition list

Command (m for help): n
// new partition

Partition type:
  p  primary
  e  extended
Select (default p): [ENTER]
Partition number (1-4, default 2): [ENTER]
// partition is created

Command (m for help): w
// partition is committed, tool quits

# mke2fs -t ext4 -L rootfs /dev/sda1
// format the newly created partition to ext4 and label it "rootfs"

# mkdir /mnt/tmp
# mount -t ext4 /dev/sda1 /mnt/tmp
// create a folder in /mnt called "tmp", mount the new drive there

# rsync -axv / /mnt/tmp
// copy all the files from current "/" partition on the SD card to the new rootfs partition 
// we just created. This will take a LONG time.

# nano /boot/cmdline.txt

In nano, find the entry for “root=” and point it to our USB stick (/dev/sda1) and add a timeout (rootdelay=5) so that Raspbian waits appropriately for the device to become available. Ignore anything else in that file. The new statement should look as below:

dwc_otg.lpm_enable=0 ... root=/dev/sda1 ... rootdelay=5

Since we are not mounting any storage partitions (like Daniel), we are done and need to reboot to our new drive now.

# reboot

Have fun!

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
PraiseGreat Pin
WMiller9930-Nov-16 4:06
WMiller9930-Nov-16 4:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.