# installkernel without creating kernel.old



## FestusHagen (Jan 15, 2009)

How can one change the creation location of kernel.old or prevent it's creation when doing "make installkernel"??

Not enough disk space, and I have already created a backup elsewhere.

Thanks

-Enjoy
fh  : )_~


----------



## trev (Jan 15, 2009)

I'm guessing wildly, but perhaps 'make reinstallkernel' after a 'make buildkernel' would do what you want. Let us know


----------



## mk (Jan 15, 2009)

didn't fully tested but you can try memory fs

```
mkdir /boot/kernel.old/
dd if=/dev/zero of=/usr/krn.old count=128 bs=1m
mdconfig -at vnode -f /usr/krn.old -u 33
newfs /dev/md33 
mount /dev/md33 /boot/kernel.old
#after finish make installkernel unmount
#and then delete memdevice 33
mdconfig -du 33
```


----------



## FestusHagen (Jan 15, 2009)

mk said:
			
		

> didn't fully tested but you can try memory fs
> 
> ```
> mkdir /boot/kernel.old/
> ...



This doesn't work, It fails with:
rm: /boot/kernel.old: Device busy​
Though trying it gave me some hints on where to look for the code that handles the backup, thus finding it in:
/usr/src/sys/conf/kern.post.mk​and thus was able to mod and accomplish the goal.

Thanks

-Enjoy
fh  : )_~


----------



## mk (Jan 15, 2009)

i test my idea and get too device busy message, but kernel install nice and boot/reboot with success 2 times.
how did you figure out which exact file to look since when i read your post try (not that hard) to see is any such option to point where to be moved kernel.old?


----------



## FestusHagen (Jan 17, 2009)

mk said:
			
		

> i test my idea and get too device busy message, but kernel install nice and boot/reboot with success 2 times.
> how did you figure out which exact file to look since when i read your post try (not that hard) to see is any such option to point where to be moved kernel.old?



There was no _option_, I just changed the relevant code in /usr/src/sys/conf/kern.post.mk to point to another location.

The lines with ".old" are the relevant code:


```
kernel-install:
	@if [ ! -f ${KERNEL_KO} ] ; then \
		echo "You must build a kernel first." ; \
		exit 1 ; \
	fi
.if exists(${DESTDIR}${KODIR})
	-thiskernel=`sysctl -n kern.bootfile` ; \
	if [ ! "`dirname "$$thiskernel"`" -ef ${DESTDIR}${KODIR} ] ; then \
		chflags -R noschg ${DESTDIR}${KODIR} ; \
		rm -rf ${DESTDIR}${KODIR} ; \
	else \
		if [ -d ${DESTDIR}${KODIR}.old ] ; then \
			chflags -R noschg ${DESTDIR}${KODIR}.old ; \
			rm -rf ${DESTDIR}${KODIR}.old ; \
		fi ; \
		mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old ; \
		sysctl kern.bootfile=${DESTDIR}${KODIR}.old/"`basename "$$thiskernel"`" ; \
	fi
.endif
```

-Enjoy
fh  : )_~


----------

