Published on

Expanding a NOOBS partition with VirtualBox

Authors
  • avatar
    Name
    lalugue
    Twitter

At first, I thought upgrading my Raspberry Pi's SD Card would be a routine procedure. That was until I needed (and found) a way to work around the card's partitions and NOOBS 💡

The Pi đŸĨ§

When I first got my Pi, it used a 16GB SD card, which was initially quite a lot of storage. Over time, I tinkered more with it and I wanted more space. This made me decide to upgrade the storage with a spare 32GB SD card that was sitting somewhere near my table.

I thought I could simply copy my old SD card's contents to the larger SD Card (via Win32DiskImager). Afterwards, I could use sudo raspi-config to extend the partition. However, my Raspberry Pi's installation had a catch...

The Catch: NOOBS đŸŽŖ

The catch was that my Pi's operating system was installed using NOOBS, which was not as straightforward to upgrade.

NOOBS has a rather unusual partitioning system, which raspi-config does not support as of this writing.

Initial Brainstorming 🌩ī¸

Before anything, I created backups of my SD Card's data in case things went awry during partitioning (they did).

At first, I tried fdisk to expand the last partition of my SD Card. However, I could not seem to detect the additional space provided by the "new" SD Card with the tool.

When I tried another tool named parted, I noticed that it could see the additional space available in the larger SD Card. At this point, I was leaning towards using parted, particularly its GUI-powered counterpart: GParted.

I wanted to use the live version of GParted. However, I did not have an extra machine to boot it. My Raspberry Pi also did not have spare peripherals attached such as a monitor, keyboard and mouse.

The Idea 💡

I did not have extra physical devices to boot GParted, but what if I used a virtual device instead?

Then the idea came: use a virtual machine to boot GParted and partition the SD Card!

The Setup đŸ–Ĩī¸

In the software side, the idea used the following tools:

  • VirtualBox
  • GParted (live version)
  • VirtualBox Extension Pack

As for the hardware, fortunately I had an SDCard-to-USB adapter lying around too!

The Expansion 💾

The main idea was using GParted in a virtual machine to expand the Pi's SD card partition 💾

For anyone still curious about how the partition was finally expanded, please feel free to read along 😄

The first part was to setup a VirtualBox virtual machine with GParted. In this case, I created a 64-bit Ubuntu virtual machine but loaded the GParted live version "disc" instead of an Ubuntu one. I headed to the following option to set the disc of my virtual machine:

Settings > Storage

Afterwards, I headed to the empty "Optical Drive" and "mounted" the GParted live version's ISO file into it đŸ’ŋ

GParted storage settings
Mounting the GParted ISO file into the virtual "optical drive"

Before starting the virtual machine, I needed it to have access to USB devices (such as the SD Card to USB adapter). In this case, I installed the VirtualBox Extension Pack.

With the extension pack installed, I turned on the virtual machine. After navigating through the boot menu and successfully booting the virtual machine, I had access to its desktop and GParted.

GParted boot menu
Navigating GParted's boot menu

Afterwards, I expanded the required partition with GParted then attached the newly-partitioned SD card into my Pi once more.

GParted desktop
The GParted desktop (not in image: SD card and its partition/s)!

After turning on my Pi, it recognized the increased space with my files and programs intact! 🚀

Final Thoughts 💭

Playing around and finding a means to enlarge a NOOBS-ified partition was fun overall. Definitely there could be other, and perhaps more efficient, ways to expand SD card partitions. Given the available equipment and constraints I had at the time, it worked 😅

Additionally, I would like to explore other virtualization programs that support accessing physical USB devices without additional proprietary licenses (ie: open-source software ❤ī¸). Alternatively, I could acquire and allocate additional hardware such as an SD Card reader and another Pi for running GParted 🤔 Hopefully Raspberry Pis become more available soon too 🤞

As always, stay tuned to my blog for updates 😉