Resizing embeded version on first boot - ARM64 custom images

Started by none, April 01, 2025, 03:43:18 PM

Previous topic - Next topic
Quote from: franco on April 04, 2025, 02:42:57 PM> so even in the nano image the the resizing is not working?

Says you? Last time I checked it worked, which was 25.1...

No, please don't get me wrong. I misunderstood your post, so I asked to be sure. I thought you were saying that was not working anymore, and now I see I got it wrong.

You said earlier it worked for you on amd64 and as I read it I got confused, as if you had tested again and said was not working anymore. Sorry for the noise :(

I just was trying to get something to compare and have a starting point. And now I have it. Thanks again.

none
"We will call you Cygnus,
the God of balance you shall be."

Ok, thanks for clearing that up. I will test Nano for business 25.4 images again early next week anyway and promise to report back.


Cheers,
Franco

Hi Franco,

I got to walk a few steps here, here is the result.

I found that the line:

        local IDX=${1##"${DEV}p"}
in /usr/local/etc/rc was returning a value that would make the next "if" always be true:

        if [ "${IDX}" = "${1}" ]; then
                # assume schema ada0a used by nano images
                IDX=1
        fi
This way when disks configured as MBR, as is the case here, would always default to IDX=1 and make it to the next "if":

       if [ -n "${DEV}" -a "${DEV}" != "${1}" -a \
            -n "${IDX}" -a "${IDX}" != "${1}" ]; then
                gpart recover ${DEV}
                gpart resize -i ${IDX} ${DEV}
       fi

issuing gpart resize on a partition that has no place to grow (and not the root one, also). The partitions here are organized like this:

gpart show da11
=>      63  61069249  da11  MBR  (29G)
        63    131009        - free -  (64M)
    131072     65536     1  fat32lba  [active]  (32M)
    196608   6094848     2  freebsd  (2.9G)
   6291456  54777856        - free -  (26G)
Just as the default opnsense scripts build. Running on index 1 would not meet the premise for the growfs step that follows, and then get that message saying it already has the desired size.

For the Nano image that would do fine, as it has only 1 partition, the BSD scheme is written directly on the device, no MBR or GPT is created.

To address this I created a test to know if it is a MBR scheme, and then act accordingly. That way it finds the index for the root file system and the gpart resize step works.

Now I got a message from gpart tellimg me I need to do a commit to the UFS label (my case was ufs/OPNsense. Not doing that would ruin the boot:

mmcsd0 recovering is not needed
GEOM_PART: ufs/OPNsense was automatically resized.
  Use `gpart commit ufs/OPNsense` to save changes or `gpart undo ufs/OPNsense` to revert them.
mmcsd0s2 resized

That step is outside the grow_partition(), and later I found was not welcome on AMD64 Nano image (may be arch related?). I then created another test to run only on MBR schemes.

My skills here are far from yours and the opnsense team. Here is the file I ended with, I hope my humble time here can help anyhow.

My tests here are also limited. Nano images works as is now and keeps working after the modifications. ARM64 images now work in the first boot. I just need to learn how to commit changes to the local repo, so images will have it out-of-the-box either.

Thanks for the help, as usual :)

The dmesg from that part is:

Booting [/boot/kernel/kernel]...               
Using DTB provided by EFI at 0xef03c000.
����#U}�qqC��� ����!����*���mu��������k�饭�9� ���5������j�j�����������)��y��i*���Ovq4�y���,�J�uQ�����4����+��������몋���
                                                                                                                        ���8�q����i*���
                                                                                                                                       +�v����J��:u�Ѩ��V[]����U8��x��y>k�8�ռy�Ѫ��i�d���i�����.�����8;�u�+����+�ꪨ�,���+���ʊ�����ʊ���+��v�����+��)�ź����*�����l�"�)��᪩��0���uW�S�I+��4��{qɩ��J����+���0��9},����e����Q���}����..��Y��0�ټ�.�g�����+�}���*�����(��k��W;�+*���<�ܑ����������y�J�h������"�(����(��J��$��b*��,��٩���9��ը�����3 �����q�WS[�mq=1>Q2ը��.��z����>A�Y�q5��q��W�騤�ɪ�`�ѤY�Q1QA��8��m+�+��,���m�����)������"�������ъ(�#��������r�*�u�u���������f+����U1��*�b���0�������������+���q�t�9���%��Z�ᩴu�]T���ԼQWI�QS����]�8<������2��*�S�*��j�r��������n�*�j�*[TWS�>��<�,����K
                                                                                                                                                                                          �++��Y)����,(�誶��$�+���uNJ�ي+k����;z���J�������;��գ��ű��
    ����Y�?�����՜u������q���������Y8����񱁙�����(�����a����ɛ�Q:��(���������**�ͣ�����f���Q�Z��銊�����9x��+��e.������       ~qq���z��!��**+���$����(��8x�ዧ������}��(���Ț�Z�)���������动���::I�����1::I�Ŋ�:����!::�����*��8
                                                                                                                                                                                                                     ������uhub0: 1 port with 1 removable, self powered
uhub3: 1 port with 1 removable, self powered
uhub2: 2 ports with 2 removable, self powered
uhub5: 2 ports with 2 removable, self powered
Mounting filesystems...
tunefs: soft updates remains unchanged as enabled
uhub1: 1 port with 1 removable, self powered
uhub4: 1 port with 1 removable, self powered
camcontrol: cam_lookup_pass: CAMGETPASSTHRU ioctl failed
cam_lookup_pass: No such file or directory
cam_lookup_pass: either the pass driver isn't in your kernel
cam_lookup_pass: or mmcsd0 doesn't exist
mmcsd0 recovering is not needed
GEOM_PART: ufs/OPNsense was automatically resized.
  Use `gpart commit ufs/OPNsense` to save changes or `gpart undo ufs/OPNsense` to revert them.
mmcsd0s2 resized
super-block backups (for fsck_ffs -b #) at:
 6402432, 7682880, 8963328, 10243776, 11524224, 12804672, 14085120, 15365568,
 16646016, 17926464, 19206912, 20487360, 21767808, 23048256, 24328704,
 25609152, 26889600, 28170048, 29450496, 30730944, 32011392, 33291840,
 34572288, 35852736, 37133184, 38413632, 39694080, 40974528, 42254976,
 43535424, 44815872, 46096320, 47376768, 48657216, 49937664, 51218112,
 52498560, 53779008, 55059456, 56339904, 57620352, 58900800, 60181248
** /dev/ufs/OPNsense
FILE SYSTEM CLEAN; SKIPPING CHECKS
clean, 6831398 free (94 frags, 853913 blocks, 0.0% fragmentation)
Setting hostuuid: 00000000-0000-0000-eb8b-ff6f21811d36.
Setting hostid: 0x5f653895.
>>> Invoking import script 'importer'
Press any key to start the configuration importer: .......
Bootstrapping config.xml...done.


FreeBSD/arm64 (OPNsense.localdomain) (ttyu1)

login: root
Password:
------------------------------------------------
|       Hello, this is OPNsense 25.1           |           :::::::.
|                                              |           :::::::::.
|  Website:     https://opnsense.org/          |        :::        :::
|  Handbook:    https://docs.opnsense.org/     |        :::        :::
|  Forums:      https://forum.opnsense.org/    |        :::        :::
|  Code:        https://github.com/opnsense    |         `:::::::::
|  Reddit:      https://reddit.com/r/opnsense  |           `:::::::
------------------------------------------------

*** OPNsense.localdomain: OPNsense 25.1.3_33 (aarch64) ***

 LAN (re0)       -> v4: 192.168.1.1/24
 WAN (re1)       ->

 HTTPS: sha256 2B 47 72 39 88 B9 32 31 2F 65 59 19 61 F6 85 76
               08 19 F7 E9 39 34 18 F8 97 70 A1 58 50 46 2C 41

  0) Logout                              7) Ping host
  1) Assign interfaces                   8) Shell
  2) Set interface IP address            9) pfTop
  3) Reset the root password            10) Firewall log
  4) Reset to factory defaults          11) Reload all services
  5) Power off system                   12) Update from console
  6) Reboot system                      13) Restore a backup

Enter an option: 8

root@OPNsense:~ # df -h
Filesystem                   Size    Used   Avail Capacity  Mounted on
/dev/ufs/OPNsense             28G    2.0G     24G     8%    /
devfs                        1.0K      0B    1.0K     0%    /dev
/dev/msdosfs/MSDOSBOOT        32M    832K     31M     3%    /boot/msdos
devfs                        1.0K      0B    1.0K     0%    /var/dhcpd/dev
devfs                        1.0K      0B    1.0K     0%    /var/unbound/dev
/usr/local/lib/python3.11     28G    2.0G     24G     8%    /var/unbound/usr/local/lib/python3.11
/lib                          28G    2.0G     24G     8%    /var/unbound/lib
"We will call you Cygnus,
the God of balance you shall be."