Raspberry to run resin.io from Hard disk

After numerous update push (yes … I am a resin newbie), I destroyed yet another SD card, so I want to try running resin on the Raspberry, from a PiDrive. I was wondering if someone already tried?

So, if you have any tips or working script to share, you are welcome. Otherwise, my PiDrive is underway, and I will try to migrate using the Adafruit script … modify it as, aside /boot, there are 5 other partitions to move and reconfigure :wink: …and post it here when under control. Any interest from the community fro that type of solution? If so, have a look at WDlabs solution for Raspberry (zero, compute, 3 …)

1 Like

Quick Update, but no solution still :frowning:

I copied resin.img on SD and on HD, and modified the cmdline.txt on SD boot partition to point root=/dev/sda2
It seems to boot correctly, register on the portal, then it loops on the portal with the following messages:

02.02.18 18:21:52 (+0100) Downloading application 'registry2.resin.io/smartcan/431af0b92f06fe25854f715e5c16a7050bc3c4e0
02.02.18 18:26:46 (+0100) Failed to download application ‘registry2.resin.io/smartcan/431af0b92f06fe25854f715e5c16a7050bc3c4e0’ due to ‘failed to register layer: Error processing tar file(exit status 1): write /usr/local/luajit/lib/libluajit-5.1.so.2.1.0: no space left on device’

I have no clue what can be the issue… still searching… sorry, but if you have any tips to share, don’t hesitate;-)

What is the boot sequence? Where is the fstab???

Already found resin-raspberrypi/layers/meta-resin-raspberrypi/recipes-support/hostapp-update-hooks/files/99-rpi-bootloader which will be modify (script, I think, used to switch between images):
It implements explicit SD partition swap ( between /dev/mmcblk0p2 and /dev/mmcblk0p3 ) and just swapping 2 and 3 :frowning: . I proposed a mod on github.

… but is there a fstab file? (I found 12 in running image) and is there a first boot script to expand partitions? I continue searching for a full working scenario with my PiDrive

The problem with your setup is pretty hard to fix: you will be having two devices with each having the same file system labels. Basically there will be two resin-rootA, two resin-boot etc. This is a very bad idea because it will race at runtime when mounting them. I would recommend you to look into raspberrypi USB boot. That’s what you are actually interested in and would be the cleanest solution. Otherwise you can try a hack where you keep the boot partition only on sd (and remove all the others) and the exactly opposite on the HDD.

@agherzan, thanks for your reply.

OK, if this is the problem, it is easy to fix:

  • USB Boot (but not reversible)
  • Having only the /boot on the SD card, and reformatting the resin-boot on HD. (Easily done on any computer as this partition is FAT)

Do you think it is enough to run from HD? As I said, I found explicit reference of /dev/mmcblk0p2 and 3 (resin-rootA and resin-rootB), so I think code needs some modification, even if running in USB boot mode. As this beeing evaluated and planned into some next releases?

By experience, Raspberry SD cards have a limited lifespan … specifically when developing and pushing new releases … A HD is for me a must if you want to be running as IoT device :wink:

It will definitely need some changes. We have an issue raised on this but it was not picked up until now - See Unifying all devices onto using resin-rootA/rootB for root partition · Issue #918 · balena-os/meta-balena · GitHub . This will be transferred to resin-raspberrypi repository. If you have time and want to invest a little in this, we are welcoming patches.

@agherzan, I am IN to help you on that, offcourse!
I don’t know if I can already do something now, otherwise, ping me when something is ready for alpha/beta testing and if I will do my best to get this enhancement integrated ASAP :wink:

I can edit /boot/commandline.txt to start with, but I will need some guidance to get it done or help on your github?!?

I checked a little the code and it seems that we don’t make any assumptions in the OS so the only place this is actually used is in the cmdline after all. This is where we set it: https://github.com/resin-os/resin-raspberrypi/blob/a1203d6e20758146d025a17979e0a6e13cebc745/layers/meta-resin-raspberrypi/recipes-kernel/linux/linux-raspberrypi_%.bbappend#L8 . We need to change that into using LABEL=resin-rootA. The os already handles this kind of argument in the initramfs (https://github.com/resin-os/meta-resin/blob/master/meta-resin-common/recipes-core/initrdscripts/files/rootfs#L34). So booting should be fixed only by changing the root argument in cmdline.

