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!
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?
[Solved] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?
Last edited by kly on 2023-01-27 21:11, edited 1 time in total.
-
- Emeritus
- Posts: 2435
- Joined: 2010-12-07 19:55
- Has thanked: 14 times
- Been thanked: 54 times
Re: [Software] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?
Have you also asked Raspberry Pi Forums - Debian? https://forums.raspberrypi.com/viewforum.php?f=50
Re: [Software] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?
I've posted over there now. Thank you!
-
- Global Moderator
- Posts: 2639
- Joined: 2018-06-20 15:16
- Location: Colorado
- Has thanked: 41 times
- Been thanked: 192 times
Re: [Software] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?
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.
-
- 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?
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.
Re: [Software] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?
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.
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.
Re: [Software] Is anyone familiar with the way the Debian Raspberry Pi images extend the root partition on first boot?
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.
-
- 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?
Thanks for the feedback.
Up to you, by editing the original post subject.