Skip to content
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-FS_partition_resize | Reboot once when partprobe failed #4582

Closed
Dtrieb opened this issue Jul 24, 2021 · 4 comments · Fixed by #4724
Closed

DietPi-FS_partition_resize | Reboot once when partprobe failed #4582

Dtrieb opened this issue Jul 24, 2021 · 4 comments · Fixed by #4724
Milestone

Comments

@Dtrieb
Copy link

Dtrieb commented Jul 24, 2021

First Boot on Nano Pi 2 fails.

Get it solved with:

resize2fs /dev/mmcblk0p2

https://dietpi.com/phpbb/viewtopic.php?p=32324#p32324

@Joulinar
Copy link
Collaborator

Hi,

Can you share following

/var/tmp/dietpi/logs/dietpi-firstboot.log
/var/tmp/dietpi/logs/dietpi-firstrun-setup.log
/var/tmp/dietpi/logs/fs_partition_resize.log

@Dtrieb
Copy link
Author

Dtrieb commented Jul 24, 2021

@MichaIng
Copy link
Owner

MichaIng commented Jul 24, 2021

Hmm:

The partition table has been altered.
Error: Error informing the kernel about modifications to partition /dev/mmcblk0p2 -- Invalid argument.  This means Linux won't know about any changes you made to /dev/mmcblk0p2 until you reboot -- so you shouldn't mount it or use it in any way before rebooting.
Error: Partition(s) 2 on /dev/mmcblk0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot now before making further changes.
partx: /dev/mmcblk0: error updating partition 2

So partprobe and partx both failed. I think we should error-handle those and trigger a reboot when failed. Only problem, when to do the filesystem resize then. When starting the same service, there is a change of a boot loop, which is not great either.

Probably we need to split those again, first partition resizing, if informing the kernel fails a reboot, then filesystem resizing. Or a flag file. I need to think about it for v7.5 🤔.

Might be related to the (old) kernel of the NanoPi M2 in particular. That uses S5P4418 SoC, which is not supported by Armbian, so we still use an old (undeveloped) build from FriendlyARM.

@MichaIng MichaIng added the Workaround available 🆗 Workaround is available/has been implemented, but a definite solution should be found when possible. label Jul 24, 2021
@MichaIng MichaIng added this to the v7.6 milestone Sep 1, 2021
@MichaIng MichaIng changed the title First Boot on Nano Pi 2 fails. DietPi-FS_partition_resize | Reboot once when partprobe failed Sep 1, 2021
MichaIng added a commit that referenced this issue Sep 10, 2021
+ CHANGELOG | DietPi-FS_partition_resize: On first boot, DietPi automatically expands the root partition and filesystem to cover the full disk size. In some circumstances, e.g. on older kernel versions, it may happen that the two used commands "partprobe" and "partx -u" fail to inform the kernel about the changed partition table and hence the filesystem is not expanded. In such case, the system is now rebooted automatically once to assure that the new partition table is loaded and the filesystem is then expanded. This change affects only new images with contain DietPi v7.6 already, since this expansion is done before DietPi updates itself. Many thanks to @Dtrieb for reporting a case where the filesystem expansion failed: #4582
@MichaIng MichaIng added Solution available 🥂 Definite solution has been done Testing/testers required 🔽 and removed Workaround available 🆗 Workaround is available/has been implemented, but a definite solution should be found when possible. Investigating 🤔 labels Sep 10, 2021
@MichaIng
Copy link
Owner

MichaIng commented Sep 10, 2021

Done with: #4724

If either partprobe or partx fails, the system is rebooted and a flag is set to skip the partition resize on next boot. The kernel loads the new partition table, the flag is removed and the filesystem is expanded. I have no system to replicate the issue, but I faked it here by changing the partx call to the invalid partxb:

Removed /etc/systemd/system/local-fs.target.wants/dietpi-fs_partition_resize.service.
Disk /dev/sda: 8 GiB, 8589934592 bytes, 16777216 sectors
Disk model: VBOX HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x32713bac

Old situation:

Device     Boot Start      End  Sectors Size Id Type
/dev/sda1  *     2048 16777215 16775168   8G 83 Linux

/dev/sda1:
New situation:
Disklabel type: dos
Disk identifier: 0x32713bac

Device     Boot Start      End  Sectors Size Id Type
/dev/sda1  *     2048 16777215 16775168   8G 83 Linux

The partition table has been altered.
/var/lib/dietpi/services/fs_partition_resize.sh: line 59: partxb: command not found
Created symlink /etc/systemd/system/local-fs.target.wants/dietpi-fs_partition_resize.service → /etc/systemd/system/dietpi-fs_partition_resize.service.
[ INFO ] Rebooting to load the new partition table
Removed /etc/systemd/system/local-fs.target.wants/dietpi-fs_partition_resize.service.
resize2fs 1.46.2 (28-Feb-2021)
The filesystem is already 2096896 (4k) blocks long.  Nothing to do!

MichaIng added a commit that referenced this issue Sep 10, 2021
+ DietPi-FS_partition_resize | Reboot to load new partition table if partprobe or partx fail
+ DietPi-FS_partition_resize | Append output to log file instead of overwriting it, since it may run twice now, when partprobe or partx failed on first boot
+ CHANGELOG | DietPi-FS_partition_resize: On first boot, DietPi automatically expands the root partition and filesystem to cover the full disk size. In some circumstances, e.g. on older kernel versions, it may happen that the two used commands "partprobe" and "partx -u" fail to inform the kernel about the changed partition table and hence the filesystem is not expanded. In such case, the system is now rebooted automatically once to assure that the new partition table is loaded and the filesystem is then expanded. This change affects only new images with contain DietPi v7.6 already, since this expansion is done before DietPi updates itself. Many thanks to @Dtrieb for reporting a case where the filesystem expansion failed: #4582
@MichaIng MichaIng mentioned this issue Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants