# Installing Gentoo onto a headless system over the Network

## blixel

Does anyone have any information about installing Gentoo onto a headless system (no keyboard/mouse/monitor) over the Network.  Not quite the same thing as a diskless station.  The system I have is an embedded computer.  It has a hard-drive, but no floppy or CD-ROM.  And it doesn't have any input devices and no display device.  I have no problem installing OpenBSD or FreeBSD on it, but I want to try Gentoo.

So far I have been able to boot it from the Network using a DHCP+TFTP server and the pxelinux.0 file from the syslinux project.  I have also compiled a highly cut down kernel for it and have included everything needed for this embedded device.  (http://www.soekris.com)

My kernel gets loaded, but it Kernel Panics because it can't find the root fs.  This is the point I'm stuck at and I'm hoping someone in these forums has some experience with headless systems and can help me out.

I believe I'm on the right track by trying to mount the root file system via NFS.  I have included NFS Root File System support in the kernel.  (Nothing is compiled as a module.  The kernel is non-modular ... or monolithic.)  I have the right driver for my network card included in the kernel as well.

I'm just lost as to what to do next.  Where do I get a roof file system for Gentoo?  I know Debian has rootfs images but I don't want to put Debian on this box.

Here is a copy/paste of the relevant portion of my boot message that

I'm seeing now.

```
eth0: DSPCFG accepted after 0 usec.

eth0: link up.

eth0: Setting full-duplex based on negotiated link capability.

eth1: DSPCFG accepted after 0 usec.

eth2: DSPCFG accepted after 0 usec.

Sending DHCP requests ., OK

IP-Config: Got DHCP answer from 192.168.1.10, my address is 192.168.1.4

eth1: remaining active for wake-on-lan

eth2: remaining active for wake-on-lan

IP-Config: Complete:

      device=eth0, addr=192.168.1.4, mask=255.255.255.0, gw=255.255.255.255,

     host=192.168.1.4, domain=davidcourtney.home, nis-domain=(none),

     bootserver=192.168.1.10, rootserver=192.168.1.4, rootpath=

Looking up port of RPC 100003/2 on 192.168.1.4

RPC: sendmsg returned error 22

portmap: RPC call returned error 22

Root-NFS: Unable to get nfsd port number from server, using default

Looking up port of RPC 100005/1 on 192.168.1.4

RPC: sendmsg returned error 22

portmap: RPC call returned error 22

Root-NFS: Unable to get mountd port number from server, using default

RPC: sendmsg returned error 22

mount: RPC call returned error 22

Root-NFS: Server returned error -22 while mounting /tftpboot/eta

VFS: Unable to mount root fs via NFS, trying floppy.

VFS: Cannot open root device "nfs" or unknown-block(2,0)

Please append a correct "root=" boot option

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
```

----------

## tuxmin

There is something wrong with your bootp config. Your headless machine tries to contact itself als NFS server and this of course fails!

```

---> rootserver=192.168.1.4         should be

rootserver=192.168.1.10

```

Hth, Alex!!!

----------

## blixel

 *tuxmin wrote:*   

> There is something wrong with your bootp config. Your headless machine tries to contact itself als NFS server and this of course fails!
> 
> ```
> 
> ---> rootserver=192.168.1.4         should be
> ...

 

Thanks Alex.  That does help, sort of.  I can't believe I made that dumb of a mistake.

I think the main part I'm still stuck on though is where do I get a root file system?  The Live CD's don't contain one.  They just have some massive squash_fs file.  With Debian, they provide a tftpboot.img and root.bin that you use to get the installer going.  I understand Gentoo doesn't have an "installer" per se', but if I can get to the command prompt, I should be able to install as usual.

Here's the new stopping point.  Basically the same as before, but at least now it's actually contacting the NFS server.

```
Sending DHCP requests ., OK

IP-Config: Got DHCP answer from 192.168.1.10, my address is 192.168.1.4

eth1: remaining active for wake-on-lan

eth2: remaining active for wake-on-lan

IP-Config: Complete:

      device=eth0, addr=192.168.1.4, mask=255.255.255.0, gw=255.255.255.255,

     host=192.168.1.4, domain=davidcourtney.home, nis-domain=(none),

     bootserver=192.168.1.10, rootserver=192.168.1.10, rootpath=/tftpboot

Looking up port of RPC 100003/2 on 192.168.1.10

Looking up port of RPC 100005/1 on 192.168.1.10

VFS: Mounted root (nfs filesystem) readonly.

Freeing unused kernel memory: 432k freed

Warning: unable to open an initial console.

Kernel panic - not syncing: No init found.  Try passing init= option to kernel.
```

----------

## tuxmin

Here's how I use to do this:

Get a stage3 tarball and the latest portage snapshot. 

Extract everything under /tftpboot on the NFS/TFTP server.

chroot into /tftpboot. 

Configure make.conf etc. as you intend for your headless system. Especially networking, the kernel and lilo or grub.

emerge sync

Do a world update.

Emerge at least openssh and add to the default runlevel.

Edit sshd_config so that root login is allowed.

Now boot your headless machine. If you did all well your system should come up.

ssh into the headless machine.

Partition the disk and mount it under let's say /mnt/gentoo (all partitions!), don't forget swap.

Now you need to copy the prepared sytem over: on the server do

- cd /tftpboot

- tar cf - * | ssh headless.machine "cd /mnt/gentoo; tar xvpf -"

switch to the headless machine again.

mount -t proc none /mnt/gentoo/proc

chroot into /mnt/gentoo and edit fstab and lilo.conf to your needs.

Run lilo

exit chroot

Reboot

I hope I forgot nothing. But I hope the procedure as such is clear.

Alex!!!

----------

## blixel

 *tuxmin wrote:*   

> Here's how I use to do this:
> 
> Get a stage3 tarball and the latest portage snapshot. 
> 
> Extract everything under /tftpboot on the NFS/TFTP server.
> ...

 

I think I follow how that would work.  Except for a couple of things.  You say to extract the stage 3 tarball to /tftpboot.  Shouldn't that be /tftpboot/gentoo?  If you extract directly to /tftpboot, wouldn't that get in the way of the other files in the /tftpboot that are required to boot over the network?  Such as /tftpboot/pxelinux.0.  Also, when you say "Now boot your headless machine...", what assumptions are you making by that point?  Because in your outline up to that point, you never mention anything about configuring DHCP+TFTP.  Without those things properly configured, the headless machine won't be able to boot the /tftpboot that you setup because it won't know anything about it.

----------

## tuxmin

 *blixel wrote:*   

> 
> 
>  You say to extract the stage 3 tarball to /tftpboot.  Shouldn't that be /tftpboot/gentoo? 
> 
> 

 

By looking at your log I see that you set

```

rootpath=/tftpboot

```

Of course it is better to use /tftpboot/gentoo or any other path that suits you. Remember to pass this path along to the client and to export it via NFS!

 *Quote:*   

> 
> 
> Also, when you say "Now boot your headless machine...", what assumptions are you making by that point?  Because in your outline up to that point, you never mention anything about configuring DHCP+TFTP.  
> 
> 

 

The assumption is that I think your TFTP/DHCP stuff is working well. Your logs confirm that the kernel is transferred via tftp, boots up and gets an IP... the only thing that misses is some content in the rootfs that is mounted via NFS. The headless machine mounts 192.168.1.10:/tftpboot as /, finds no /sbin/init as there obviously is none and the kernel panics. Looks very good to me up to this point... to put it clear: the NFS mount of the rootfs is totally independant of the TFTP/DHCP stuff! 

There is one thing I forgot to mention, though. Try the initial boot with an empty fstab in the chrooted Gentoo, if that fails add the follewing line

```

192.168.1.10:/tftpboot/gentoo     /       nfs     defaults        0 0

```

I think you need to "emerge nfs-utils" in the chroot environment for this to work.

Hth, and don't hesitate to ask further questions.

Alex!!!

----------

## blixel

 *Quote:*   

> Now boot your headless machine. If you did all well your system should come up.
> 
> ssh into the headless machine.
> 
> Partition the disk and mount it under let's say /mnt/gentoo (all partitions!), don't forget swap.
> ...

 

I'm actuall amazed I've made it this far.  I'm at this point now where I'm copying the system over.  I think it's stuck on the proc directory though.  I still have network activity, but I don't think it's doing anything.  Should I have unmounted /proc in my chrooted environment before copying the system over?

Update: Well it doesn't look like it will let me unmount proc from the chrooted environment.  Probably because it's in use via NFS at the moment.  Hmmm...  I think I'll try "tar --exclude proc -cf - * | ssh headless.machine "cd /mnt/gentoo; tar xvpf -"

----------

## blixel

 *tuxmin wrote:*   

>  *blixel wrote:*   
> 
>  You say to extract the stage 3 tarball to /tftpboot.  Shouldn't that be /tftpboot/gentoo? 
> 
>  
> ...

 

Absolutely incredible!  It all worked.  My headless box is now booting Gentoo completely on its own.  Thanks for your tips.  Never would have got it without your help.

I did have to do the initial boot with the nfs line in my fstab you mentioned above.

The only thing I don't like about the process is copying over the system from one box to the other.  It feels dirty doing it that way.

I hope Gentoo comes up with some nice, clean little boot images like Debian has.  Because even after all this effort I went through to put Gentoo on this thing, I'm tempted to go with Debian anyway just because it's so much easier.  Eventually I'll have to setup Gentoo on this box again and there's no way I'm going to remember all these steps without making a huge set of notes.  Whereas with Debian, there are like 3 steps.  Hmm...

----------

## /dev/random

http://www.gentoo.org/doc/en/diskless-howto.xml#doc_chap4

I believe the PXE Linux section of that mentions what you're referring to.

----------

## tuxmin

Nice nice...

You're right. I forgot to mention to umount proc before copying (from outside the chroot environment of course). But the --exclude option is as good. One might consider excluding dev as well as we normally use devfs or udev with Gentoo -- but on the other hand it uses up to no diskspace.

And guess what, I use the same method to install Debian  :Smile: 

But on my servers I can boot Knoppix from CD which makes things much easier.

And now that you made it I'd say you learned a lot about Linux. Think this over and try to really understand why this works and I'm sure you'll need only a few lines of documentation to recall it later.

Regards, Alex!!!

----------

## blixel

 *tuxmin wrote:*   

> You're right. I forgot to mention to umount proc before copying (from outside the chroot environment of course). But the --exclude option is as good. One might consider excluding dev as well as we normally use devfs or udev with Gentoo -- but on the other hand it uses up to no diskspace.

 

I don't think you could umount proc from outside the chroot environment.  I could be mistaken, but I think it's needed in order to succesfully boot the headless system via NFS ... and then it's in use while that system is booted.  So I think exclude is the only way to do it.

 *tuxmin wrote:*   

> And guess what, I use the same method to install Debian 

 

Eh?  Why go through all that trouble?  Boot the tftpboot.img and run the install.  It's so elegant and clean.  Though admittedly, I haven't gotten it to work yet due to what seems to be a very minor problem.  Know anything about this?  I posted this question to groups.google.com earlier today.   http://groups-beta.google.com/group/comp.os.linux.networking/browse_thread/thread/a0e32716ca333ab2/72605f495a23d2ae#72605f495a23d2ae

 *tuxmin wrote:*   

> And now that you made it I'd say you learned a lot about Linux. Think this over and try to really understand why this works and

 

I don't think there is anything about it I don't understand.  The commands weren't mystical things I typed that just made the OS magically appear on my headless system.  I had to deviate from your outline quite a bit to accomplish my goal.  If I didn't have any understanding of what I was doing (and I'm not saying you insinuated that, you did not), but if I didn't already have a very good understanding of the process, I wouldn't have been able to accomplish anything based on your outline.

 *tuxmin wrote:*   

> I'm sure you'll need only a few lines of documentation to recall it later.

 

Doubtful.  Without awesome documentation, there were too many steps to follow to be able to remember any of it a year or two from now.  When I write documentation, I try to assume that the person doing the task knows as little as possible.  Certain assumptions have to be made or else you could never document anything.  Here is an example of the document I've been working on with regards to these Soekris boxes.  http://www.davidcourtney.org/soekris.html

----------

## tuxmin

Your Debian problem: I guess your network card simply is not supported by the Woody kernel. That's why I use Knoppix to boot and then copy over my generic Debian System -- Knoppix boots on as good as any hardware and I happen to have lots of servers that don't even boot with the Debian Installer CD set.

One day when I have the time and am in the mood I'll try to setup my own install server.. until then I'll do it semi automatically  :Smile: 

Another point why I use this method is that my system images are fully setup for my environment, many third party software like backup and client software is already there and does not have to be installed seperately saving me a lot of time.

Anyway, if I could help you in some way I'm glad, and if you throw everything accomplished into the dustbin then be it so  :Smile: 

And that you are compiling such an extensive documentation for the public is something I really appreciate!

Regards, Alex!!!

----------

