# Obtain kernel source from ISO file



## arsaKasra (Nov 19, 2013)

I'm running FreeBSD release 9.2 as guest OS on Virtualbox in Windows. I need to "install the emulators/virtualbox-ose-additions package" as it says in the website manual . When I try to do that I get an error saying that virtualbox-ose-additions requires kernel source. Now I only have the ISO file available, and I can't write it to a DVD, and actually wouldn't really like to do so. And also I prefer not having to download them, if I ever have that option as a solution. So, is there a simple workaround using only the ISO file? I already mentioned I am running FreeBSD on VirtualBox, in case that make any difference.


----------



## SirDice (Nov 19, 2013)

Just mount the ISO on the 'virtual' CD/DVD drive VirtualBox gives to your guest. Mount the CD in FreeBSD: `mount /cdrom`. Then simply untar /cdrom/usr/freebsd-dist/src.txz.

You can also 'mount' the ISO on an md(4) device inside FreeBSD: `mount -a -t vnode -f /path/to/ISO` and mount whatever md(4) device gets created on /cdrom or /mnt.


----------



## arsaKasra (Nov 19, 2013)

Thank you, but, to start with, `mount /cdrom` won't work, I get 
	
	



```
mount: cdrom: unknown special file or file system
```
 That aside, I managed to copy the src.txz to disk but when I tried to `untar` it, I got the error 
	
	



```
Lzma library error: Corrupted input data
```
 I'm not sure if it's possible that the files on the ISO are corrupted while I successfully installed FreeBSD using it. Anyway, I just removed the machine to reinstall it hoping that there will be an option to copy the source files during the install. But in case that doesn't work, and if I ever managed to get a working copy of the extracted src.txz, what am I supposed to do with it?


----------



## Crivens (Nov 19, 2013)

To skip the process with the loopback mount (maybe you are a "user" and can not do that), `BSD tar` is able to extract .iso files as if they were tar archives.


----------



## ShelLuser (Nov 19, 2013)

arsaKasra said:
			
		

> That aside, I managed to copy the src.txz to disk but when I tried to `untar` it, I got the error
> 
> 
> 
> ...


What command did you try to unpack the archive?

My guess is that you forgot to use the -J ("--xz") option. These archives aren't common tarballs (which are usually compressed with either gzip or bzip2) but instead it uses xz (see the xz(1) manualpage for more information on that).


----------



## arsaKasra (Nov 20, 2013)

ShelLuser said:
			
		

> What command did you try to unpack the archive?
> 
> My guess is that you forgot to use the -J ("--xz") option. These archives aren't common tarballs (which are usually compressed with either gzip or bzip2) but instead it uses xz (see the xz(1) manualpage for more information on that).



Well, honestly I can't remember if I did use the J option, but when I tried reinstalling with sources included, I again got an error about the src.txz being corrupted, apart from that, I tried extracting with 7-zip in Windows, same result. Whatever the matter was with that, I have downloaded the file and it worked fine.


----------

