Minimal Raspbian installation using the Serial Console

Unless I’m messing about with a legacy desktop or low-cost digital signage I generally connect to my Raspberry Pi from my PC or laptop using a USB console cable.

Powering the Raspberry Pi from the USB port keeps the number of cables to a minimum and means you don’t need a separate power supply, all I have to do is plug the USB console cable into my computer or laptop and the Raspberry Pi will start to boot. If I need to I can still install XFCE or MATE and connect to the desktop remotely over the network using XDMCP or VNC.


To accommodate the serial cable I used a fine file to cut a narrow slot about 1.5-2 mm wide in layer 4 of my Pibow Ninja case. When in place the heat shrink on the end of the cable acts as a strain relief collar and prevents the serial cable from being pulled out. Start out by making the slot a little narrower than you need and widen it with the file until it is just right.

raspberry_pi2_serialObviously if you want to use the serial cable in conjunction with a HAT then some ingenuity and a soldering iron may be needed! When installed the red and black cables provide power and the green and white cables are for the serial console.

Note – Make sure you use a cable that is compatible with the Raspberry Pi, the Raspberry Pi may use 5v for power but any more than 3.3v on the serial port will damage it.

Having removed the need for a separate display, keyboard or mouse the next problem is how to do a minimal installation using just the serial console. Fortunately there is an unattended installer available, don’t be put off by the complex looking github page it isn’t that hard, all you need to do is download the compressed installer image from the downloads section at the bottom of the page.


If you are already using a linix machine you can do this using the following commands.

