News How to Run Raspberry Pi 4 or 3 Off an SSD or Flash Drive

Jul 11, 2019
1
0
10
I tried this verbatim and it doesn't seem like it was tested: the mounted /media/newdisk gets copied onto itself recursively. I think the rsync command needs an exclude. Also, most of us will be doing this with a fresh install, wouldn't it be a lot faster to flash the SSD with the buster zip file?
 
Aug 1, 2019
1
0
10
So now that I followed the instructions exactly, I have the same problem as rpi4_user. I am not an experienced Linux user so the comment "the rsync command needs an exclude" is probably correct but it doesn't help me. Is there going to be an update on the original post to fix the problem? Is there a simple method to recover from the infinite loop my rpi4 is now in? Thanks.
 
Aug 10, 2019
1
0
10
I have tried this also exactly and it doesn't work for me. The pi4 just hangs trying to start various services and failing. I did change the fstab entry also and still no luck.
Thoughts?
 
Aug 14, 2019
1
0
10
I tried this verbatim and it doesn't seem like it was tested: the mounted /media/newdisk gets copied onto itself recursively. I think the rsync command needs an exclude. Also, most of us will be doing this with a fresh install, wouldn't it be a lot faster to flash the SSD with the buster zip file?

I just tried it, and it worked fine for me. It doesn't 'copy onto itself'...it's mounting the external drive into a folder, so you can drag and drop files into it by placing them into the folder. This is how you modify iso images. The only thing he seems to have forgotten, was to unmount the /media/newdisk after copying everything, but I suspect that happens anyway when you unmount the drive. Not sure...I unmounted manually...'sudo umount /media/newdisk'. The empty folder newdisk in /media still exists though, it would have been better to just 'mkdir ~/newdisk', then just delete it from the home directory once you're done.

Other than that...the only other thing I changed, was to use the actual PARTUUID for the cmdline.txt file, as just using the /dev/sd* can cause issues if you plug another usb drive in later on, causing the /dev/sd* to change. So... run 'blkid' from the terminal, and look for your device's /dev/sd*, then find the PARTUUID at the end of the info. ' /dev/sdb1: LABEL="usbboot" UUID="57ea0cd6-c9ce-48b8-82f5-02076eeccd7e" TYPE="ext4" PARTUUID="b9c26a96-01" ' So, I put 'root=PARTUUID=b9c26a96-01'. You should also add it to the fstab, but I haven't gotten there yet. :p

The only other thing I did...was to install and use gparted to delete,create,format the usb to ext4. So much easier than doing by command prompts. :p

After all that though, the easiest and fastest way to do this...is to write the original image to both the sdcard, and the usb device. Then edit the /boot/cmdline.txt of the sdcard to use the /dev/sda2 partition. Then once booted and the initial install/configuration's done, you can edit the cmdline.txt file with the proper PARTUUID info, as well as add the info to fstab. That's how I did it with the RPi2B a few years ago. The original image was small enough that I could get away with just using a 2GB sdcard for the boot disk. :)
 

ginandbacon

Reputable
Aug 22, 2019
11
1
4,515
Just wanted to add that I got this to work. A little trial and error but I got it working. I used this adapter with this drive. Updated the /etc/fstab accordingly. Only difference is I am using PARTUUID in fstab to set /root external drive and PARTUUID in cmdline.txt. The biggest difference I have found is extremely increased network speeds for transferring large files from the Pi to a network location or mounted drive with full Gigabit throughput (over 100MB/s). I also recommend using gparted to format the drive as I had sector alignment issues when using fdisk

Also, I confirmed MSATA on my other Pi 4 using this adapter and this drive

HDPARM MSATA results:
pi@pihole:~ $ sudo hdparm -t /dev/sda1

/dev/sda1: (msata drive)
Timing buffered disk reads: 1064 MB in 3.00 seconds = 354.66 MB/sec

pi@pihole:~ $ sudo hdparm -t /dev/mmcblk0

