Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Ubuntu Server

You're reading from   Mastering Ubuntu Server Upgrade your Ubuntu skills

Arrow left icon
Product type Paperback
Published in Jul 2016
Publisher
ISBN-13 9781785284526
Length 430 pages
Edition 1st Edition
Concepts
Arrow right icon
Author (1):
Arrow left icon
Jay LaCroix Jay LaCroix
Author Profile Icon Jay LaCroix
Jay LaCroix
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Deploying Ubuntu Server FREE CHAPTER 2. Managing Users 3. Managing Storage Volumes 4. Connecting to Networks 5. Managing Software Packages 6. Controlling and Monitoring Processes 7. Managing Your Ubuntu Server Network 8. Accessing and Sharing Files 9. Managing Databases 10. Serving Web Content 11. Virtualizing Hosts and Applications 12. Securing Your Server 13. Troubleshooting Ubuntu Servers 14. Preventing and Recovering from Disasters Index

Installing Ubuntu Server (Raspberry Pi)

The Raspberry Pi has become quite a valuable asset in the industry. These tiny computers, now with four cores and 1 GB of RAM, are extremely useful in running one-off tasks and even offering a great place to test code without disrupting existing infrastructure. In my lab, I have three Pis on my network, each one responsible for performing specific tasks or functions. It's a very useful platform.

Thankfully, Ubuntu Server is quite easy to install on a Raspberry Pi. In fact, it's installed in much the same way as Raspbian, which is the distribution most commonly used on the Pi. Ubuntu Server is available for Raspberry Pi models 2 and 3. All you'll need to do is download the SD card image and then copy it directly to your SD card. Once you've done that, you can boot the Pi and log in. The default username and password is ubuntu for both.

Note

At the time of writing, the version of Ubuntu Server for the Raspberry Pi 3 is not officially supported but should work. The Pi 2 version is fully supported. The Pi 3 version is expected to be fully supported at some point.

To install Ubuntu on the Pi, perform the following steps:

  1. To get started, you'll first download the SD card image from here: https://wiki.ubuntu.com/ARM/RaspberryPi and check that it is compatible with your model of Raspberry Pi.
  2. In order to write the image to an SD card, first extract it and then use dd to do the actual copying. This is very similar to the process we used to create bootable USB media. In fact, it is the same; the only difference is the source and target. From a Linux system, you can perform the process with the following command:
    # dd if=/path/to/downloaded/file of=/dev/sdX bs=1M
    
  3. As before, replace if= and of= with the path to the downloaded and extracted file and the target respectively. If you are unsure about which device your SD card is on your system, execute:
    # fdisk -l
    
  4. In my case, this process can take some time to complete. Often, the command prompt will return even before the syncing process is actually finished. This means you'll more than likely see the access indicator LED on your card reader continue to flash for a while before the process is truly complete. It goes without saying, but make sure you remove your SD card only once the LED has stopped flashing. If you'd rather have the command prompt NOT return until after the process is complete, add the sync option, like the following:
    # dd if=/path/to/downloaded/file of=/dev/sdX bs=1M; sync
    
  5. So for example, on my system, the command will be:
    # dd if=/home/jay/downloads/ubuntu-server-16.04.img of=/dev/sdc bs=1M; sync
    

Depending on the speed of your card reader, this process will likely take at least 5 minutes to complete, if not longer. Once you're finished and you start up your Pi, you're likely to notice an issue straight away. If we execute:

df -h

We'll see that regardless of the size of our SD card, we'll have quite a bit of space that is not being utilized. This is because the SD card image will be the size of the SD card it was captured from, which will most likely not equal the size of yours. This will result in wasted space. What we'll need to do is resize the installation to match our SD card.

First, from the Pi after it's started up, enter fdisk by executing the following command:

# fdisk /dev/mmcblk0

Next, we'll need to delete the second partition, by pressing d + 2.

With the partition deleted (and while still within the fdisk console), we'll recreate the partition we deleted by pressing n + p + 2 and Enter (twice) +w.

With those commands executed, execute the reboot command to restart the Pi. However, we have one more command to execute. Once it starts backup, we can do the actual resizing with:

# resize2fs /dev/mmcblk0p2

After the resize procedure, you should be all set and able to utilize all the space of your SD card. You should also be able to use your Pi as a means of following along with the activities of this book. One last thing, though. If you execute this, you'll notice that your Pi doesn't have a swap partition:

free -m

This is normal, and while you can create a swap file to fill the role of a swap partition, I recommend you don't. SD cards are much too slow for swap, so you'd be better off without it. Since the Raspberry Pi 2 and Pi 3 only have about 1 GB of RAM, make sure whatever processes you plan on running fit within that restraint and you should be fine.

You have been reading a chapter from
Mastering Ubuntu Server
Published in: Jul 2016
Publisher:
ISBN-13: 9781785284526
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image