expand automatically partition and reboot

Ask questions about Arch Linux ARM. Please search before making a new topic.

expand automatically partition and reboot

Postby mattblack » Mon Feb 14, 2022 11:54 am

Hi all!

As per title, I am adding my config to an archlinux arm aarch64 image and trying to repack it so I can install it on multiple raspberrypi.

In order to save space with the image, I shrink it, so when I flash it with dd or balenahatcher the root partition has only few free MBs and some stuff is not starting, to avoid this I am trying to expand the partition automatically on the first boot.

To achieve my goal I took inspiration from the raspberryPiOS repo where they do have an init_resize.sh that is used on the very first boot instead of starting systemd.

I took the shell script, I dropped the NOOBS bit and adjusted it accordingly (https://github.com/MattBlack85/astroarc ... _resize.sh) and the resize + fs expansion seems to work pretty well, the only thing I can't achieve is a reboot after the script is done.

I understand systemd is not started and I can't use a clean reboot, but shouldn't $this->bbcode_second_pass_code('', 'reboot -f') just work?

These are the errors I get:
$this->bbcode_second_pass_code('', '
Reboot failed -- system halted
')

Is there a clean solution to achieve this goal?

PS: I also tried $this->bbcode_second_pass_code('', 'echo b > /proc/sysrq-trigger') with the same exact result and a clean reboot without -f, but the latter fails and the kernel panics cause systemd is not active
mattblack
 
Posts: 8
Joined: Fri Feb 11, 2022 11:36 am

Re: expand automatically partition and reboot

Postby andiling » Wed Feb 16, 2022 7:26 pm

I'm not having an automated script since I am coming across such situation seldom.
But I'm creating daily an image of my system as backup where the root partition is smaller (for the boot partition it makes no sense to me since it is very small anyways).

In case I need to restore from backup I am flasing this image to a sd card and boot. Later then I use fdisk to delete the root partition and create it again with the proper size keeping ext4 signature. Afterwards I'm using resize2fs. All works with the root partition mounted rw - quick'n dirty.

Maybe you can write a script following this...
andiling
 
Posts: 68
Joined: Sun Mar 06, 2016 8:34 pm

Re: expand automatically partition and reboot

Postby mattblack » Mon Feb 21, 2022 12:46 pm

I went with the easiest option which is a live resize using growpart +resize2fs on the first boot enabling a oneshot service :) seems to work pretty well
mattblack
 
Posts: 8
Joined: Fri Feb 11, 2022 11:36 am


Return to User Questions

Who is online

Users browsing this forum: No registered users and 5 guests