$ wget -c\
> download/v1.0.8.1/raspbian-ua-netinst-v1.0.8.1.img.bz2
Resolving (
Connecting to ||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 20058815 (19M) [application/octet-stream]
Saving to: ‘raspbian-ua-netinst-v1.0.8.1.img.bz2’

raspbian-ua-netinst 100%[=====================>] 19.13M 854KB/s in 24s

2016-02-06 21:47:34 (831 KB/s) - ‘raspbian-ua-netinst-v1.0.8.1.img.bz2’ saved

Or you can just click on this link. Then you just need to uncompress it.

$ bunzip2 raspbian-ua-netinst-v1.0.7.img.bz2

The uncompressed image file should be about 64M bytes, next we need to transfer this image into an SD card.

Writing the image

After inserting your SD card you can use this script to help identify which device it is.

$ ./
sde “USB3.0 CRW-SD”

On my system my SD card is ‘/dev/sde’ – you will need to change this to match your system when entering the commands below.

Note – The existing contents of the SD card will be overwritten!

We need to be logged in as a super user.

$ su


$ sudo -i

Then we need to make sure that there are no mounted partitions on the SD card. To do this I have used ‘mount’ to list all the mounted partitions and combined this with ‘grep’ to filter the results before using ‘cut’ to remove everything but the first space delimited field so only the names of the mounted partitions on the SD card are shown (on my machine the SD card is ‘/dev/sde’ but it may be a different device on your system).

# mount |grep /dev/sde | cut -d " " -f1

If as in this example there are mounted partitions on the SD card then we need to unmount each of them in turn using ‘umount’.

# umount /dev/sde1
# umount /dev/sde2

Then we are ready copy the image file to our SD card.

# dd if=raspbian-ua-netinst-v1.0.8.1.img of=/dev/sde bs=512
131072+0 records in
131072+0 records out
67108864 bytes (67 MB) copied, 20.331 s, 3.3 MB/s

Before removing the card you need to make sure that all the data has been written from memory to the device.

# sync;sleep 3;eject /dev/sde

Then remove the SD card and reinsert it – if you are using a graphical desktop it will be mounted automatically so we need to unmount it and remount it for the commands that follow to work.

# umount /dev/sde1
# mount /dev/sde1 /mnt

Configuring the installer

In order to use the serial interface we need to make some changes to the existing configuration file, and create a new file containing the installation options we want to use.

Start by editing the ‘cmdline.txt’ file to configure the console to use the serial interface during the installation – on my system the serial interface defaults to 9600 baud so I also need to reduce the baud rate to match.

# nano /mnt/cmdline.txt

consoleblank=0 console=ttyAMA0,9600 kgdboc=ttyAMA0,9600 console=ttyAMA0

Then you need to configure the installer by creating a new file called ‘installer-config.txt’.

Note – It is best to type this filename in by hand as when pasting text from a web page the hyphen may look the same but actually be a different character from the one on your keyboard (if the installer ignores the installation options check the file name first, it would have saved me hours trying to get this to work the first time if I has spotted that sooner!)

# nano /mnt/installer-config.txt

cmdline="console=ttyAMA0,9600dwc_otg.lpm_enable=0 console=ttyAMA0,9600"

Note – Remember to change the hostame and root password entries above.

If you don’t specify which release to use the installer will default to the older ‘wheezy’ release and if you want to use all the free space on the SD card you don’t have to specify the root size, however I use 1918M as this means that the resulting system image will fit on a 2GB card and on a larger card you can use the remaining space to create a separate ‘home’ partition later. Lastly, if you don’t want ti use the newer journalling ‘ext4’ filesystem you can change this to ext2.

You can then unmount the SD card, eject it and insert in your Raspberry Pi.

# umount /dev/sde1
# eject /dev/sde

Note – Make sure your Raspberry PI is NOT powered on when you insert or remove the SD card.

Installing Raspbian

The installer is designed to work unattended so you can just plug your Raspberry Pi console cable into you serial port and let it get on with it – but I like to monitor what is happening in a console window.

If you just plug in the USB cable then open a console window and connect to the USB serial port then by the time you are connected you will have missed initial output completely. To overcome this problem I use this script and desktop shortcut to open a console window and then wait while I plug in the USB cable.

��o��[    0.000000] Booting Linux on physical CPU 0xf00
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.18.0-trunk-rpi2
[    0.000000] CPU: ARMv7 Processor
[    0.000000] Machine model: Raspberry Pi 2 Model B
Revision git~f18c193
Built on Tue May  5 20:24:19 CEST 2015
Running on Raspberry Pi version 2
Copying boot files... OK
=== Start executing installer-config.txt. ===
=== Finished executing installer-config.txt. ===

Network configuration:
  ip_addr = dhcp
  online_config =

Waiting for eth0... Configuring eth0 with DHCP...

If the installer hangs at this point you have probably just forgotten to connect the network cable. When you connect the network the installer will continue.

Waiting for eth0... Configuring eth0 with DHCP...
Time set using timeserver ‘’ to... Sat Sep 26 22:43:36 UTC 2015
Installation started at Sat Sep 26 22:40:00 UTC 2015.
Installer configuration:
  preset = server
  packages =
  mirror =
  release = jessie
  hostname = Pi
  domainname =
  rootpw = Password
  bootsize = +128M
  rootsize = +1918M
  timeserver =
  cmdline = console=ttyAMA0,9600 kgdboc=ttyAMA0,9600 console=ttyAMA0
Waiting for /dev/mmcblk0... OK
Applying new partition table... OK
Initializing /boot as vfat... OK
Initializing / as ext4... OK
Mounting new filesystems... OK
Copying /boot files in... OK
Starting install process...

The installation will take about 15 to 20 minutes or so depending on the speed of your internet connection, SD card and model of Raspberry Pi and at the end your Raspberry Pi will automatically reboot, ready for you to use.

Configuring installed system:
  Setting root password... OK
  Configuring /etc/fstab... OK
  Configuring tmpfs to use RAM... OK
  Configuring hostname... OK
  Configuring network settings... OK
  Enabling serial console... OK
  Allowing root to login with password... OK

Removing cdebootstrap-helper-rc.d... OK
Configuring apt... OK
Creating preferences file for libraspberrypi-bin... OK
Updating package lists... OK
Installing bootloader package (=firmware)... OK
Installing libraspberrypi-bin package (=vcgencmd)... OK
Configuring bootloader to start the installed system...
Kernel version: ‘3.18.0-trunk-rpi2’
Copying kernel to /boot/kernel7.img... OK
Creating default cmdline.txt... OK
Saving current time for fake-hwclock...
Installation finished at Sat Sep 26 23:02:10 UTC 2015 and took 22 min 10 sec
Unmounting filesystems... OK
Finished! Rebooting to installed system in 5 seconds...
swapoff: /etc/fstab: No such file or directory
The system is going down NOW!
Sent SIGTERM to all processes
Sent SIGKILL to all processes
Requesting system reboot
[ 1346.606678] reboot: Restarting system
��o��[    0.000000] Booting Linux on physical CPU 0xf00
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.18.0-trunk-rpi2
[    0.000000] CPU: ARMv7 Processor
[    0.000000] Machine model: Raspberry Pi 2 Model B
[  OK  ] Started Update UTMP about System Runlevel Changes.

Raspbian GNU/Linux 8 unknown ttyAMA0

unknown login:

Since the installation leaves the ‘installer-config.txt’ file in the boot partition (which contains the root password) you may want to delete it after logging in for the first time!

# rm /boot/installer-config.txt

This minimal installation makes a great starting point for a number of projects, but you will probably want to modify the configuration and then to install some additional packages to get a more functional system.

You will probably want to begin by creating a separate home partition if you have not already used all the space available on your SD card. Then if you want a graphical desktop then the next step is probably to install either MATE or XFCE. Alternatively you could configure NFS and turn the system into a file server.

Of course all this would be impossible without the work done by Diederik de Haas so I’d like to finish by just saying a big ‘Thank You’ to him for all his hard work.

Raspberry Pi is a trademark of the Raspberry Pi Foundation

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

Leave a Reply

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

You are commenting using your 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