Video: A guide to Raspberry Pi in 60 seconds
In my previous post, I wrote about assembling and using the Farnell element 14 Pi-Desktop kit. I limited that post to the basic installation, configuration and use of the Pi-Desktop enclosure itself. Now I am going to look at one of the optional expansion possibilities of that kit, adding an mSATA SSD (Solid State Disk).
The first thing to consider, though, is why you would want to do this. There are three obvious reasons:
- Increase disk space, at a better cost than comparable micro-SD cards. This is probably the best reason, and it really does pay off. The largest microSD card I have seen so far is 400GB, while mSATA drives up to 1TB are available, at a price that is only about 25% higher than the 400GB microSD. Prices for equal capacity are consistently lower for mSATA than microSD.
- Improve performance of the Raspberry Pi. This is probably the worst reason, and if it is your goal you are going to be disappointed. This might seem strange at first glance, because mSATA speeds (~500MB/sec) are roughly five times faster than micro-SD (~100MBps). The problem is that the Pi-Desktop add-on board connects to the Raspberry Pi via USB 2.0, which has a maximum data rate of 60MB/sec.
- Get rid of the micro-SD card altogether. This might not be a high priority for the average Raspberry Pi home user, but in commercial and embedded uses the reliability and durability of micro-SD cards can be an issue.
So, consider these carefully when you decide whether you want to do this or not. My own motivation was a combination of these, plus the fact that this just seemed like a cool and fun thing to do. In fact I got an unexpected benefit from it – I learned a few more things about the Raspberry Pi itself.
The Pi-Desktop add-on board, shown above, includes an mSATA connector and standoff/screw posts to connect and secure an SSD. It is important to note that it will only accept an mSATA module like the one also shown above; both physically and logically it is not possible to use the newer M.2 SATA devices.
Installing the SSD is pretty much a no-brainer. Make sure the Raspberry Pi is powered off (no, don’t try to “hot swap” it). Slip the connector into place (it only goes one way), and secure the module with the two screws that came with the Pi-Desktop kit.
When you boot the Raspberry Pi with the SSD installed, you probably won’t see any difference in the Raspbian desktop.
You can confirm that the SSD has been recognized, and find out what name it has been given, using the lsblk command. Here you can see that the SD card is mmcblk0, and has the boot and root partitions on it, and the SSD has been recognized as sda and has no partitions on it yet.
SSD as additional disk drive
The simplest possible way to use the SSD is just as an additional disk drive alongside the standard Raspberry Pi micro-SD card. To do this you will have to partition and format the SSD. There are a number of Linux GUI and CLI utilities for disk management. I prefer gparted for this, but it is not included in the base Raspbian installation so I have to install it first. That can be done with the CLI command:
sudo apt-get install gparted
Of course if you prefer a GUI package manager you could also go to the panel menu, Preferences, Add / Remove Software, then search and install it from there
If you are installing a new (unformatted) SSD; you will first have to create a partition table on it. This can be done with gparted by selecting the SSD from the drop-down device list, then going to Device / Create Partition Table and then choosing gpt. I see absolutely no reason to use the old “msdos” partition table in this case.
The next step is to actually create one or more partitions. I’m not interested in getting into the controversy about filesystem types and sizes for SSD drives, but if you are then just do a search on “Linux SSD” and you will find hours and hours of entertaining and occasionally educational reading. For my purposes in this simple example I created one ext4 partition that covers the entire drive.
After creating the filesystem, just reboot and the SSD will be automatically mounted, under the directory /media/pi/[UUID]. You can see that it is mounted, and where, by running the lsblk command again, or by simply hovering on the Removable Devices icon at the right end of the top panel.
At this point the installation and simple configuration of the SSD is complete. If you prefer to have it mounted in a more obvious place, something like /data, you can add a line to /etc/fstab for it.
SSD for Raspbian root filesystem
Another possibility for configuring the SSD is to actually move the root filesystem to it. The Pi-Desktop software package includes a utility called ppp-hdclone which should do this for you.
Unfortunately I was not able to get this to work. Seriously.
So I finally gave up and decided to just do it myself – it’s not rocket science.
In fact it is probably better to do this yourself, because you need to think just a bit about how you actually want to use the SSD in this case. The simplest way would be to just make one partition that covers the entire SSD, and then copy the existing micro-SD root partition to it. That’s actually not such a great idea, though, because you really should keep your user files and application data separated from the root and home filesystem. A better solution would be to create two partitions, one for the root filesystem and the other for application data.
To do this, follow the procedure above to configure the SSD, but instead of creating one filesystem that covers the entire SSD, make one that is at least a bit larger than the existing root filesystem on the micro-SD card. You can see that on my system the root is 7.27GB, so I could make an 8GB partition on the SSD. But you can also see that there is 6GB used already, so that doesn’t leave much free space (I am using an 8GB micro-SD card in this system). The new SSD has plenty of space, so why not bump up the root partition size now, and make things a bit more comfortable? I decided to make a 16GB partition for root.
Now you just have to copy the contents of the root filesystem from the micro-SD card to the SSD. Note that in this example I am using the device names on my system; they could be different on others, so verify these with what you see in gparted to be sure.
dd if=/dev/mmcblk0p2 of=/dev/sda1 bs=4M iflag=fullblock oflag=direct status=progress
This copy takes a few minutes to complete – enough time to get a cup of coffee, but probably not enough for a lunch break. But what the heck, if you’ve gotten this far and you’re still with me, go ahead and take a lunch break – if anyone says something, tell them that I said it was ok.
When the dd command has completed, go back to gparted, select the SSD partition and then in the Partition menu chose Check. This will clean up any inconsistencies which might have crept in during copying, and it will expand the filesystem to fill the partition (because I created the new partition larger than the old one, remember?). Then reboot the Raspberry Pi – yes, I know that a reboot is not absolutely necessary at this point, but it will pay off in just a few minutes.
After rebooting you have to make two more changes, to tell the boot process and the filesystem table that the root filesystem is going to be moved.
The boot configuration is in the file /boot/cmdline.txt, and the parameter you need to change is “root=PARTUUID=xxxxxx”. You can find the new value with sudo blkid. Use the value from the line for /dev/sda1 (duh), and make sure you take PARTUUID, not the simple UUID.
The filesystem configuration is a bit more tricky, because you have to remember that when you reboot after this, the root filesystem will be the one that you just created on the SSD, not the one which is currently mounted from the micro-SD. This is the reason that I rebooted after copying the root filesystem, because during the reboot the new partition on /dev/sda1 was automatically mounted under /media/pi/, so now I have easy access to the files on it. So now do this:
sudo vi /media/pi/*/etc/fstab
Change the line for the root filesystem (/) so that it has the same PARTUUID value that you just put in the boot configuration file (cmdline.txt).
That’s it! You’re ready to reboot, and the root filesystem will be on the SSD! After rebooting, here is what that looks like with blkid – you can see that /dev/sda1 is the root filesystem, and /dev/mmcblk0p2 is now auto-mounted under /media/pi/.
You can now follow the same procedure I described in the first section above, to create a second partition on the SSD that uses all the remaining free space and either let it automount on /media/pi/[UUID] or add a line to /etc/fstab to mount it.
SSD completely replaces micro-SD
The last alternative for using the SSD is also the most extreme – completely replace the micro-SD card, so the Raspberry Pi actually boots from the SSD. The Pi-Desktop documentation for this is a bit difficult to understand, to say the least (I would be more inclined to describe it as garbled). It includes a link to a github Boot From a USB Mass Storage Device document, but I found that to be equally as confusing.
I finally went back to the Raspberry Pi Documentation How to boot from a USB Mass Storage Device on a Raspberry Pi 3. This document is clear and easy to follow, so I will not repeat those instructions here. I went through them and successfully booted from the SSD. However, I ran into two problems which convinced me that this is not a useful configuration.
- Every time the Raspberry Pi boots, there is a 10-15 second delay while it tries to find a bootable micro-SD card. This isn’t a long time, but after a while it gets pretty irritating.
- After booting from the SSD and then installing the Pi-Desktop add-on packages, the Raspberry Pi no longer boots!
Because the Pi-Desktop was the whole point of this project, that second one means that booting from the SSD is out of the question. I was surprised to run into a problem as serious as this, especially because I haven’t seen or heard anything about it before. But then I went back and re-read the Pi-Desktop documentation, and realized that in the section titled “Initializing Booting from the SSD” they actually say
The default method of the Pi-Desktop utilitzes a micro-SD card; therefore this is the process we will focus on below.
Uh, OK… so the “Booting from SSD” section describes… not booting from the SSD? Like I said, it seems a bit garbled to me. Anyway, it doesn’t mention the fact that really booting from the SSD and then installing the Pi-Desktop software packages causes the Raspberry Pi to not boot at all. If anyone else has actually done this and gotten it to work properly, I would be interested in hearing how you managed it.
What about ordinary USB drives?
As I was running these tests, and thinking about the add-on board connecting via USB, it occurred to me that as far as the Raspberry Pi is concerned, the SSD is just another USB device. (Yeah, I know, I can be a bit slow.) What that means is that all the things that I have done so far with the SSD could also be done with a simple USB disk plugged into one of the Raspberry Pi USB ports. Hmmm.
It wouldn’t look terribly elegant to have an ordinary USB stick protruding from the side of the Raspberry Pi case, but there are some nice nano-USB drives which are not much more than a bump on the side of the case, and have a good capacity at a low price. Keep in mind here that because the Raspberry Pi has only USB 2, you wouldn’t even need to use a USB 3 drive for this, either, and USB 2 drives are getting to be about as cheap as chips!
So, I have repeated all of the steps I made so far, but with an ordinary USB stick rather than the SSD, and it all worked exactly the same way – simple add-on storage, moving the root filesystem to the USB drive, and even booting from a USB stick.
After having such a positive experience with the basic Pi-Desktop kit, I have to say honestly that I am disappointed with the results of adding an SSD to it. It works, and it does have some advantages in terms of overall disk space, reliability and even a bit better performance. But the performance gain is nowhere near what I had (naively) expected, and the inability to successfully boot from SSD and use the full Pi-Desktop functionality are really disappointing.
Previous and related coverage
If you need to turn a Pi into a PC, this kit promises to do it — in minutes.
Hardware spotlight: The Raspberry Pi [Tech Pro Research]
An overview of what this little board can do and how it’s being put to use.
IT pro’s guide to working smarter with Linux [Tech Pro Research]
Get practical tips and advice to help your organization get the most out of Linux.
Read more of Jamie’s Mostly Linux Stuff
- Raspberry Pi: Hands-on with the Pi-Desktop kit
- Installing Linux on a PC with UEFI firmware: A refresher
- Installing Linux on your PC is super easy – here’s how to do it
- Hands On: Keeping a very old laptop useful with Linux