How to: Use External Hard Drive with Raspberry Pi

In this Tutorial, I will go over how to use an external hard drive with a Raspberry Pi. This will allow us to expand the storage of the Pi and increase the longevity of the SD card.

SD cards on the Raspberry Pi are cheap and come in relatively larger sizes, but have a few limitation, such as wearing out quickly and become exponentially more expensive at larger capacities. Wouldn’t it be great if you could take a standard hard drive or SSD and use that for storage on the Pi instead? Well, good news, you can! Though it will take a bit of work to set it up initially, but once all the hard work is done, you can use all of that sweet capacity for whatever project you’d like!!

Step 1: Get a Disk

First we will want to obtain a disk that we want to use for the Pi. This can be anything from a Hard Drive to an SSD or even a USB memory stick. Ensure this is a disk you do not care about erasing, as all contents will be deleted permanently.

For this project I chose to use a hard drive I had laying around: a 600 GB . I got myself a SATA to USB3 adapter so that I can plug it into my Pi. If you go this route, make sure to get a USB3 type, especially if working with a Raspberry Pi 4. If using a hard drive instead of SSD, you may be required to use an external power supply as USB might not be enough to turn the disk on.

Step 2: Format Disk and Create Partition

We first want to determine what the disk is called on the system when it is plugged in:

sudo lsblk

Should look as follows:

In my case, my disk is “sda” and is about 600 GB in size. As can be seen, the disk has a partition already name “sda1”. The mmcblk0 is the SD card.

Next, we want to use the fdisk tool to create a new partition. Type to following command, ensuring the “/dev/sda/” matches the disk name on your Pi.

sudo fdisk /dev/sda

Once in the tool, type ‘p’ into the terminal to check the details of the disk. In my case, the “Disklabel type” was of type “DOS”. We will want to change that to “GPT”.

Type in “g” (lowercase) to switch it to GPT. Then type ‘w’ to save this change. Go back into the fdisk tool using the “sudo fdisk /dev/sda” command again.

Type ‘p’ again to ensure that the “Disklabel type” has changed to “gpt”.

Type ‘n’ to create a new partition. Hit the enter key three times to choose the default values for all options. This should create a new partition on the disk of the full size of the disk.

Finally, we want to save all our selections and actually write all of this to the disk. Type ‘w’ to write to disk.

Step 3: Mount the Drive

Now that we have formatted the disk to work properly with Linux, we want to mount the drive so we can start to actually use it with Home Assistant. We can mount it in two ways, the manual way or the automatic way. The manual way is good for initial testing, but is required on each power cycle. With the automatic way, the system will automatically mount the disk at boot up, which is what we ultimately want to do.

First we are going to need to create a filesystem on the disk. This is going to create an EXT4 filesystem on the disk:

mkfs.ext4 /dev/sda1

Again, make sure to use the partition name we just created before of your system. Depending on the size of the disk, this might take a while. It might ask you to confirm that you want to do the command. Next we will want to create a folder in the /mnt directory to attach the disk so it can be mounted.

sudo mkdir /mnt/hassio

I decided to name my folder “hassio”, but this can be whatever the user wants. Next we want to make sure we have permission to access the new folder:

sudo chown -R pi:pi /mnt/hassio

Finally, we mount the disk to the new folder we just created:

 sudo mount /dev/sda1 /mnt/hassio

Of course, you will want to match your disk name and folder name. And there we go, we finally have a disk to use! Of course we mounted it manually, and we dont want to have to do that everytime, so lets change that.

Step 4: Setup Automatic Disk Mounting

We first have to find out the UUID of the disk, so that if the name changes when a new disk is plugged in, it wont mount that one instead. Luckily Linux makes that easy to find:

ls -l /dev/disk/by-uuid/

You should see the partition after a set of random HEX characters, in mine case it is “63dc61ad-81b3-4990-9db3-f63b1c885f72”. Write this down somewhere, we will need it soon. We want to edit the “fstab” file to tell the system what to mount and how to mount it. Use “nano” to edit this file.

sudo nano /etc/fstab

At the bottom of the file, add the following line:

UUID=63dc61ad-81b3-4990-9db3-f63b1c885f72 /mnt/hassio   exfat   auto,nofail,noatime,users,rw,uid=pi,gid=pi 0 0

Replace the UUID with the one you found earlier, as well as the folder name to match the one you created. Hit ctrl-s, ctrl-x to save and exit nano. Now whenever we reset the Pi, the disk will be mounted to the folder we created. Neat!

Step 5: Now what?

Now that the disk has been mounted, we can use the folder that the disk is mounted to just like any other Linux folder. All file access inside that folder will actually be on the disk itself, so try playing around with it!

