How can I set up a USB HDD to extend the life of my SD Card and maximize the performance of my Raspberry Pi?
1 Answer
If you're going to have a HDD that's always attached to the Pi, then you can mount the sections of your filesystem that incur the largest number of read/writes directly from it.
These directories are probably the culprits:
/home/
/var/
/tmp/
You are able to mount partitions on your external hard drive to these directories automatically at boot. Let's say your HDD is /dev/sdb
, and it has four partitions. You can append your /etc/fstab
to look something like this:
/dev/sdb1 /var ext4 defaults 0 1
/dev/sdb2 /home ext4 defaults 0 1
/dev/sdb3 /tmp ext4 defaults 0 1
/dev/sdb4 none swap sw 0 0
I've also included a swap partition. Though you might want to research how effective swap can be over USB. I really wouldn't expect much from it.
More information about swap in this question: How to set up swap space?
-
Would you add a swap partition/file to the HDD (assuming it was not an SSD) and if so how? Commented Jun 18, 2012 at 22:15
-
I probably wouldn't bother with swap. It's not going to be very quick over USB. But by all means try it out. I'll edit my answer.– JivingsCommented Jun 18, 2012 at 22:17
-
1I wonder if the pi will continue to boot when the USB HDD is disconnected?– faultyCommented Jun 11, 2013 at 12:29