HomeMy SetupResourcesNewsProjects/CodeFAQsContact
Raspberry Pi Projects > TNET Raspberry Pi Related Coding Scripts > rpi-wiggle - Expand FS to SDcard Size - RELEASED

RPI-Wiggle

What is it

RPI-Wiggle is a script which expands the smaller image that has been written to a larger SDCard and then expands the filesystem to the full size of the SDCard. However, it backs off just a bit to ensure that when you make a backup a copy of that SDCard, you can then save it to a like sized SDCard.

Raspbian OS comes with a tool which does this called raspi-config, but when it expands, it uses the full size of the SDCard which when backed up many times results in an image that can't be then written to like sized SDcards. This means you have no way to restore it except to use a larger SDCard (If you are already at 32GB, your out of luck). You can use Linux to repartition the filesystems, but the rpi-wiggle script keeps you in the Windows world for the many that don't have Linux.

You would use this script instead of the function built into the raspi-config.

Related Content:

How does it work.

Basically it does the same thing the raspi-config does... it looks at the current SDCard and then caculates the size of the card. This script then calculates the end of that card and backs off the number a bit to make it slightly smaller.

It then uses the fdisk command to set the size of the SDCard filesystems.

When completed with that, it creates a reboot command which will run once when the system is rebooted. REBOOTING IS REQUIRED.

The script stops with a prompt for the user to press ENTER to reboot the system

When the system reboots, the run once script is then executed and uses the resize2fs function to expand the file system of the unmounted /root filesystem to complete the process. This part of the script can take minutes depending on how large the the SDCard you are expanding to. For example, a 16GB card took long enough that the screen saver blank actually turned the monitor off requiring the use of a key on the keyboard to get the screen back on.

When that is completed, the once run script is removed and the boot process continue to the Login prompt. You are done at the point.

Sample before: This was an 8GB image on a 16GB SDcard
    Filesystem      Size  Used Avail Use% Mounted on
    rootfs          7.4G  1.7G  5.3G  24% /
    /dev/root       7.4G  1.7G  5.3G  24% /
Sample after:
    Filesystem      Size  Used Avail Use% Mounted on
    rootfs           15G  1.7G   12G  13% /
    /dev/root        15G  1.7G   12G  13% /

Requirements

Technically, this script should not destroy anything. If it attempts to change the size to something that is not there, it won't do it. Resizing down can't work without removing the filesystem first, but this script will not attempt to do that. Regardless....

USE AT YOUR OWN RISK. If you have anything important on the SDcard you can't be without, save it to another source first.

Where is the script

Normally, I create a directory called /src to put scripts like this into. If you have this or something similar, cd to that directory and then...
cd /src
wget https://raw.github.com/dweeber/rpiwiggle/master/rpi-wiggle

You can also download the script and place it into /boot if you are mounting this in your windows box. Permissions do not need to be set since it will be run as root.

How to use the script

THIS SCRIPT SHOULD ONLY BE RUN ONCE.
Running the script more than once could lead to the system attempting to make the image smaller... This won't work and will have unknown consequences.

sudo ./rpi-wiggle

Starting resize2fs_once, THIS WILL TAKE A FEW MINUTES

DO NOT INTERRUPT THE PROCESS... just let it run.

This will take a while depending on the size of the SDcard you are expanding to. A 16GB card was taking a good 7+ minutes. A 32GB hard will take significantly more.

Checking the status

To see if it is still working... you look at the activity light on the Raspberry Pi. It will either be on solid or on most of the time flickering. If it goes out for a long period of time... something is wrong.

When it completes...

When it is done, the light will go out and then blink as normal as the system continues on with the boot process.

You will end up at the Login prompt and the process will be complete.

At that point, it is done with no further steps to complete.

Login as normal and you should now have the root filesystem expanded to use the new size of the SDCard you put it on.

Related Info





comments powered by Disqus
Copyright © 2014, all rights reserved. Manage
Page Creation by TNET using Boltwire v3.4.16 Hosting by TNET - Views #4543 - Ulterius Server
IP: 50.17.86.12 [ec2-50-17-86-12.compute-1.amazonaws.com] - Thu Dec 18 01:25:35 2014