1,706 replies on “How to: Use External Hard Drive with Raspberry Pi”

I do consider all of the ideas you have introduced in your post.
They are very convincing and will definitely work.
Nonetheless, the posts are very quick for starters.
May just you please lengthen them a little from subsequent
time? Thank you for the post.

We stumbled over here coming from a different web page and thought I may
as well check things out. I like what I see so now i’m following you.
Look forward to checking out your web page repeatedly.

Excellent post. I was checking continuously this blog and I’m impressed!

Very useful info particularly the last part 🙂 I care for such info much.
I was looking for this particular information for a
long time. Thank you and best of luck.

hi!,I really like your writing so a lot! proportion we
be in contact extra about your article on AOL? I require a specialist on this space to solve my problem.
Maybe that is you! Taking a look forward to look you.

Can I simply just say what a comfort to find an individual who
really knows what they are talking about on the net. You definitely realize how to bring an issue to light and
make it important. A lot more people have to
look at this and understand this side of your story.
It’s surprising you are not more popular since you surely possess the gift.

I’m impressed, I must say. Rarely do I come across a blog that’s equally educative and entertaining, and let me
tell you, you have hit the nail on the head. The issue is something that
too few men and women are speaking intelligently about.
Now i’m very happy that I found this during my search for something relating to this.

Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.
You clearly know what youre talking about, why waste your intelligence on just
posting videos to your blog when you could
be giving us something enlightening to read?

Aw, this was an extremely nice post. Taking the time
and actual effort to produce a great article…
but what can I say… I hesitate a lot and never manage to get nearly anything done.

It’s the best time to make some plans for the longer term and it’s time to
be happy. I’ve learn this submit and if I may I desire to recommend you some
attention-grabbing things or tips. Maybe you
can write subsequent articles regarding this article.
I want to learn even more things approximately it!

Magnificent beat ! I wish to apprentice whilst you amend your website,
how can i subscribe for a blog website? The account
aided me a applicable deal. I have been a little bit acquainted of this your broadcast provided bright
clear idea

Undeniably believe that which you stated. Your favorite justification seemed to be on the net the
simplest thing to be aware of. I say to you, I definitely get
annoyed while people think about worries that
they plainly do not know about. You managed to hit the nail upon the top and also defined out
the whole thing without having side-effects ,
people can take a signal. Will likely be back to get more.

You could certainly see your expertise in the work you write. The world hopes for even more passionate writers like you who are not afraid to say how they believe. Always follow your heart.

Hey there just wanted to give you a brief heads up and let you know a few of the pictures
aren’t loading properly. I’m not sure why but I think its a linking issue.
I’ve tried it in two different internet browsers
and both show the same results.

Nice post. I used to be checking constantly this blog and I’m inspired!

Extremely useful information specially the remaining phase 🙂 I care for such information much.
I was looking for this particular info for a long time.
Thank you and good luck.

I do not know if it’s just me or if everyone else experiencing issues with your website.
It looks like some of the written text in your content are running off the screen. Can someone else please
comment and let me know if this is happening to them as well?

This could be a problem with my internet browser because I’ve had this happen before.
Appreciate it

Hey there just wanted to give you a quick heads up.
The words in your content seem to be running off
the screen in Safari. I’m not sure if this is a format issue or something to do with browser compatibility but I thought
I’d post to let you know. The style and design look
great though! Hope you get the problem resolved soon.

Excellent goods from you, man. I’ve understand your stuff previous to and you’re just extremely fantastic.
I actually like what you’ve acquired here, really like what you’re stating and the
way in which you say it. You make it entertaining and you still take care of to keep it smart.
I can not wait to read far more from you. This is really a great web site.

Fantastic goods from you, man. I’ve be aware your stuff previous to and you’re simply extremely great.

I actually like what you’ve acquired here, really like what you’re saying and
the way through which you are saying it. You are making it enjoyable and
you still take care of to keep it wise. I cant wait to learn far more from you.

This is really a great web site. adreamoftrains web hosting company

Thanks a bunch for sharing this with all people you really recognize what you’re speaking about!
Bookmarked. Please additionally talk over with my site =).

We may have a link alternate agreement among us

After going over a few of the articles on your site, I honestly appreciate your way
of blogging. I book-marked it to my bookmark webpage list and will be checking back in the near future.

Please check out my web site too and tell me how you feel.

With havin so much written content do you ever run into any problems of plagorism or copyright infringement?
My site has a lot of completely unique content I’ve either authored myself
or outsourced but it appears a lot of it is popping
it up all over the internet without my agreement. Do you
know any methods to help stop content from being stolen? I’d certainly
appreciate it.

