-
-
Notifications
You must be signed in to change notification settings - Fork 503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DietPi-Imager | Add option to add FAT partition after rootfs to simplify setup #6602
Conversation
oh, the first commit was needed in order for me to be able to test it on a board that met my criteria... the firstboot would always fail (apparently there is a kernel update and downloading and unpacking this take a LOT of space) |
Ah, another important thing, the actual mount, copy and partition deletion would need to be done here: https://github.com/MichaIng/DietPi/blob/dev/rootfs/var/lib/dietpi/services/fs_partition_resize.sh This script runs before
|
BRILLIANT. That's the piece that was missing. And that explains why the partition didn't get resized. I will change that as well. Depending on a few errands I have to run today you should have an update to the PR within the next 24h |
so this needed a bit more work than your comments might make one believe. |
This is now tested with a both mbr and gpt and seems to work fine. And yes, of course it's a no op when build an image that already has a FAT Anyway, I think this is ready to be merged. |
Definitely. I'd keep it as opt-in in
|
Excellent, I'll add that to the exclusions I already have (which is just the first one) |
A couple of comments while I work on the second change you requested... |
Ok, I think I have once again addressed all the feedback. |
"final" (ha... right...) cleanups to make it look more consistent with the rest. Collapsed into a single commit this is nice and small and tidy now. |
I think this is caused by the recent major kernel upgrade by Armbian, respectively the first APT repo kernel/bootloader package upgrades/syncs since February. Those Linux builds and/or the initramfs' seem to take significantly more space. So yes, let's drop the change here and instead I'll do a test with all images anyway before merging the 7z => xz change, and then raise all rootfs sizes where necessary.
I think it is fine. How high is the chance that someone creates a partition labelled "DIETPISETUP" with a FAT filesystem at the end of the image, not intended for this feature. Let's keep it like that. |
yes, they seem to take something like an extra 150M...
Excellent. I already pushed a commit to this branch that reverts them.
That was my thinking. Excellent. Then I think I have no outstanding tasks here. YAY. |
Sometimes the buids are running out of space when doing a kernel update. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
So far this only handles dos partition tables. When ADD_DOS_PART is set to 1, add a small 4MB fat filesystem as the last partition to this image, and copy the two DietPi config files to this partition. Now even people who don't have access to a Linux system can very easily mount the DIETPISETUP partition, edit the two files and get the setup they want. This is especially important for headless devices connecte via WiFi - where this initial setup is necessary for them to connect to the network in the first place. This commit only creates that new partition. The setup logic still needs to be updated so that it mounts that partition (when present) and uses the config files on that partition instead of the ones provided elsewhere in the image. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is the second part of the logic. If we have the DIETPISETUP partition then copy the dietpi.txt and dietpi-wifi.txt files from there into the /boot directory and delete the DIETPISETUP partition (in order to allow the resizing of the root filesystem to work). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We were checking for the mbr type of 'c'. Instead of checking for that and the GUID for a generic MS data partition, make things easier and just check that it's a vfat filesystem. With that, the 4MB, and the subsequent check for the label this appears to be enough belts and suspenders. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
And collect all the code for this in one spot. Putting this all in one line is of course possible, but also much harder to read, understand, and maintain, IMHO. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Also copy the dietpiEnv.txt file. The others don't appear to have default content, so I just mention them in the readme. Frankly, the text in the readme probably needs some editing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
These were needed for me to be able to test things locally, but don't belong in this PR. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
comparing to dev this removes an odd whitespace change; it also tightens some of the code to be more in line with the rest of the file, and remove some remaining debug output that otherwise just clutters the user experience when manually building an image. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
27686ca
to
4c023fd
Compare
- DietPi-Imager | Turn ADD_DOS_PART env variable into a CLI flag. Do not add the additional partition by default, but only if requested - DietPi-Imager | Coding: Re-use FP_SOURCE_IMG and IMAGE_SIZE variables for adding FAT patition; only raise source image size if required - DietPi-Imager | Copy as well dietpiEnv.txt and optional config/automation files/scripts to setup FAT partition if present - DietPi-FS_partition_resize | Allow FAT setup partitions of any size and only copy files if newer: Reason is that users with a Linux host may have edited/created files on the ext4 partition and we do not want to overwrite these - DietPi-Build | Make skipping the additional FAT setup partition a CLI flag, and pass the new CLI flag to DietPi-Imager - DietPi-Build | When creating multiple image editions for the same device, always remove the added FAT setup partition before booting the system or passing it to DietPi-Imager again - CHANGELOG | Add entry about added FAT setup partition
I did a few changes:
But the two more important changes:
Merging this now, so I am able to test it via GitHub Actions directly. |
Thanks for those changes. For the "user edited files in root partition" my preferred fix would be to store a hash of the unedited file as part of the imaging. The interesting question of course is what to do when neither match 🤷♂️ |
Indeed, the hash would be a safer approach. I'm just a little hesitating to add another 2-3 files to our images and making it another little more complex 😅. I would only check whether the files on the I think for now I'll leave it like it is, expecting not too off system clocks. For the images we generate it is definitely correct, and it is very unlikely that a Windows/macOS system where those images were downloaded to afterwards has a system time from before the image generation, after those images have been flashed. If really someone runs into this issue, we can reconsider. |
Btw, tested it on an OPi 5 Plus, and after I replaced the I was actually hoping that WSL2 will solve this at least for Windows users, but mounting USB devices is not possible without a VirtualHere-like IP based device sharing from Windows host to WSL guest, which requires additional setup within the guest. And even then, mounting SD cards via shared USB device (card reader) is not possible, which means that the most relevant use case for us does not work, and most others are at least difficult, more difficult than spinning up some VMware/VirtualBox VM to mount and edit the USB device. So yes, a great time saver, with no native alternative to expect any time soon. |
I am thrilled that this is working as well as I had hoped. |
Most of them caused by my last commit here, which I merged untested so that I can test via our CI instead 😄. But yep, learned a few things, that also FAT16 has a minimal size above 1 MiB, and that |
@dirkhh: Big thanks for this exciting and valuable feature. I used it many times so far. |
This isn't complete, yet (MBR only, only tested on one board), but I felt that this would be enough to maybe get some feedback on the code and the overall idea for implementation.
What this does right now is that if the corresponding environment variable
ADD_DOS_PART
is set, at image creation time a 4MB DOS partition named DIETPISETUP (yay for 11 character limit) is created at the end of the disk image anddietpi.txt
anddietpi-wifi.txt
are copied onto that partition.During first boot, when such a partition is found, those two files (and ONLY those two files - not sure if that is the right choice, but it seemed better that way) get copied back over the ones that were in the
root
filesystem.This way a user on a Mac or a Windows system can very easily make changes to the settings - I think the most important use case will be wifi setup on headless systems... and then of course fully automated setup.
Again, I'm curious to hear comments about everything. Coding style, decisions about how this is enabled, where I inserted the code, anything. I want to make sure that this is broadly useful and not just a fix for my use case.