Raspberry Pi 3 Minimal Install

Unfortunately the raspbian unattended network install doesn’t yet support the Raspberry Pi 3, so if you want a really lightweight install on your nice shiny Raspberry Pi 3 you need to do a bit more work.

However, providing you have a Raspberry Pi 2 with a minimal installation it isn’t that difficult since all that you have to do is copy the latest kernel and kernel modules from the official raspbian image.

First you need to download the latest Raspbian Lite image.

# wget https://downloads.raspberrypi.org/raspbian_lite_latest \
> -O raspbian-lite-latest.zip
Saving to: ‘raspbian-lite-latest.zip’
raspbian_lite_lates 100%[=================>] 284.47M 766KB/s in 5m 49s
2016-03-06 16:02:26 (835 KB/s) – ‘raspbian-lite-latest.zip’ saved [298287382/298287382]

When the download is finished you need to insert an SD card into your computer and copy the new image to the card. (You can use this script to help identify the right device name – on my system it is ‘/dev/sde’).

Before writing the image to you need to dismount any existing partitions if they were mounted automatically – any data on the card WILL BE LOST. Use ‘mount’ to list all the partitions that have been mounted and ‘umount’ to unmount them.

# mount | grep /dev/sde | cut -f1 -d ‘ ‘
# umount /dev/sde1
# umount /dev/sde2
# unzip raspbian-lite-latest.zip
Archive: raspbian-lite-latest.zip
  inflating: 2016-02-26-raspbian-jessie-lite.img
# dd if=2016-02-26-raspbian-jessie-lite.img of=/dev/sde bs=8192
166144+0 records in
166144+0 records out
1361051648 bytes (1.4 GB) copied, 147.734 s, 9.2 MB/s

Then you need to mount the new partitions and copy the contents of the boot partition and all the new kernel modules to your local hard disk.

mount /dev/sde1 /mnt
# ls /mnt
bcm2708-rpi-b.dtb      cmdline.txt    fixup_x.dat      overlays
bcm2708-rpi-b-plus.dtb config.txt     issue.txt        start_cd.elf
bcm2708-rpi-cm.dtb     COPYING.linux  kernel7.img      start_db.elf
bcm2709-rpi-2-b.dtb    fixup_cd.dat   kernel.img       start.elf
bcm2710-rpi-3-b.dtb    fixup.dat      LICENCE.broadcom start_x.elf
bootcode.bin           fixup_db.dat   LICENSE.oracle
# mkdir boot
# cp -r -v /mnt/* ./boot/
‘/mnt/bcm2708-rpi-b.dtb’ -> ‘./boot/bcm2708-rpi-b.dtb’
‘/mnt/bcm2708-rpi-b-plus.dtb’ -> ‘./boot/bcm2708-rpi-b-plus.dtb’
‘/mnt/start.elf’ -> ‘./boot/start.elf’
‘/mnt/start_x.elf’ -> ‘./boot/start_x.elf’
# umount /dev/sde1
# mount /dev/sde2 /mnt
# ls /mnt/lib/modules/
4.1.18+  4.1.18-v7+
# mkdir ./lib
# mkdir ./lib/modules
# cp -r -v /mnt/lib/modules/* ./lib/modules/
‘/mnt/lib/modules/4.1.18+’ -> ‘./lib/modules/4.1.18+’
‘/mnt/lib/modules/4.1.18+/kernel’ -> ‘./lib/modules/4.1.18+/kernel’
‘/mnt/lib/modules/4.1.18-v7+/modules.symbols.bin’ -> ‘./lib/modules/4.1.18-v7+/modules.symbols.bin’
# umount /dev/sde2
# eject /dev/sde

Now that we have a copy of the new files we are going to need we can remove the SD card and insert the one containing out minimal installation.

Again if they partitions are mounted automatically you will need to dismount them first.

# mount | grep /dev/sde | cut -f1 -d ‘ ‘
# umount /dev/sde1
# umount /dev/sde2

Then we need to delete the existing files on the boot partition and replace them with the updated versions we saved from the latest raspbian image.

