Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Adding custom OS version examples

procount edited this page Sep 11, 2017 · 12 revisions

In addition to the readme entry about adding custom OS to noobs I'd like to share the process of doing it.

As an example we try to add Ubuntu Mate as new OS to raspberry pi, since it was not officially added by the foundation yet.

Before you start you might want to look at the developer information first.

Ubuntu Mate

This tutorial was tested and works with Noobs 1.5. Also see this thread as reference.

You need to use a Linux PC to create the image of course. Basic Linux knowledge is required.

Creating partition archives

# Most of the time you need to use the root user. Be careful!

# Also note the size in MB (round up) for the partition_size_nominal value.
# Commands inside parted: print quit
parted ubuntu-mate-15.10.1-desktop-armhf-raspberry-pi-2.img

# Create loopback devices for mounting
# Then mount the partitions via GUI or command line
sudo kpartx -av ubuntu-mate-15.10.1-desktop-armhf-raspberry-pi-2.img

# Pack the files. root/ has to be packed with root user. This takes quite some time.
# Get the size of the extracted tar archive we create.
# Note the values for the uncompressed_tarball_size.
cd /media/$USER/PI_BOOT
bsdtar --numeric-owner --format gnutar -cpf /tmp/boot.tar .
ls /tmp/boot.tar -l --block-size=1MB
xz -9 -e /tmp/boot.tar 
cd /media/$USER/PI_ROOT
sudo bsdtar --numeric-owner --format gnutar --one-file-system -cpf /tmp/root.tar .
ls /tmp/root.tar -l --block-size=1MB
xz -9 -e /tmp/root.tar 

# Unmount the partitions via gui or command line. Then do:
sudo kpartx -dv ubuntu-mate-15.10.1-desktop-armhf-raspberry-pi-2.img

Required files

Now create a folder inside os named Ubuntu. Place the two created tar.xz files in there. You also need to create a few other files:

partition_setup.sh
#!/bin/sh

set -ex

if [ -z "$part1" ] || [ -z "$part2" ]; then
  printf "Error: missing environment variable part1 or part2\n" 1>&2
  exit 1
fi

mkdir -p /tmp/1 /tmp/2

mount "$part1" /tmp/1
mount "$part2" /tmp/2

sed /tmp/1/cmdline.txt -i -e "s|root=[^ ]*|root=${part2}|"
sed /tmp/2/etc/fstab -i -e "s|^.* / |${part2}  / |"
sed /tmp/2/etc/fstab -i -e "s|^.* /boot |${part1}  /boot |"

umount /tmp/1
umount /tmp/2
partitions.json
{
  "partitions": [
    {
      "label": "boot",
      "filesystem_type": "FAT",
      "partition_size_nominal": 63,
      "want_maximised": false,
      "uncompressed_tarball_size": 21
    },
    {
      "label": "root",
      "filesystem_type": "ext4",
      "partition_size_nominal": 3867,
      "want_maximised": true,
      "mkfs_options": "-O ^huge_file",
      "uncompressed_tarball_size": 3133
    }
  ]
}
os.json
{
  "name": "Ubuntu_Mate",
  "version": "wily",
  "release_date": "2015-12-21",
  "kernel": "4.1",
  "description": "Ubuntu MATE for the Raspberry Pi 2",
  "url": "https://ubuntu-mate.org/raspberry-pi/",
  "supported_hex_revisions": "1040,1041",
  "feature_level": 0
}
Ubuntu_Mate.png

The Icon for Ubuntu is also missing, but not important. You can download it yourself, resize it to 40x40px and name it the same as the Ubuntu_Mate folder aka Ubuntu_Mate.png.

I took the image from bitbucket and resized it to 40x40px.

File overview

$ ls /os/Ubuntu_Mate -l
-rw-rw-r-- 1 username username  11040008 Feb  6 23:54 boot.tar.xz
-rw-rw-r-- 1 username username       272 Feb  7 10:44 os.json
-rwxr--r-- 1 username username       420 Nov 21 22:43 partition_setup.sh
-rwxr-xr-x 1 username username       414 Feb  7 00:12 partitions.json
-rw-rw-r-- 1 username username 913935756 Feb  6 23:58 root.tar.xz
-rw-rw-r-- 1 username username      2720 Feb  7 09:59 Ubuntu_Mate.png

Arch Linux for Pi2

See this issue for more information.

Kali Linux

Kali Linux follows the same process, but make sure your if you have a Pi 3 that you are connected to the Internet.

If you want to the Kali icon, I pulled one off of Google and made it 40x40px. You can get it off this link

BEWARE one of the partitions, loop0p2, gave me a lot of trouble. To get around that use:

mount -o loop,ro,noexec,noload /dev/mapper/loop0p2 {wherever you want to mount}

You will have a read-only version of the filesystem because of the ro option. You can remove it and try again if you need special files you need to add to the root.tar

My os.json file:

os.json
{
    "description": "Kali Linux for RasPi added to NOOBS Bootloader",
    "kernel": "4.4",
    "name": "Kali",
    "release_date": "2017-05-25",
    "supported_models": [
        "Pi 2",
        "Pi 3"
    ],
    "url": "https://www.kali.org/",
    "version": "2017.1"
}

Other resources: