Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Banana Pi Cookbook

You're reading from  Banana Pi Cookbook

Product type Book
Published in Jun 2015
Publisher
ISBN-13 9781783552443
Pages 200 pages
Edition 1st Edition
Languages
Author (1):
Ryad El-Dajani Ryad El-Dajani
Profile icon Ryad El-Dajani

Chapter 3. External Disks

In this chapter, we will cover the following recipes:

  • Mounting a USB drive

  • Mounting an SSD or HDD via SATA

  • Mounting via fstab

  • Booting from an external disk

Introduction


This chapter is all about external disk drives. We will connect and mount USB drives and HDD or SSD drives using the SATA connector. Furthermore, we are going to explore the possibility of moving the root filesystem to, and booting from, an external drive.

Mounting a USB drive


USB flash drives are widely used to store various files and directories. They are great to exchange data from or to different computers. They are found literally everywhere. In this recipe, we are going to mount an external USB flash drive. This way, you will have access to the contents of the flash drives.

Getting ready

This recipe requires the following ingredients:

  • A booted up Linux on the Banana Pi

  • A USB flash drive

  • Access to the Banana Pi's shell

How to do it…

Perform the following to successfully mount a USB flash drive (also called USB disk):

  1. Boot up your Linux distribution on the Banana Pi.

  2. Attach the USB flash drive to one of the available USB ports, as shown in the following image:

    Tip

    On some distributions (such as Raspbian), the USB drive may be mounted automatically by a program called udisks.

  3. Determine the USB device by entering the following command into a shell:

    $ sudo fdisk –l
    
  4. You will see a list of attached disks. The following screenshot shows the output of the...

Mounting an SSD or HDD via SATA


Besides the mounting of disks via USB, the Banana Pi provides a SATA interface. This interface provides greatly improved performance compared to USBs for hard disk drives (HDD) or solid state disks (SSD).

Getting ready

This recipe requires the following ingredients:

  • A Banana Pi

  • USB power supply unit

  • An SD card containing a Linux distribution

  • A hard disk drive or solid state drive

  • A SATA-to-SATA cable and a SATA power supply for your drive or SATA cable with power supply terminals

  • Access to the Banana Pi's shell

All these products can be bought from retailers. The SATA cable with power supply terminals is quite rare. You might search for that item on online stores that specialize in single-board computers. If you search for Banana Pi SATA cable with power terminals or similar on your desired search engine, you will find retailers for that product.

How to do it…

The mounting of an external drive via SATA is similar to the mounting of a USB flash drive we discovered in...

Mounting via fstab


In this recipe, we are going to automount our drives using the fstab (located at /etc/fstab) system file.

Getting ready

The following components are required to mount drives conveniently using the fstab file:

  • A working Linux system on the Banana Pi

  • A USB flash drive and/or a SATA drive

  • In case of a SATA drive, a working connection to your Banana Pi and a suitable power supply

  • Access to the Banana Pi's shell

How to do it…

Perform the following to configure a drive in your fstab:

  1. Connect your devices accordingly.

  2. Power your Banana Pi and initiate the boot sequence.

  3. Open a shell.

  4. Determine the used filesystems by blkid on attached partitions:

    $ sudo blkid
    
  5. You will get information about all the available partitions. In the following screenshot, you see that the drive /dev/sda has three partitions (sda1 using ext4, sda2 using FAT32, and sda3 using NTFS):

  6. Create the necessary target directories to mount these partitions:

    $ sudo mkdir /mnt/ext4_partition
    $ sudo mkdir /mnt/fat_partition
    $...

Booting from an external disk


This recipe explains how to copy the root filesystem from the SD card to an external disk and boot from it. This is an advanced recipe. You will still require an SD card as the kernel with the necessary filesystem drivers located at the first partition of the SD card.

You may want to move your root filesystem from the SD card to an external drive for performance and/or space reasons. Also when having a lot of I/O operations on the SD card, the SD card may become unstable. A filesystem on a SATA attached disk is more stable in general.

Getting ready

The following ingredients are needed when using an external disk as the root filesystem:

  • A working Linux system on the Banana Pi

  • A SATA HDD or SSD drive

  • A working connection to your Banana Pi and a suitable power supply

  • Access to the Banana Pi's shell

How to do it…

This recipe is split into two subtopics, the preparing (that is formatting) of the external disk and the copying and configuring of the root filesystem.

Formatting...

lock icon The rest of the chapter is locked
You have been reading a chapter from
Banana Pi Cookbook
Published in: Jun 2015 Publisher: ISBN-13: 9781783552443
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 $15.99/month. Cancel anytime}