Raspi 2: Move system root to usb-SSD

Hi Craig,

doesn’t sound good. But I’ve no clue what went wrong.

I’ve installed the openhabian image here from scratch once again and moved the system to my ssd.
After rebooting everything is fine, I had no problem to connect again.

So the question for me is, wheter the fix is faulty or some other problem (hardware or connection issues) occured.

If it is a problem with moving the system to the usb-device, then it should be suciffient to put the SDcard in an external cardreader and copy back cmdline.txt.sdcard to cmdline.txt to make your PI boot again.

Hey Peter,

Well my Pi booted up now but with a pretty strange fix. What I did was force a wrong hostname in PuTTY and tried to connect, and as expected received an error. Then I saved the correct hostname of ‘openhabianpi’ and it connected! Maybe something to do with the stored certificate in PuTTY?

For a complete layman, how do I verify that my system is indeed running on the SSD?

Thanks again for your help and for this functionality. Since I live in South Africa but spend most of my time abroad reliability is essential. My OH installation has been running perfectly on an SD for many months, completely unattended, but if I’m running on SSD it should be even more robust. So far it’s been solid :slight_smile:

Edit: This was after I did:

put the SDcard in an external cardreader and copy back cmdline.txt.sdcard to cmdline.txt

Hi Craig,

sounds like a connection problem for me.

Anyway, if you copied back cmdline.txt.sdcard to cmdline.txt, then you’re running on SDCard again (instead of the SSD).

You can verify that with the command “lsblk”. Look at the mountpoint “/” (that is your system root). If it is mounted on sda1 then you’re on the SSD, if it is mounted on mmcblk0p2, then you’re on the SDCard.

Hi all,

I’ve tried again this morning but when I reboot after setting the current to 1 (as done by the menu option), I never get further than this stage…

I’ll leave it for another hour and see if it progresses. Otherwise is there possibly any workaround to passing this stage?

Don’t know if it’s due to a slowish internet connection

Hi @peter_juenger,

I was looking after the official raspberry documentation for USB boot. Have you considered to support the program_usb_boot_mode feature as well. I also wonder what are the pros and cons compared with the current solution?

works great:

Hi @ptweety,

So far I have not thought of supporting the native usb_boot_mode of the PI3.

The pro of the present solution is that it works with all PIs (1, 2 and 3).

The cons are that you need to install openhabian on the SDCard first and that you’ll stil need it for booting (the vfat /boot partition). However, using the SDCard for booting should wear it to much.

Anyway, shouldn’t be a big thing, whats your oppion on that @ThomDietrich?

Hey guys,
I’m open for additions and improvements. So whatever you can think off, hack away!
Regarding the topic: I have no strong notion here. As you might have read somewhere else, I am not concerned about SD card failure and don’t need the extra space of an external mass storage.

The “program_usb_boot_mode” feature sounds like a good solution indeed and might be interesting for many. From what I’ve read usage of said feature is less related to the system image but relies on a RPi3 and the usb boot mode activated. @ptweety @sihui correct? I don’t see why the latest openHABian image wouldn’t work like this.

That’s also my unterstanding.

I could modify the existing menu entry in a way that if it’s a PI3, then the necessary usb_boot bit would be set in addition to the usbpower 1 A.
After the reboot, if it’s a PI3, also a vfat boot partion would be created when the system is moved.
Then the PI3 should boot completely from the usb mass storage device.

However, I see some drawbacks with this solution:

  • works only with PI3s with recent firmware and recent bootcode
  • compability may be worse then having the boot partion on the SDCard

Another possibilty would be to have a separate menu entry for the moving the system on a PI3, so that the user with a PI3 could choose the desired boot-method (the existing or the new one) on its own.
Drawbacks I see then is that the menu would get somewhat more cluttered and the code duplication.

Correct.

I vote for that!

Just want to report back about my experience with this great tutorial and what I actually did different:

  1. created two partitions an my mSATA-SSD
NAME        FSTYPE LABEL UUID                                 MOUNTPOINT
sda                                                           
├─sda2      ext4   root  34c60a4e-41d2-4992-855b-d61835ba4d6e /
└─sda1      vfat   boot  D5F0-D458   
  1. used the rsync command to copy my root (and boot as well)