# mount /dev/sde1 /mnt
# rm -r /mnt/* /mnt/.*
rm: refusing to remove ‘.’ or ‘..’ directory: skipping ‘/mnt/.’
rm: refusing to remove ‘.’ or ‘..’ directory: skipping ‘/mnt/..’
# cp -r -v ./boot/* /mnt/
‘./boot/bcm2708-rpi-b.dtb’ -> ‘/mnt/bcm2708-rpi-b.dtb’
‘./boot/start_x.elf’ -> ‘/mnt/start_x.elf’

Then we can unmount the boot partition, mount the second partition and copy across the new kernel modules.

# umount /dev/sde1
# mount /dev/sde2 /mnt
# cd ./lib/modules/
./lib/modules# cp -r -v ./4.1.18+ /mnt/lib/modules/
‘./4.1.18+’ -> ‘/mnt/lib/modules/4.1.18+’
‘./4.1.18+/kernel’ -> ‘/mnt/lib/modules/4.1.18+/kernel’
‘./4.1.18+/modules.softdep’ -> ‘/mnt/lib/modules/4.1.18+/modules.softdep’
‘./4.1.18+/modules.symbols’ -> ‘/mnt/lib/modules/4.1.18+/modules.symbols’
./lib/modules# cp -r -v ./4.1.18-v7+/ /mnt/lib/modules/
‘./4.1.18-v7+/’ -> ‘/mnt/lib/modules/4.1.18-v7+’
‘./4.1.18-v7+/kernel’ -> ‘/mnt/lib/modules/4.1.18-v7+/kernel’
./lib/modules# ls /mnt/lib/modules/
3.18.0-trunk-rpi2  4.1.18+  4.1.18-v7+
./lib/modules# umount /mnt
./lib/modules# eject /dev/sde

Note – We will remove the old kernel modules in ‘3.18.0-trunk-rpi2’ after we have booted from the new installation.

Insert the card into your Raspberry Pi (either a Pi 2 or a Pi 3) and boot as normal, then login as root.

Debian GNU/Linux 8 Pi tty1
Pi login: root
Last login: Sun Mar 6 02:05:00 UTC 2016 on tty1
Linux Pi 4.1.18-v7+ #846 SMP Thu Feb 25 14:22:53 GMT 2016 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

Now we can use the package manager to remove the old kernel modules.

# apt-get purge linux-image-3.18.0-trunk-rpi2 linux-image-rpi2-rpfv
Reading package lists… Done
Building dependency tree      
Reading state information… Done
The following packages will be REMOVED:
  linux-image-3.18.0-trunk-rpi2* linux-image-rpi2-rpfv*
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 61.8 MB disk space will be freed.
Do you want to continue? [Y/n] y
update-initramfs: Deleting /boot/initrd.img-3.18.0-trunk-rpi2
The link /vmlinuz is a damaged link
Removing symbolic link vmlinuz
You may need to re-run your boot loader
The link /initrd.img is a damaged link
Removing symbolic link initrd.img
You may need to re-run your boot loader

Note – The error messages above may be ignored.

That is it – I’d be the first person to admit that it is a bit of a kludge. I’d far rather be able to install the latest kernel modules from the repository but as far as I can tell at the moment you can’t.

Also I suspect that you could also do a minimal installation on a Raspberry Pi 2 and then update to the latest kernel using ‘rpi-update’ but I haven’t tried that yet.

Once you have you Raspberry Pi 3 up and running you will probably want to modify the configuration to ensure that only required packages are installed and any unnecessary locale files are deleted and then to install some additional packages to get a more functional system. If you want a graphical desktop then the next step is probably to install either MATE or XFCE or you could configure NFS and use it as a file server.

Raspberry Pi is a trademark of the Raspberry Pi Foundation

This entry was posted in Raspbian and tagged , , . Bookmark the permalink.

One Response to Raspberry Pi 3 Minimal Install

  1. I know this is set for the Pi 3, but will it also work with the Pi Zero as well?

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s