Skip to content

Commit e99e867

Browse files
committed
Installer: Fix reinstall with changed kernel (#31)
1 parent 98e19f3 commit e99e867

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ When you need a kernel module that isn't loaded by default, you will still have
262262
> Optional: Create a swap file with `fallocate -l 512M /swap && mkswap /swap && chmod 600 /swap` (example is 512MB) and enable it on boot by appending `/swap none swap sw 0 0` to `/etc/fstab`.
263263
264264
## Reinstalling or replacing an existing system
265-
If you want to reinstall with the same settings you did your first install you can just move the original _config.txt_ back and reboot. Depending on the hardware you want to reinstall on (Raspberry Pi **1** or **2**), make sure you still have _kernel_rpi1_install.img_ / _kernel_rpi2_install.img_ and _installer-rpi1.cpio.gz_ / _installer-rpi2.cpio.gz_ in your _/boot_ partition. If you are replacing your existing system which was not installed using this method, make sure you copy those files in and the installer _config.txt_ from the original image.
265+
If you want to reinstall with the same settings you did your first install you can just move the original _config.txt_ back and reboot.
266266

267267
mv /boot/config-reinstall.txt /boot/config.txt
268268
reboot

scripts/etc/init.d/rcS

+16-1
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,18 @@ echo -n "Copying boot files... "
310310
# copy boot data to safety
311311
mount $bootpartition /boot || fail
312312

313+
if [ -e "/boot/kernel-reinstall.img" ] && [ -e "/boot/kernel7-reinstall.img" ] ; then
314+
echo -e "\n"
315+
echo "=================================================="
316+
echo "== Reinstallation requested. Restoring files... =="
317+
mv /boot/kernel-reinstall.img /boot/kernel.img
318+
mv /boot/kernel7-reinstall.img /boot/kernel7.img
319+
echo "== Done. Rebooting to start installation... ======"
320+
echo "=================================================="
321+
sleep 3s
322+
reboot && exit
323+
fi
324+
313325
cp -r -- /boot/* /bootfs/ || fail
314326

315327
umount /boot || fail
@@ -1350,8 +1362,11 @@ if [ "${enable_watchdog}" = "1" ]; then
13501362
sed -i 's/^.*RuntimeWatchdogSec=.*$/RuntimeWatchdogSec=14s/' /rootfs/etc/systemd/system.conf
13511363
fi
13521364

1353-
echo "Configuring bootloader to start the installed system..."
1365+
echo "Preserving original config.txt and kernels..."
13541366
cp /bootfs/config.txt /rootfs/boot/config-reinstall.txt
1367+
cp /bootfs/kernel.img /rootfs/boot/kernel-reinstall.img
1368+
cp /bootfs/kernel7.img /rootfs/boot/kernel7-reinstall.img
1369+
echo "Configuring bootloader to start the installed system..."
13551370
cp /bootfs/config/boot/config.txt /rootfs/boot/config.txt
13561371
if [ -z "$(tail -c1 /rootfs/boot/config.txt)" ]; then
13571372
echo >> /rootfs/boot/config.txt

0 commit comments

Comments
 (0)