Raspberry Pi3 - Install openhabian to USB and boot from usb (Tutorial in progress)

usb
raspberrypi3
usbboot
Tags: #<Tag:0x00007f0146827488> #<Tag:0x00007f0146827348> #<Tag:0x00007f0146827208>

(Gadget Guy) #1

Work in Progress

NOTE: This thread doesn’t have much value right now because I haven’t had full success. Hopefully will work out the issues and post updates. otherwise I will delete this thread.

I am currently documenting the process for installing latest openhabian image onto a USB drive and set my Raspberry Pi 3b to boot from USB. (Without needing to use a card in the sd card slot (not even for /boot)

Assumptions:

  • Main Computer - Linux - Ubuntu
  • Hardware running openhab2 (Raspberry Pi 3b)

Pre step: . From main computer, use ETCHER to flash latest openhabian image to micro SD card and follow initial setup. ssh into raspberry pi (can watch the install) - You can skip this step if you already have access to the running raspberryPi…

First, check status of current value for option to boot_From_USB in the OTP (one-time programmable memory) of the pi.

openhabian@openHABianPi:~$ vcgencmd otp_dump | grep 17:

The goal is to see a value of: 17:3020000a If you see this value, you can skip the next steps (your Pi already has this set and will attempt to boot from USB in the absence of sd card)

To enable USB boot mode, type the following:

echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt

This adds program_usb_boot_mode=1 to the end of /boot/config.txt.

Reboot the Raspberry Pi:

sudo reboot now

Once the Pi boots, it will read the new line from the /boot/config.txt file and enable the BOOT_FROM_USB option in the OTP memory. We should now see a value of 17:3020000a if set successfully, we can check again with the code:

openhabian@openHABianPi:~$ vcgencmd otp_dump | grep 17:

You should see the new value of 17:3020000a which means the rpi will now check USB slots for bootable medium if one is not found in the memory card slot. (This is a permanent setting). You can now remove the last line from your /boot/config.txt file which we set above. (program_usb_boot_mode=1)

We can now shut down the raspberry pi and remove the SD card and insert our USB stick which has a new image of openhabian flashed using ETCHER.

sudo shutdown now

Remove SD card and plug in your USB now.

You can watch this via ssh from your host computer by logging into the box with ssh openhabian@x.x.x.x (default pass = openhabian) where x.x.x.x is the local IP address of your raspberry pi. This setup will take about 30-60 minutes.

Further Reading:
Raspberry Pi 3- Configure to boot from USB via OTP

… 1+ hour later… I am still waiting for setup to complete. It seems to be writing much slower… I came across a website with benchmark results… tuns out this one get a “terrible average bench” … I am using a 64GB Kingston DataTraveler 100 G3… So take note, and you may want to find a faster card!

USB Benchmark Results - Terrible Average Bench

Alright… so after ~ 2 hours, it finally failed out on one of the last steps (updating openhab to latest stable).

I decided to scrap the USB stick (too slow) and try to use a 240GB SSD … this is currently not working and I reverted to a SD card…


(Gadget Guy) #2

Reserved Slot


(Kim Andersen) #3

I havn´t tried. But I wonder if you could write the image directly to an SSD and then boot I thin it should be possible if you have en Rpi3B+ since it can boot from USB by default.


(Patrick Beard) #4

I just did this last week with a 120GB SSD and my Raspberry Pi 3

Below is how I did it. It is not meant to be a tutorial and I take no responsibility for any omisions or errors!

I imaged my SD card with WinDisk32Imager. I then set the write once bit by adding program_usb_boot_mode=1 to the bottom of /boot/config.txt on the SD card. Then I rebooted to allow the bit to be written.

I then used Etcher to write the SD image I created to my 120GB SSD.

I removed the SD card from my RPi and connected the SSD using a powered SATA to USB lead.

Once it booted I sshd to the RPi and expanded the file system using the command line as raspi-config can’t do it with SSDs. To do this I did the following;

The commands below suited my SD image but may not suite yours

sudo fdisk /dev/sda

Enter p to see the partitions - take a note of the start of partition 2
Press d and then 2 to delete the main partition (I didn’t have a swap partition so nothing else to delete)
Press n then p and then 2 to create a new primary partition, next you need to enter the start of the partition by entering the start number from the old partition that you noted in step one.
For the end of the partition just press enter to accept the default.

If asked to remove ext4 signature select no.

If you are sure you have done everthing ok press w to write the new partition table.

REBOOT

ssh back in and enter sudo resize2fs /dev/sda2

When finished check using df -h.

The SSD and cable I used are;

Kingston 120GB SSD
Powered SATA to USB


(Gadget Guy) #5

That is a neat cable! Thanks for sharing.

Perhaps my issues are indeed are indeed power related… I will look into trying this type of powered USB cable.

I am using a 2.5A power supply to run the Pi and had previously mounted this drive and test creating a couple of files so I thought that might suggest I would be okay.

I am currently running off of SD card but will try again over the holidays to get the SSD based installation running. Will update this post once I do so.


(Patrick Beard) #6

I am also using a 2.5A psu. After my RPi failed to boot with the SSD I left it connected but booted from SD card. I could see the SSD details in the syslog so it was being seen. I never tried to mount it.

With the powered SATA to usb the Pi booted with no problem.


(Peter Loron) #7

Note that I have had success in writing the openhabian image directly to the SSD, rather than needing to use the microSD first.


(Kim Andersen) #8

How??


(Peter Loron) #9

I had the SSD in an external USB case. I simply plugged that into my computer, and used Etcher to write the image to that disk. You need to go into settings and enable “unsafe mode” to be able to select non-flash media.


(Gadget Guy) #10

Yep - this is how I did it as well. checking “unsafe mode” was the key step.

Just be careful not to overwrite your existing hard drive!!! I had to triple check as my SSD was the same as the one running my rig!


(Kim Andersen) #11

Ahh okay… I use Win32DiskImager… Maybe thats the reason I couldn´t get it to work.


(Gadget Guy) #12

Okay, so i picked up a powered SATA to USB connector and sure enough everything worked great.

I had flashed the image using Etcher and it booted and installed without any problems. Will work on updating this tutorial. Thank you for getting me over this hump!


(Patrick Beard) #13

Did you remember to expand the file system?


(CM6.5 H102) #14

Just to give more options.:grinning:

I’ve been running my RPI on SSD without SD card for a while now. If you prefer to use something other than a powered adapter this https://www.amazon.com/gp/product/B06Y5CJSVW/ref=oh_aui_detailpage_o01_s01?ie=UTF8&psc=1 works very well with the RPI.