rsync -aAXH --info=progress2 --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/boot/*"} / /mnt
  1. changed from device names to PARTUUID references in /etc/fstab:
proc                  /proc           proc    defaults          0       0
PARTUUID=62ac66b5-01  /boot           vfat    defaults          0       2
PARTUUID=becf1c2d-02  /               ext4    defaults,noatime  0       1

and /boot/cmdline.txt:

dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=becf1c2d-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

So, I still boot from SD but have my root on SSD while being prepared to completely switch over to SSD.

Hi @ThomDietrich

I am not concerned about SD card failure

You’ve not encountered any issues? So far I’ve run on SD card for months without missing a beat, but in the back of my mind I worry that the card will burn out, hence I’m desperately trying to get the system onto my SSD which I bought solely for this purpose. I’ll try again tomorrow on a fresh install and a fresh RPi3, but for some reason it never reboots after running the process. :frowning:

If you’ve made any changes to the routine please let me know and I’ll be happy to test it from start to finish.

openHABian: Problem after upgrade :wink:

…the SD card will survive 318 years :boom:

Now we’re talking… :smile:

This is of course pure mathematics. I’m not seriously believing in this number and I’m not planning to wait that long to find out :stuck_out_tongue_winking_eye:

Hi Community,

I moved my openhab partition to an usb ssd disk using the configuration setup menu. The sd card is still needed to boot i assume.
My question now is: if I want to backup my openhab system, is it sufficient to backup the ssddrive only? Can the boot sd card easily be recreated from scratch if it should be faulty? If I backup the sd card once will that be sufficient or does it change while openhab is running? Would it be advisable and possible to switch the sd boot partition to ssd completely?

Another question I have is: cloning the ssd drive takes quite some memory. Its a 180gb ssd that I still had lying around. A acronis ( compressed) backup takes almost 180 gb. How can this be? There is not much on the disk but the openhab installation, some additional packages that I required (eg python related stuff ) the mqqt server and some scripts.

Would amanda backup as well copy and backup the entire disk or just the openhab settings? I would rather have a complete disk backup but disconnecting it every time to back it up using acronis while connecting it to my laptop is a bit uncomfortable.

Best regards and thanks for any hint

Trigan

This article is quite old now - I see it’s mentioning it’s for an Rpi 2, but if you’re running RPi3B there is an exceptionally easier way… build up your Openhab install and configuration on your SD card as per normal, then type:

vcgencmd otp_dump | grep 17

It should come back with 17:1020000a (meaning boot off SD card)

Now edit the /boot/config.txt and add to the bottom:

program_usb_boot_mode=1

Save the file, then reboot your Rpi. Once logged back on, run the above command again:

vcgencmd otp_dump | grep 17

It should now come back with 17:3020000a (meaning boot off USB disk - but, it will always try SD first. If it comes back with the original setting, then you either typo’d the entry, or you’re running an older Rpi that doesn’t support booting off USB-to-SSD disk)

Now edit the config.txt file a 2nd time, and remove the program_usb_boot_mode=1 line. Immediately after that, shutdown the RPi:

sudo shutdown now

Remove the SD card, and put it in a USB SD card reader and install in your PC. Download win32diskimager and take an image of the SD card saving to a file on your PC. Once done, unplug your USB SD card reader and plug the SSD disk into your PC (via the USB-to-SSD 3.0 cable you would have bought) and now write the image you took with the win32diskimager back to the SSD disk.

Once complete, plug the USB-to-SSD cable with SSD disk into your RPi and power it up. Voila, you’re now booting from SSD disk, NO SD card needed. Boot up time will be marginally slower as the RPi looks for the SD card initially (5 seconds longer from my testing), but will revert to the USB SSD disk straight after. Note that this process won’t work with most SATA/SAS disks, as being mechanical drives the USB port can’t provide enough grunt to power the drive.

You do NOT need the SD card to boot the RPi with an SSD disk. Some have said an empty SD card will improve the boot speed. In terms of performance, I’ve noticed OH is faster with the SSD disk, even though it’s limited by the USB 2.0 speed of the interface.

In regards to doing OH backups, see my super simple backup script if you happen to be running an FTP server… Super simple OH backup script to FTP server

Hello Chimera,

thanks for Your fast reply and Your helpful hints.

Yes I am using an RPI3. I will try the above steps to get rid of the SD card. Boot time is not a big factor for me. Systems is running most of the time 24/7.

Problem for me now is that I expanded the partition with the openhabian-setup.
I am not sure how to get it back to SD card before I can copy it and expand it using the steps above.
I have my openhab 2.2 installation for a long time now and there are many additional packages installed, I can not remember, it grew over the years. To start from scratch would be a big drawback for me.

I never had any issues powering the ssd drive. I just use a usb y-cable as it was sold for the old portable micro usb sata harddrives. The main usb plug is fitted in my rpi3 . the second usb is connected directly to my usb power plug.

y cable

Hello again,

I upgraded to openhab 2.4 now and tried to get it work without SD card. It would not boot.
Is it possible to take the mount from usb steps but without having to copy the whole image to ssd card.
(as I wrote in my post above)
I am asking because my image is already on the ssd disk. I just have the sd card for the boot. Its probably the boot sector that has to be copied, right?

boot value is still showing 17:1020000a

best regards

Trigan :slight_smile:

Which Rpi are you using?
Rpi3b+ can boot directly, without sd card. Rpi3b needs to be configured for booting. Search google.