Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
kly
Posts: 4
Joined: 2023-01-12 21:02

[Solved] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?

#1 Post by kly »

A little background:
For years I've been creating customized images of Raspbian/Raspberry Pi OS for use in a production environment, but now I'm attempting to do this with vanilla Debian to minimize the amount of bloat (Even the Raspberry Pi OS lite image has bloat). So I customized a Raspberry Pi microSD card by using debootstrap to install the base system, chrooted into it, installed a kernel, installed raspi-firmware to the boot partition, customized the software, etc.. Like the Debian prebuilt images or Raspberry PI OS images, the partitioning is pretty basic: Just a boot partition with the Raspberry Pi firmware extracted to it, and a root partition with everything else. After plenty of testing everything works great.

The problem:
We have a production environment of about 500 Raspberry Pis in various locations around the world. I need to copy my customized system into an image file so I can dd it to all of the microSD cards for these Pis. With Raspberry Pi OS, I'd set the init_resize.sh and resize2fs_once script (provided with that distribution) to run on the next boot. Then I'd shrink the root file system and change the boundary of its partition to match. Then dd everything up to this boundary to a file and that would be my image. My question is regarding the prebuilt Debian images, how do they go about expanding the root partition and file system on first boot? I briefly searched for this today but didn't find anything yet.

Thank you!
Last edited by kly on 2023-01-27 21:11, edited 1 time in total.


kly
Posts: 4
Joined: 2023-01-12 21:02

Re: [Software] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?

#3 Post by kly »

I've posted over there now. Thank you!

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: [Software] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?

#4 Post by CwF »

kly wrote: 2023-01-13 17:02 I've posted over there now. Thank you!
Thank you for taking to the question to those who might know.
I invite you to post back your solution for general Debian. I'd assume similar scripts would work the same. I use images built and upgraded within vm's and written out to the devices to be installed. In a similar way the vm image is 8.4GB and always installed to a much larger device. I use a single partition so it is simple to expand to device size. I see no reason to complicate the image with multiple partitions and don't use a swap partition, so it's a quick operation.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: [Software] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?

#5 Post by p.H »

kly wrote: 2023-01-12 21:44 My question is regarding the prebuilt Debian images, how do they go about expanding the root partition and file system on first boot?
Check here:
https://salsa.debian.org/raspi-team/ima ... sizerootfs
https://salsa.debian.org/raspi-team/ima ... sizerootfs

The first script is installed in initramfs-tools hook scripts and aims to include everything needed to resize the root partition and filesystem in the initramfs.
The second script is included in the initramfs boot scripts by the former and is executed at first boot (or any boot if not removed ? didn't check) to resize the root partition.
I guess both are self-explanatory enough.

kly
Posts: 4
Joined: 2023-01-12 21:02

Re: [Software] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?

#6 Post by kly »

Thank you for this. I downloaded both files and copied them to their respective folders. Gave root execute permissions on each. Installed parted as I can see it relies on that. Minimized the root filesystem and re-sized its partition to match the new boundary. As a test, booted up on an RPI and still it does not resize the partition and expand the FS.

I again examined one of the downloadable prebuilt Debian images. I did a find on the root partition, and neither of those scripts exist on the image, nor do the SystemD resize scripts they apparently used to use. Also did a recursive grep of the non binary files looking for keywords but didn't really find anything. So at least currently they seem to be doing it some other way. I'll dig a little deeper when I have time.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: [Software] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?

#7 Post by p.H »

Did you update the initramfs after installing the files ?

kly
Posts: 4
Joined: 2023-01-12 21:02

Re: [Software] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?

#8 Post by kly »

Ah, my lack of understanding of initramfs was the problem. Anyway updating it has fixed it and our image expands perfectly now. Thank you everyone for your help! This can be marked as solved now.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: [Software] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?

#9 Post by p.H »

Thanks for the feedback.
kly wrote: 2023-01-27 19:44 This can be marked as solved now.
Up to you, by editing the original post subject.

Post Reply