/dev/mmcblk0: (sd card)
Timing buffered disk reads: 130 MB in 3.01 seconds = 43.17 MB/sec

pi@raspberrypi:~ $ sudo hdparm -Tt /dev/sda1

/dev/sda1: (SSD)
Timing buffered disk reads: 1070 MB in 3.00 seconds = 356.20 MB/sec

/dev/mmcblk0: (sd card)
Timing buffered disk reads: 130 MB in 3.03 seconds = 42.90 MB/sec
 
Last edited:

stretch9x

Commendable
Sep 23, 2019
14
1
1,515
You can achieve faster storage speeds on a Raspberry Pi by putting your programs on an external drive. Here's how.

How to Run Raspberry Pi 4 or 3 Off an SSD or Flash Drive : Read more
Does not work on RPI4. Found typo
You can achieve faster storage speeds on a Raspberry Pi by putting your programs on an external drive. Here's how.

How to Run Raspberry Pi 4 or 3 Off an SSD or Flash Drive : Read more
Does not work well on my 4gig pi4b. After spotting a typo on line 13 that left the period out of /boot/cmdline.txt, I finally managed to make the mod install but throughout the entire effort, I was plagued with this: Having a ssd on either USB3 port makes my usb2 wirelesss mouse/keyboard dongle very irratic. Tried a wired usb mouse/kb combo to no avail. Tried a usb2 SSD HAT ssd adapter with a different SSD but have the same issue. Spent a couple frustrating days trying to find a solution to this issue and gave up. The same SSD, adapter and mouse/kb combo works perfectly on my rpi3b+ after applying the "boot from usb" mod. I suppose there will be a lot of unhappy pi users that waited so long for the appropriate firmware update, Installed the 64 bit firmware upgrade today, Big improvement over the 32bit version on 64bit apps.
 

stretch9x

Commendable
Sep 23, 2019
14
1
1,515
Does not work on RPI4. Found typo

Does not work well on my 4gig pi4b. After spotting a typo on line 13 that left the period out of /boot/cmdline.txt, I finally managed to make the mod install but throughout the entire effort, I was plagued with this: Having a ssd on either USB3 port makes my usb2 wirelesss mouse/keyboard dongle very irratic. Tried a wired usb mouse/kb combo to no avail. Tried a usb2 SSD HAT ssd adapter with a different SSD but have the same issue. Spent a couple frustrating days trying to find a solution to this issue and gave up. The same SSD, adapter and mouse/kb combo works perfectly on my rpi3b+ after applying the "boot from usb" mod. I suppose there will be a lot of unhappy pi users that waited so long for the appropriate firmware update, Installed the 64 bit firmware upgrade today, Big improvement over the 32bit version on 64bit apps.
(solved it) : I did this:
echo 2 sudo tee /proc/irq/55/affinity
No trouble now when the SSD is in a USB3 port. All is good now. My PI-4B is now using my SSD for storage and my wireless mouse/kb combo is no longer dropping out.
 
Oct 13, 2019
1
0
10
Since the update to Raspbian in September 2019 and other updates this routine no longer works. I recommend the following procedure: https://jamesachambers.com/raspberry-pi-4-usb-boot-config-guide-for-ssd-flash-drives/ and use gparted to expand and resize the second partition on the hard disk. BTW, I had to use the StarTech USB3 to SATA3 adapter to complete the project. Keep in mind you still need a microSD in the pi just for the boot, but then the hard disk does everything -EVERYTHING else. Nice.
 
Nov 24, 2019
2
0
10
I tried this verbatim and it doesn't seem like it was tested: the mounted /media/newdisk gets copied onto itself recursively. I think the rsync command needs an exclude. Also, most of us will be doing this with a fresh install, wouldn't it be a lot faster to flash the SSD with the buster zip file?

The rsync command worked for me as shown without problems. The 'x' option in "rsync -avx ..." prevents the recursive copy into itself. -x is the short form for --one-file-system ("don't cross filesystem boundaries"). Note 'x' must be lower case; upper case 'X' has a different meaning ("preserve extended attributes").
 
