Skip to content

Commit

Permalink
v9.7
Browse files Browse the repository at this point in the history
- DietPi-Patches | Fix kernel version info on NanoPi 5/6 migration, do some safety checks and do the sadly needed re-partitioning, to have the root partition at number 1.
  • Loading branch information
MichaIng committed Aug 22, 2024
1 parent 17b35a9 commit 81b0a52
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions .update/patches
Original file line number Diff line number Diff line change
Expand Up @@ -1789,12 +1789,23 @@ Patch_9_7()
esac
G_AGUP
if G_WHIP_DEFAULT_ITEM='yes' G_WHIP_YESNO '[ INFO ] Major kernel and bootloader upgrade available
\nFor the NanoPi R5S/R5C, we offer a major kernel upgrade to Linux 6.1, based on a new Rockchip kernel source which should provide not only new kernel features, but higher quality as well, compared to the old Rockchip Linux 5.10 legacy kernel.
\nFor the NanoPi R5S/R5C, we offer a major kernel upgrade to Linux 6.6, based on a new Rockchip kernel source which should provide not only new kernel features, but higher quality as well, compared to the old Rockchip Linux 5.10 legacy kernel.
\nAdditionally, compared to the previously hidden kernel image and boot config on the first 7 partitions, the new image and configs will stored and available within the /boot partition, so that kernel command-line parameters can be adjusted. Also kernel headers are available to compile new kernel modules.
\nThis implies flashing a new bootloader image, which reads boot scripts from the root partition.
\nHowever, while we are not aware of any left issues, it is still good to have a backup in place, and we do not enforce the upgrade. You can do it any time later.
\nDo you want to migrate to the new Linux 6.1 kernel now?'
\nDo you want to migrate to the new Linux 6.6 kernel now?'
then
# Safety checks
if [[ $G_ROOTFS_DEV != *'8' ]]
then
G_DIETPI-NOTIFY 1 "Root filesystem is not located on partition 8 as intended, but \"$G_ROOTFS_DEV\" instead. Aborting, please report at: https://github.com/MichaIng/DietPi/issues"
exit 1

elif [[ $(lsblk -no START "$G_ROOTFS_DEV") != 286720 ]]
then
G_DIETPI-NOTIFY 1 "Root partition does not start at sector 286720 as intended, but \"$(lsblk -no START "$G_ROOTFS_DEV")\" instead. Aborting, please report at: https://github.com/MichaIng/DietPi/issues"
exit 1
fi
# Install boot scripts and configs
local dir="../DietPi-Update/DietPi-${G_GITBRANCH//\//-}" # GitHub translates forward slashes into dashes
G_EXEC mv "$dir/.build/images/U-Boot/boot.cmd" /boot/boot.cmd
Expand All @@ -1820,6 +1831,12 @@ Patch_9_7()
G_EXEC_OUTPUT=1 G_EXEC mkimage -C none -A arm64 -T script -d /boot/boot.cmd /boot/boot.scr
# Flash bootloader
/boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc
G_EXEC apt-mark auto firmware-nanopi5
# Redo partitioning
G_DIETPI-NOTIFY 1 'Rewriting partition table to have root filesystem in partition 1'
local rootdrive=$(lsblk -npo PKNAME "$G_ROOTFS_DEV")
G_EXEC parted "$rootdrive" rm 1 rm 2 rm 3 rm 4 rm 5 rm 6 rm 7 rm 8
G_EXEC_OUTPUT=1 G_EXEC sfdisk "$rootdrive" <<< '286720,+' # somehow needed, since above command and '286720,+' somehow create the partition 2015 sectors smaller, resulting in too large filesystem size. Only a subsequent ',+' expands it to the true end of the drive.
fi

elif [[ $G_HW_MODEL == 79 ]] && dpkg-query -s 'firmware-nanopi6' &> /dev/null
Expand All @@ -1832,12 +1849,23 @@ Patch_9_7()
esac
G_AGUP
if G_WHIP_DEFAULT_ITEM='yes' G_WHIP_YESNO '[ INFO ] Major kernel and bootloader upgrade available
\nFor the NanoPi 6 series, we offer a major kernel upgrade to Linux 6.6, based on mainline kernel sources which should provide not only new kernel features, but higher quality as well, compared to the old Rockchip Linux 5.10 legacy kernel.
\nFor the NanoPi 6 series, we offer a major kernel upgrade to Linux 6.1, based on mainline kernel sources which should provide not only new kernel features, but higher quality as well, compared to the old Rockchip Linux 5.10 legacy kernel.
\nAdditionally, compared to the previously hidden kernel image and boot config on the first 7 partitions, the new image and configs will stored and available within the /boot partition, so that kernel command-line parameters can be adjusted. Also kernel headers are available to compile new kernel modules.
\nThis implies flashing a new bootloader image, which reads boot scripts from the root partition.
\nHowever, while we are not aware of any left issues, it is still good to have a backup in place, and we do not enforce the upgrade. You can do it any time later.
\nDo you want to migrate to the new Linux 6.6 kernel now?'
\nDo you want to migrate to the new Linux 6.1 kernel now?'
then
# Safety checks
if [[ $G_ROOTFS_DEV != *'8' ]]
then
G_DIETPI-NOTIFY 1 "Root filesystem is not located on partition 8 as intended, but \"$G_ROOTFS_DEV\" instead. Aborting, please report at: https://github.com/MichaIng/DietPi/issues"
exit 1

elif [[ $(lsblk -no START "$G_ROOTFS_DEV") != 286720 ]]
then
G_DIETPI-NOTIFY 1 "Root partition does not start at sector 286720 as intended, but \"$(lsblk -no START "$G_ROOTFS_DEV")\" instead. Aborting, please report at: https://github.com/MichaIng/DietPi/issues"
exit 1
fi
# Install boot scripts and configs
local dir="../DietPi-Update/DietPi-${G_GITBRANCH//\//-}" # GitHub translates forward slashes into dashes
G_EXEC mv "$dir/.build/images/U-Boot/boot.cmd" /boot/boot.cmd
Expand Down Expand Up @@ -1869,6 +1897,13 @@ Patch_9_7()
G_EXEC_OUTPUT=1 G_EXEC mkimage -C none -A arm64 -T script -d /boot/boot.cmd /boot/boot.scr
# Flash bootloader
/boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc
G_EXEC apt-mark auto firmware-nanopi6
# Redo partitioning
G_DIETPI-NOTIFY 1 'Rewriting partition table to have root filesystem in partition 1'
local rootdrive=$(lsblk -npo PKNAME "$G_ROOTFS_DEV")
G_EXEC parted "$rootdrive" rm 1 rm 2 rm 3 rm 4 rm 5 rm 6 rm 7 rm 8
G_EXEC_OUTPUT=1 G_EXEC sfdisk -N1 "$rootdrive" <<< '286720'
G_EXEC_OUTPUT=1 G_EXEC sfdisk -N1 "$rootdrive" <<< ',+' # somehow needed, since above command and '286720,+' somehow create the partition 2015 sectors smaller, resulting in too large filesystem size. Only a subsequent ',+' expands it to the true end of the drive.
fi
fi

Expand Down

0 comments on commit 81b0a52

Please sign in to comment.