My Raspberry Pi 2 was mostly disused, running a couple of Seti@Home threads. It is out of date and the speed was always rather slow compared to the other machines in my home. Some of it is because 1GB RAM is anemic in 2016 but some of it is because a MicroSD is a very slow storage device, even with tuning Linux parameters in configuration files like /etc/fstab.
So, I decided to do something about it. I have a 120GB USB 2 backup drive that is also a bit out of date, having been replaced with a slim USB 3 1TB drive. But, it is still a cheetah when compared with a MicroSD. Being cheap, I decided to simply use the 120GB drive rather than buy a new one.
Strategy: roughly, Transfer system disk from SD card to hard disk - eLinux.org . I would have liked to followed the RPi3 strategy of booting directly from the USB drive (https://www.raspberrypi.org/blog/pi-3-booting-part-i-usb-mass-storage-boot/ ). Unfortunately, that would become yet another "project" in itself due to RPi2 off-the-shelf firmware limitations (fixed, hopefully: https://github.com/raspberrypi/documentation/blob/master/hardware/raspberrypi/bootmodes/README.md ). However, getting everything but /boot functions onto a USB drive will still be quite satisfying.
First, whether you are going with RPi2 or RPi3, keep in mind that a USB drive needs power. The RPi2, as I learned the hard way [], does not have sufficient power for write-stability. Get a powered USB hub if the drive does not have a power chord. In my case, I have one of those USB Y-cables from the Pleistocene epoch so the green connector (data) plugs into the RPi2 and the blue/black connector (juice) plugs into one of my Intel PCs (yes, cheating to save money and space in my home office).
Okay, here we go:
1. Make sure that the USB drive is ready for copying the entire MicroSD-based root partition [/]. The drive is going to be reborn. Did you save all the data that you want to keep somewhere else?
2. The simplest preparation approach is to install `gparted` if you do not already have it (Just as good as Windows Partition Magick and it is donation-ware! ). On my desktop, `gparted` appears in the desktop menu under the category "Preferences" (Why not "System Tools"?). Go figure.
3. Launch `gparted` from the menu. Be careful because it is potentially dangerous but so is `gpart, `fdisk`, and `sfdisk`. I am recommending this GUI to avoid manual calculations and minimize the chance for mishap. Enter your `sudo` password.
4. From the drive list in the upper right, select the drive that Raspbian mapped your USB drive to. Mine was /dev/sda. Be careful.
5. Related to the selected drive, you will see a list of partitions and 0 or more line(s) stating "unallocated". Click on Device > Create Partition Table. If you see a no-can-do message that 1 or more partitions are "currently active", unmount them: Right click on a mounted partition and select "Unmount". Once all of the partitions of this drive are unmounted, proceed to re-create the partition table:
See the "WARNING....." pop-up.
Select "msdos" and click "Apply".
6. The result of the previous step is a single line "unallocated". Now, create a single ext4 partition which is a little bit larger than the MicroSD /dev/mmcblk0p2 partition:
Right click on the line "unallocated".
Select "New".
Enter the size in MiB. My Jessie Pixel /dev/mmcblk0p2 partition was 14.9 so I entered 16. We will enlarge this later.
Optionally, you can label the partition (E.g. "raspbian-slash").
Click "Add".
7. Commit changes by clicking on the little green check mark near the top of the GUI. Exit from `gparted` when all of the commit screens are done.
8. Going to do a partition copy with `dd`. Windows and Mac users have an equivalent tool. For the sake of the example, I assume that your target partition is specified as /dev/sda1:
sudo dd bs=4M conv=noerror if=/dev/mmcblk0p2 of=/dev/sda1
# Go have a pint and kick back. This is going to take a bit.
10. The previous step concluded perfectly. Re-launch `gparted`. Select the drive and the new partition. Right click and select "Resize/Move". You can extend the partition to the end of the disk. Exit `gparted`.
11. sudo YOUR-FAVORITE-EDITOR /boot/cmdline.txt
Change "/dev/mmcblk0p2" to "/dev/sda1", assuming again that /dev/sda1 is the new partition on the USB drive.
Save and exit.
12. Disconnect the USB drive and reconnect it. Note where it is mounted, say, /minister/silly-walks/usbdrive.
13. sudo YOUR-FAVORITE-EDITOR /minister/silly-walks/usbdrive/etc/fstab
Change "/dev/mmcblk0p2" to "/dev/sda1", assuming again that /dev/sda1 is the new partition on the USB drive.
Save and exit.
14. Reboot
Yes, I followed this to the letter. My RPi2 is considerably faster in terms of disk I/O and, therefore, storage-dependent applications (all of them?).
Fallback: Power off. Take out the MicroSD. Edit it somewhere to reverse steps 11 and 13. Re-insert MicroSD. Power on. You are back to where you were. What went wrong?
Questions/comments?
Top Comments