Loxberry on USB Hard-drive or SSD

A Loxberry installation on a USB hard-drive or SSD provides a more robust environment for running the device. Specifically, if the Loxberry is used for statistics gathering (eg. Node-Red/Influx/Grafana), the USB Hard-drive or SSD will tolerate far more write cycles and store more data than a typical SD Card. There can also be an increase in responsiveness within the Loxberry, depending upon the speed of the attached device.

The following guide is written from the experience with a Raspberry Pi 3B. Other models may vary in requirements. Please discuss any variations at the following link -

Table of Contents

New Loxberry image or transfer Existing Loxberry image to Hard-drive/SSD

1. New Loxberry - On your desktop computer, you will have already copied the Loxberry image to the SD-Card as descibed in the link Installation of Loxberry. Carry out the installation as per the guide and conduct the initial Loxberry setup including the first reboot. Also copy the Loxberry image using Win32DiskImager to the USB hard-drive or SSD.

2. Existing Loxberry - Install the Loxberry plugin called Loxberry Backup. Make a DDZ backup to any removeable device. Remove the device and extract the .gz file on a desktop computer. Following extraction, you should have a file called -

loxberry-ddz-backup-yyyymmdd-hhmmss.img

Now follow the initial directions at step 1 above, but instead of downloading the original Loxberry image in that guide, use Win32DiskImager to write your ddz image to the USB hard-drive or SSD. 

 

At the completion of steps 1 or 2, you will have two near identical images of the Loxberry -

a. One residing on the SD card in the Loxberry, and

b. One residing on an external USB hard-drive or SSD,

Plug the external USB hard-drive/SSD into the Rapsberry Pi before continuing.

Modify Boot Sequence to use the External Drive

A script is used to modify booting parameters. Full details of the script can be found in the link -

The attached file (usb-boot.zip) contains everything required. Download the zip file and extract to the desktop. There are 4 required files contained therein -

mbr2gpt

sdc-boot

set-partuuid

usb-boot

 

Login to the Loxberry File Manager, enter the Secure PIN and upload the 4 files -   

 

 

 

Confirmation of the file transfers will be visible in the list pictured -



We now need to leave the web-GUI and access the Loxberry via an alternative means.

Accessing the Loxberry Shell

1. To run the necessary commands, we need to access the 'SSH-/Console-Login'. A preferred option is to use the program 'PuTTY'. Log in to the Loxberry using the 'PuTTY Configuration' tool, set with the appropriate IP address, then select 'Open'. You will need the Credentials file from the initial installation of the Loxberry ('SSH-/Console-Login' password and 'root Superuser' password etc.).



2. Login to the shell as 'loxberry' (assuming unchanged from defaults 1.), with the appropriate 'SSH-/Console-Login' password (2.). Then change to root login using the command su - (3.), followed by the 'root Superuser' password (4.).



Installing the Boot Script

3. Change the directory with the following command at the prompt root@loxberry:~#

cd /opt/loxberry

 

4. Carry out the command to run the script -

bash usb-boot

5. A message will appear -

gdisk not installed

Ok to install gdisk (y/n)? - Select y to continue.

 

6. Use SD card to boot the USB device (recommended) - Yes - Press Enter



7. Select the USB mass storage device to boot - Press the SPACE BAR and an asterisk will be placed between the brackets, then press Enter

 

8. Replicate BOOT/ROOT contents from /dev/mmcblk0 to /dev/sda? Select No and then press Enter

9. A message will be displayed -

Warning - SD card (/dev/mmcblk0) and USB device (/dev/sda) have the same PARTUUID : SD card will boot instead of USB device

Ok to change PARTUUID on USB device (/dev/sda) (y/n)

Select y to change PARTUUID

 

NOTE - For ongoing use of the Loxberry, the SD CARD must remain in place to boot the USB device.



10. Reboot the Loxberry (type reboot at the prompt) and wait about 5 minutes before attempting to log back in via a browser at the Loxberry IP address.

 

Upon logging in, you will see two alternatives -

 

a. For New Loxberry images, the login will revert to defaults (Username - loxberry, Password - loxberry) and the first screen appearing will be 'Welcome to Loxberry". This is confirmation that the Raspberry Pi has booted into the USB device. Normal setup procedures will need to be carried out again, including through the first reboot.

b. For Existing Loxberry images, the first screen appearing will be the normal Plugins page.

Expanding the Image to the Hard-Drive/SSD

11. From the System Settings screen, select My Loxberry -

Select System Information and scroll down to Filesystem Mounts -





The entry /dev/root will indicate 99% Percent Used. We now need to leave the web-GUI and return to PuTTY to expand the Loxberry image to fill the hard-drive. The next action will decrease the Percent Used significantly.



12. Login to the Loxberry shell as root, using PuTTY as per the directions in step 2 above.

 

13. At the prompt root@loxberry:~# enter the following command -

fdisk -l



Note the Disk information for /dev/sda. This should match the size you expect for your hard-drive or SSD. Make a note of the 'Boot Start' value for the /dev/sda2 partition. 

 

14. At the prompt root@loxberry:~# enter the following command -



By pressing 'p' and 'Enter', the current partition table is displayed -

The partition '/dev/sda1' (the first partition of type “W95 FAT32”) must not be changed. It is used to boot the system and must not be deleted.

15. We now delete the second partition (sda2) with 'd' and '2' -



16. Now the same partition is created again with 'n'. The underlying data will not be affected by deleting, then re-creating the partition.

Select 'p' for primary partition and select Partition number '2'.

 

***ATTENTION***: The First sector of partition 2 needs to be specified. Enter the value noted earlier (here "94208") and do not accept the default!

 

17. The Last sector of partition 2 needs to be specified. Simply press 'Enter' to use the default value indicated. This value will utilise the full amount of disk space.

The message "Partition #2 contains a ext4 signature" may be displayed. Answer 'N' for No.

 

18. Now save the information with 'w' -



19. The system must now be restarted with the command -



Give the Loxberry a few minutes to reboot, then log back in via PuTTY as root (ie. su -).



20. At the prompt, type the command -



The resize will take some minutes with no indication of progress until the shell prompt re-appears.

 

 Success!



Now reboot the Loxberry with the command -



21. After a few minutes, log back into the Loxberry web-GUI (via a browser at the Loxberry IP address).

From the System Settings screen, select My Loxberry -

Return to System Information and scroll down to Filesystem Mounts -

The 'Percent Used' will now reflect the true space available on the hard-drive or SSD.

Enjoy your hard-drive/SSD Loxberry installation.



Note - all credit to the section relating to Partition resizing goes to -