[How To] Resize NOOBS / PINN Systems


Here is my new web app I have created to allow users to easily set NOOBS / PINN system sizes.

http://noobs.matthuisman.nz/


Rules

  1. A system can only be resized if
    i) Has a partition with 'want_maximised' set to True or
    ii) Has only a single partition (eg. Data Partition)
  2. A system can not be resized smaller than it's calculated size (see below)
  3. 100MB is allocated from the available space to allocate for PINN / NOOBS system files

How it works

In total 3x languages are used (Python, Javascript & PHP).
You can view all the public files on my Github HERE.

generate_systems.py (build cache)

Each night a Python script caches all os_list files, as well as their corresponding partition info
Real minimal system sizes are calculated as sum of ('partition_size_nominal' + 4).
If a partition does not have a 'partition_size_nominal', a default size of 200MB is applied.

App.js (the web page)

This Javascript app just pulls in the cached system data and displays the systems and makes sure the total size fits on the chosen SD card size. It then uses JQuery UI slider with slide callbacks to keep systems larger than their minimum size.


Once the system sizes are set it generates a link with the sizes as URL parameters.

A PHP script then generates the correct cmdline and returns it. It also tells the NOOBS / PINN to use a new URL for the OS list instead of the default.

This is where the magic happens.

proxy.php (do magic)

When the Pi boots, it will fetch the list of systems from the given URL.
The proxy PHP script first loads all the cached systems and then loops over the URL parameters parsed to it. If their is a system that matches a URL parameter, it is added to the JSON output.
But first, it's nominal_size parameter is updated, and it's partition_info URL is changed to also use the proxy script.

proxy.php (do more magic)

For the partitions list, a PHP script calculates the size of the partition to be expanded from the URL size parameter minus the total size of the other partitions. It then set's the partition to this new size and also makes sure the want_maximised is set to False. This means any free space left on the card will remain free. But, it does allow for advanced users to also install custom OS's.