MySQL for the Internet of Things

(Steven Felgate) #1

Chapter 6 ■ Building low-Cost MysQl data nodes


■Tip using an external hard drive—either an ssd or traditional spindle drive—is much faster than


accessing data on a flash drive. it is also typically cheaper per unit (gigabyte) or, as i mentioned, can be easily


obtained from surplus.


Partitioning and Formatting the Drive


Before you can use a new or an existing drive with a file system incompatible with the Raspberry Pi, you
must partition and format the drive. I find it easier to do this on my desktop computer and suggest you
do the same. Thus, the following assumes the external drive has a single FAT (or FAT32) partition. That
isn’t so important because we will delete it and create a new partition with the ext4 file system for optimal
performance.
Begin by connecting the drive to the Raspberry Pi. Then determine what drives are attached by using
the fdisk -l command to see the available disks connected. You should see your hard drive listed as
/dev/sda if you have a standard Raspbian image. If you use a different image or your device is labeled
differently, use the address from your system in the following steps.
Once you identify the disk, launch fdisk again with the device as an option, as shown in Listing 6-1.


Listing 6-1. Partitioning a Hard Disk on Raspberry Pi


pi@raspberrypi ~ $ sudo fdisk /dev/sda


Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m


Help:


Generic
d delete a partition
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table


Misc
m print this menu
x extra functionality (experts only)


Save & Exit
w write table to disk and exit
q quit without saving changes

Free download pdf