Datactl help

I have tried to use the datactl feature on hassos but it failed after creating the partition on the SSD I’m using.
It has successfully created a partition named “hassos-data-external”.
However then spat the following error out:
“cat: can’t open ‘/sys/class/block/nvme0n11/size’ : No such file or directory”
Does anyone know why this might be?
If someone can point me in the right direction, I’m quite willing to do a bit of debugging but I definitely need a leg up!

PS my system is as follows:
Pi4 Compute module, on a standard CM4IO dev board with PCIe-M2 adaptor and a PCIe SSD.

PPS I’m a hardware design engineer by trade and drawn up a basic CM4 carrier with M2 slot that I’m just about to send off for manufacture. If I can get the above to work I reckon it would be a nice bit of hardware to run HA on, so if anyone is interested feel free to give us a shout.

Jonathan

I’ve been looking into this, the datactl script generates the new partition path like this:

NEW_DEVICE_PART_SIZE=$(cat "/sys/class/block/$(basename "${NEW_DEVICE_ROOT}")1/size")

resulting in a path “nvme0n11” where it should be “nvme0n1p1”

Would I be correct in saying a change to the line above in datactl to:

NEW_DEVICE_PART_SIZE=$(cat "/sys/class/block/$(basename "${NEW_DEVICE_ROOT}")p1/size")

Would fix my problem?
If so how the hell do I achieve this?

Thanks in advance.

1 Like

Anyone know how I can modify the dataclt script?

1 Like

Same here. I located the file, it is in /usr/bin/datactl.

Changing it is a bit of work due to the squashfs filesystem it is in.

Take your CM4 and connect it to another (linux) system as USB device (jumper to disable eMMC boot is set) using rpiboot

In my case, the only system partition used was sda3

# mount -t squashfs /{dev,mnt}/sda3
# mksquashfs /mnt/sda3 sda3.sqsh.bckp
# umount /dev/sda3
# unsquashfs sda3.sqsh.bckp
# vim squashfs-root/usr/bin/datactl  # add the "p" as you mentioned and save the file
# mksquashfs squashfs-root sda3.sqsh
# dd if=sda3.sqsh of=/dev/sda3 status=progress

You may now remount the partition and double check the file is fixed. If yes, you can unplug the CM4 (don’t forget to unmount), remove the USB cable and jumper, boot normally and execute datactl move. Voila!

I realize that this might arise from the fact that partitions of devices whose names end with digits have a p between device name and partition number. So this might allow a generic fix. I will see if I can drop a PR or similar.

Let me know if it fixed your problem (in case you were still chasing it)

PS: This site (“Basic steps” for the readout part, and “Example 2” for the writing part) helped my in understanding what squashfs commands I had to use.

PR was opened – Let’s see if it gets merged :slight_smile:

1 Like

Well, done on this, I’ll be sure to try it out when I get time. PS I’ve got a sneaky suspicion it will get merged. See the “Home assistant Amber”

We are working on a D-Bus API, which can be used from Supervisor and ultimately from the frontend for the data disk feature. That is what I use to test NVMe on Amber currently:

busctl --verbose call io.hass.os /io/hass/os/DataDisk io.hass.os.DataDisk ChangeDevice s /dev/nvme0n1

That being said, I did merge the PR, still, since datactl is currently still the documented.
There is a set of nightly builds: Index of /7.0.dev20210920

I’ll probably will remove the datactl script at one point when there is UI support for it.

1 Like