RichardMidnight / pi-safe

Create your own custom image files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

auto-expand of file system on restore stuck in a reboot loop because of overlay file system

steve-71 opened this issue · comments

discovered an issue where I backed up a system which was configured with overlay file system and read-only boot partition, it shrank it and when I restored it to a new SD Card it tried to auto-expand the filesystem to the media size, rebooted and then tried to expand again.. I couldn't figure out how to get out of this loop, so backed it up again but deselected auto-expand, then the restored image booted correctly.
I could then expand the filesystem after manually disabling the overlay filesystem and read-only partition.
Probably just needs a mention/caution in the docs, or if you can advise how to break out of the reboot loop I'll reproduce the issue.

Steve-71,
Thanks for the info on the issue. I just added a note to the TIPS section of the online readme.md saying that auto-expand does not support read-only root partitions. I am wondering if I can detect this and notify the user. Can you tell me more about your file system? Can you run "sudo parted -l" in a terminal and show me the results?

"parted -l" output as requested below:

pi@raspberrypi:~ $ sudo parted -l
Model:  USB  SanDisk 3.2Gen1 (scsi)
Disk /dev/sda: 15.4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
 1      4194kB  273MB   268MB   primary  fat32        lba
 2      273MB   15.4GB  15.1GB  primary  ext4

Any clues there?
Steve

Did a diff between the /boot/config.txt files and there's this line at the end of the one that's using the overlay filesystem:

initramfs initrd.img-5.10.63-v7l+-overlay

and did a comparison of the /boot/cmdline.txt and the non-autoexpanding one says:

boot=overlay console=tty1 root=PARTUUID=fb514052-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

while the normal one omits the boot=overlay part, haven't found where it mounts the boot partition read-only yet.
Steve

Thanks,
No clues in the fdisk output. That is normal. The fact that the last partition is primary/ext4 means it can likely be shrunk. You are on the right track trying to figure out where it loads the overlay system as read-only. What is your hardware and OS including ver? Is this a stock configuration or specialized?
Richard

The beta version has new features which shows some details about the media including estimates on final image size. You can try the beta, then Tools, Analyze and point to your media. To revert to the published version, just install it over the beta.
Richard

OS details according to pisafe:
Raspbian GNU/Linux 10 (buster) hw=armv7l kernel=5.10.63-v7l+
Details from dmesg:

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.10.63-v7l+ (dom@buildbot) (arm-linux-gnueabihf-gcc-8 (Ubuntu/Linaro 8.4.0-3ubuntu1) 8.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #1459 SMP Wed Oct 6 16:41:57 BST 2021
[    0.000000] CPU: ARMv7 Processor [410fd083] revision 3 (ARMv7), cr=30c5383d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
[    0.000000] OF: fdt: Machine model: Raspberry Pi 4 Model B Rev 1.4

it's Raspberry PI OS Lite (32 bit) according to the Raspberry PI Imager, then update/upgrade'd, so nothing really special going on afaik. I use sudo raspi-config performance settings to turn on the overlay filesystem/read only boot partition so it can be power-cycled without shutdown.

I'm installing the beta of pisafe and try that out; thanks.

Thanks, I will look into how the raspi-config overlay filesystem works.

I believe it is the ',ro' (read only) on the two lines in the /etc/fstab file. I still need to confirm.

proc /proc proc defaults 0 0
PARTUUID=fb0d460e-01 /boot vfat defaults,ro 0 2
PARTUUID=fb0d460e-02 / ext4 defaults,noatime,ro 0 1

OK, I did some investigating and updated the beta to recommend turning off auto-expand if it detects an overlay. It is NOT fully tested but seems to work.
The overlay setting seems to be detectable by looking at the /boot/cmdline.txt as you indicated.
The read-only setting seems to be detectable by looking at the /etc/fstab file, but my quick testing shows that is not the problem.
Thanks again for the heads up on the situation

I've tested the new beta; the warning and default of turning off auto-expand works well.
Many thanks for the quick response and fix, most appreciated.