Hi I am so glad I found your webpage, I really found you
by error, while I was researching on Bing for something else, Regardless I am here now and would just like to say thank
you for a marvelous post and a all round interesting blog
(I also love the theme/design), I don’t have time
to read it all at the moment but I have bookmarked it and also
added your RSS feeds, so when I have time I will be back to read more,
Please do keep up the fantastic work.

Hi there just wanted to give you a quick heads up and
let you know a few of the images aren’t loading properly. I’m not sure why but I think its a linking
issue. I’ve tried it in two different web browsers and both show the same results.

This design is incredible! You certainly know how to keep a reader entertained.
Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Wonderful job.
I really enjoyed what you had to say, and more than that, how you presented
it. Too cool!

A fascinating discussion is definitely worth comment.
I do believe that you ought to publish more on this
topic, it may not be a taboo matter but typically folks don’t discuss these subjects.
To the next! All the best!!

Oh my goodness! Amazing article dude! Many thanks, However
I am experiencing issues with your RSS. I don’t know why I can’t join it.
Is there anybody getting identical RSS issues? Anybody who knows the solution will you kindly respond?

I’m amazed, I must say. Seldom do I encounter a blog that’s equally educative and
amusing, and without a doubt, you have hit the nail on the head.
The problem is something that too few folks are speaking intelligently about.
Now i’m very happy that I found this during my hunt for something
relating to this. 2CSYEon cheap flights

Hey, I think your site might be having browser compatibility issues.
When I look at your blog site in Firefox, it looks fine but when opening in Internet Explorer, it has some overlapping.

I just wanted to give you a quick heads up! Other then that, terrific blog!
31muvXS cheap flights

Howdy! Do you know if they make any plugins to assist with SEO?

I’m trying to get my blog to rank for some targeted keywords but
I’m not seeing very good success. If you know of any please share.

Kudos! cheap flights y2yxvvfw

Usually I don’t learn post on blogs, however I wish to
say that this write-up very compelled me to check out and do it!
Your writing taste has been surprised me. Thanks, very nice article.
yynxznuh cheap flights

Its like you learn my thoughts! You seem to know so
much about this, such as you wrote the e-book in it or something.
I think that you simply can do with some % to power the message home a little bit, but other than that, that is magnificent blog.

An excellent read. I will certainly be back. 32hvAj4 cheap

Greetings, I believe your web site might be having internet browser compatibility problems.
When I take a look at your blog in Safari, it looks fine but when opening
in I.E., it has some overlapping issues. I simply wanted to provide
you with a quick heads up! Other than that, excellent

My developer is trying to convince me to move to .net from PHP.
I have always disliked the idea because of the
costs. But he’s tryiong none the less. I’ve been using Movable-type on a variety of websites for about a year and am worried about switching to another
platform. I have heard good things about

Is there a way I can transfer all my wordpress posts into it?
Any kind of help would be greatly appreciated!

Hey are using WordPress for your blog platform?
I’m new to the blog world but I’m trying to get started and set up my own. Do you require
any coding knowledge to make your own blog? Any help
would be really appreciated!

In Staffing, anytime, so debatable are the agents recommended by the quantity’s first-rate rank to believe cialis online forum uncharted that the getting one’s hands urinalysis of chunk over and above at tests to seem the reference radical, forms to seem its prevalence. 5 cialis Fcyjfs vnhzbg

You really make it seem so easy with your presentation but I find this topic to be really something that I think I would never
understand. It seems too complex and extremely broad for me.
I’m looking forward for your next post, I will try to get the hang of

Hey there! Someone in my Myspace group shared this website with us so I came to give it a look. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers! Wonderful blog and outstanding style and design.

I am curious to find out what blog platform you’re working with? I’m having some minor security problems with my latest blog and I’d like to find something more risk-free. Do you have any suggestions?

Hello there! This article could not be written any better! Going through this post reminds me of my previous roommate! He continually kept talking about this. I most certainly will send this post to him. Pretty sure he’s going to have a very good read. Many thanks for sharing!

I’ve recently started a blog, the info you provide on this web site has helped me greatly. Thanks for all of your time & work. “The inner fire is the most important thing mankind possesses.” by Edith Sodergran.

Thanks for the sensible critique. Me and my neighbor were just preparing to do a little research on this. We got a grab a book from our local library but I think I learned more from this post. I’m very glad to see such excellent info being shared freely out there.

Greetings from Idaho! I’m bored to tears at work so I decided to check out your blog on my iphone during lunch break. I really like the information you present here and can’t wait to take a look when I get home. I’m shocked at how fast your blog loaded on my mobile .. I’m not even using WIFI, just 3G .. Anyways, excellent site!

I simply couldn’t go away your website prior to suggesting that I really loved the usual info a person supply in your visitors? Is gonna be again continuously to inspect new posts