Nov 24, 2019
2
0
10
I ran into a problem, because /boot/cmdline.txt did not exist, and creating a new one did not work.

Turns out in the install image I started with (64-bit Ubuntu server from https://ubuntu.com/download/raspberry-pi), various boot configuration files are found in /boot/firmware/*.txt. /boot/firmware/README explains what they are and which are read when. For the procedure here to work, I needed to edit /boot/firmware/nobtcmd.txt instead of /boot/cmdline.txt.
 
Dec 2, 2019
2
0
10
I ran into a problem, because /boot/cmdline.txt did not exist, and creating a new one did not work.

Turns out in the install image I started with (64-bit Ubuntu server from https://ubuntu.com/download/raspberry-pi), various boot configuration files are found in /boot/firmware/*.txt. /boot/firmware/README explains what they are and which are read when. For the procedure here to work, I needed to edit /boot/firmware/nobtcmd.txt instead of /boot/cmdline.txt.

Thank you so much @ogolyx - I too was using ubuntu server (19.10) on my pi (4b), and didn't realize cmdline.txt wasn't the right file. So appreciative that you came back to share what you found!
 
Dec 2, 2019
2
0
10
After several hours of banging my head against the wall with this tutorial, I finally figured out that when you're using a Raspberry Pi 4B running Ubuntu Server 19.10, and you boot off of the sdcard, and want to re-route root to a usb ssd, once you complete the rsync step, you then need to do this:

sudo blkid (to get the UUID of the usb ssd's primary partition, usually /dev/sda1, but could be other things)
sudo nano /etc/fstab (and add a 3rd line that reads: UUID=theuuidofyourssdpartition /media/yourmountlocation ext4 defaults 0 0
sudo nano /boot/firmware/nobtcmd.txt (and change root=LABEL=writable to root=UUID=theuuidofyourssdpartition and leave everything else unmodified)

Once you've done that, you should be able to reboot and the Pi will just boot up and presto, everything just works. At that point, after you login, if you do sudo fdisk -l you'll see that /dev/sda1 or whatever is now mounted on / meaning ubuntu now considers your usb ssd's primary partition to be where root is. Yay! Hope this helps...
 
Dec 29, 2019
1
0
10
Worked like a champ with Raspbian buster on a Pi 4 with 4GB with a 500GB SanDisk Extreme Portable SSD.
  • Docker build speed cut in half for my current project.
  • dd writes went from 15MB/s to 106 MB/s.
  • dd reads went from ~33MB/s to 200-218 MB/s
  • hdparm showed 354.54 MB/sec
Note you have to replace the old root info in step 14, not just add info to the end. My original cmdline.txt was:

console=serial0,115200 console=tty1 root=PARTUUID=5e3da3da-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

New one is with the bolded text replaced:

console=serial0,115200 console=tty1 root=/dev/sda1 rootfstype=ext4 rootwait elevator=deadline fsck.repair=yes
 
Last edited:
Jan 8, 2020
1
0
10
You can achieve faster storage speeds on a Raspberry Pi by putting your programs on an external drive. Here's how.

How to Run Raspberry Pi 4 or 3 Off an SSD or Flash Drive : Read more
Oh Kay!
I've read thru everyones replies and answers, and I jumped in and started setting up a 512 G SSD on (one of) my Pi(s). I've been using various flavors of linux since kernel v 0.97. I can follow instructions and I understand the boot process fairly well.
That being said....
I was able to get my Pi to boot from the SSD, yet when I resized the partition down to 64G, well I had problems! Even though there was only 7.5 G data written to the SSD, the resizing seemed to foul things up.
I started getting input/output errors running top and that sort of thing. so I rebooted.
THAT did not go well!
Kept getting kernel panics rebooting CPU2 could mount the file system. I went into the recovery and tried to edit the config files to point back to the SD card.
Nothing worked!
Phew!
Bit the bullet and went to reinstall from scratch! Yecch!

Here is the SUPRISE!
When the install screen came up, it gave me the option to install to the SD card or the SSD!
I figured "WTF?" I've hosed the system, whats a little more time trying it out, right?
Well, It seems to work! It does hit the SD card a bit during boot, but the majority of the action seems to be on the SSD. When the boot is all done, the SSD is mounted as / and the SD (boot) partition is mounted on /boot.
I still have to resize the partitions that Raspian lays out, They don't allow for a real swap partition, and I want one!

So, y eah, I have to go through the whole software update thingy, but, it seems that I've found the "easy" way to install Raspian on an SSD and have the system configure it for you.

Yes, you do need to leave the SD card in, but the speed up is fantastic!
 
Feb 11, 2020
1
0
10
I followed this guide and did as many suggested here to overcome a bunch of errors thrown when pointing to SSD.

So after updating the cmdline.txt (tried /dev/sda1 and PARTUUID) and rebooting my PI4, I couldn't get over an error on Boot 'No working init found'

So I ran a fsck on the sda1, and I got literally hundreds (maybe thousands) of errors on my SSD, which lead me to think that I'm not using a compatible SSD.

Any thoughts from anyone?
 
Mar 8, 2020
1
0
10
Since the pi 4's improved performance will expand the use cases for the machine, many users would be very happy to overcome the SD card's limitations, which have now turned into a bottleneck. With prices for SSDs going down, a working solution would be very welcome, indeed.

This topic imho warrants a tested and consistent HowTo. After reading the original article and the informative posts, I am a pit put off to travel down that road, as there seem to be so many inconsistent experiences.

I would appreciate, if the original author took the time to revisit this issue and published a modified version of the above article.

@ https://www.tomshardware.com/author/avram-piltch: Thanks for the effort, if you ever find the time to do it!
 

elias023

Reputable
Mar 5, 2018
2
0
4,510
www.eliax.trade
At instruction number 12:
sudo rsync -avx /bin /dev /etc /home /lib /lost+found /mnt /opt /proc /root /run /sbin /srv /tmp /usr /var /media/newdrive/
sudo mkdir /media/newdrive/sys

That way the folder won't copy into itself and we still get all the essential files and folders needed to boot up properly.
 
Last edited:
Apr 26, 2020
1
0
10
Bit the bullet and went to reinstall from scratch! Yecch!

Here is the SUPRISE!
When the install screen came up, it gave me the option to install to the SD card or the SSD!
I figured "WTF?" I've hosed the system, whats a little more time trying it out, right?
Well, It seems to work! It does hit the SD card a bit during boot, but the majority of the action seems to be on the SSD. When the boot is all done, the SSD is mounted as / and the SD (boot) partition is mounted on /boot.
I still have to resize the partitions that Raspian lays out, They don't allow for a real swap partition, and I want one!

So, yeah, I have to go through the whole software update thingy, but, it seems that I've found the "easy" way to install Raspian on an SSD and have the system configure it for you.

Yes, you do need to leave the SD card in, but the speed up is fantastic!
Could you outline how you went about doing the reinstall and where you got the SSD option ?
 
May 5, 2020
1
0
10
The disk instructions landed me up with a GPT, not a MBR, and didn't quite work.


When using fdisk you have to DELETE all the current partitions

Then you must use the “o” (letter oh) command to make it a DOS formated disk

Then use the “n” for new partion, type is “p” for primary , then “1” , then return, then return

Then “w”


Also, YOU must make sure you get the PUID of the new disk and use that in the cmdline.txt file
and YOU must then change the /etc/fstab to also mount by the PUID as well
 
May 11, 2020
2
1
10
The instructions worked for me. I did not edit fstab or anything else not written in the instructions. I used a m.2 ssd in an enclosure. I can see and feel the difference. I kinda want my home folder on it's own partition, but I'll have to save that job for another day. I see other instructions go about this differently, and I wonder what the difference is.