The second part that needs working is switching the partition to the next root label updating the OS. That is handled in https://github.com/resin-os/resin-raspberrypi/blob/a1203d6e20758146d025a17979e0a6e13cebc745/layers/meta-resin-raspberrypi/recipes-support/hostapp-update-hooks/files/99-rpi-bootloader . Currently it uses block devices to switch the root. We will need to modify that by finding the label of the partition mounted in sysroot and use that when seding cmdline.

Hope this gives you enough to try something.

1 Like

Here is an example that should be very similar to what we want to achieve here but used for grub configuration files: https://github.com/resin-os/meta-resin/blob/master/meta-resin-common/recipes-support/hostapp-update-hooks/files/99-resin-grub#L17 .

OK, thanks for all infos, it is clearer, I have 3 focal points (Boot with Partition Label, resize Data Partitiona dn switch root partitions).

I did a first quick test for step 1, so copyed the full image on HD, reformatted resin-boot, and copy/modified files from resin-boot on a FAT formatted (named resin-boot) SD card. new cmdline.txt:

dwc_otg.lpm_enable=0 console=null root=PARTLABEL=resin-rootA rootdelay=5 rootfstype=ext4 fsck.repair=yes rootwait vt.global_cursor_default=0

But, it doesn’t boot! So, as of now, still looking to get it working this way (was OK with root=/dev/sda2 ), but would not be uniform so still searching…

… Oups correct cmdline.txt should be:

dwc_otg.lpm_enable=0 console=null root=LABEL=resin-rootA rootdelay=5 rootfstype=ext4 fsck.repair=yes rootwait vt.global_cursor_default=0

I submitted 2 pull request on github, but will have to fix last issues to be fully fonctionnal. Now: boot and root partition switching would be using unified notations / partition labels.

(Have been misled by PartUUID and UUID exemples, sorry!)

Issue 2: resin-data is NOT expanded:

/dev/sda6 960M 756M 138M 85% /mnt/data

It is https://github.com/resin-os/meta-resin/blob/master/meta-resin-common/recipes-core/initrdscripts/files/resindataexpander which is used for that, no? … But I cannot find it … nothing left in inittab

… But Step 1 is OK … it boot … I continue :wink:

@agherzan I am still trying to get it 100% to work, but I am blocked with the resin-data partition expansion!!!

Maybe you can give me a clue concerning the sequence? How and when is the resin-filesystem-expand launched? Can I find some boot log somewhere?

When I try to launch it on the Host, the partition is mounted, so it cannot expand it! :frowning:

Thank you again, Henry

PS: I re-submitted both modifications on Github, waiting for validation.

@theonlyzby So currently you have the board running but the data partition is not expanded, right?

When you expand a partition you have two parts: you need to extend the partition and afterwards resize the file-system. The partition part is done in initramfs: https://github.com/resin-os/meta-resin/blob/master/meta-resin-common/recipes-core/initrdscripts/files/resindataexpander . This uses parted to extend the partition to the end of the device. The partition expand is done as a systemd service https://github.com/resin-os/meta-resin/blob/master/meta-resin-common/recipes-support/resin-expand/resin-filesystem-expand/resin-filesystem-expand.service . This runs a script which does the resizing. As well it has a Before on resin-data.service to make sure that the data partition is mounted after the resizing is done.

Hopefully this gives you enough info to start investigating on the roots of the problem.

But the systemd service calls resin-filesystem-expand which is this one, no? https://github.com/resin-os/meta-resin/blob/master/meta-resin-common/recipes-support/resin-expand/resin-filesystem-expand/resin-filesystem-expand

So it only expands partition #6 (resin-data) but not partition #4 (extended partition that includes resin-data) so … it blocks the process … at least when achieved on the HD … seems :frowning:

https://github.com/resin-os/meta-resin/blob/master/meta-resin-common/recipes-core/initrdscripts/files/resindataexpander expands both the extended partition (4th) and the data partition (6th).

Agree, but I cannot find this file on my Rasp, the only expanding script is the resin-fielsystem-expand (also the one launched into systemd service is this one: https://github.com/resin-os/meta-resin/blob/master/meta-resin-common/recipes-support/resin-expand/resin-filesystem-expand/resin-filesystem-expand which only tries to expand partition resin-data ( #6)
or do I miss something??? … I am confused

1 Like

I’m highly interested in this, as shown on:

Hi @daghemo @theonlyzby,

Would it be possible for you to set up a device where this issue is reproduced (i.e. data partition not expanding while the device has booted from usb) , and then grant support access to the device so that we can have a look?

@lekkas Yes! Just let me get my hands on another RPi!

Hi @lekkas. I’ve just granted support access to one on my RPis.