个人工具

“UbuntuHelp:Installation/LocalNet”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第2行: 第2行:
 
{{Languages|UbuntuHelp:Installation/LocalNet}}
 
{{Languages|UbuntuHelp:Installation/LocalNet}}
  
'''Other Languages: ComoNetbootInstall Espanol'''
 
  
[new] good news!  It works with Edgy Alternate and Server CDs.
 
  
This is a work in progress.  It is also a mix of Basic Internet Install and Local Net Install that are similar to just installing from the CD, and Hands Off Install that uses a preseed file to automate the whole thing. 
+
== Feisty Desktop Edition Install ==
  
sahara is the server (dhcp, tftp, http).
+
''This section (and perhaps this page) was correct for Feisty. It does not work for Gutsy.''
shaz is the blank box that I am installing on.
+
  
0. Install Trivial File Transfer Protocol server and enable it (default tftp config uses inetd)
+
The following describes how you can boot a machine into the Ubuntu Desktop Edition, using just its network card to "PXE netboot", via a tftp and nfs server. This means you can use the machine to run a LiveCD system, without actually needing any CD drive nor hard disk in the machine. The machine is effectively a diskless workstation at this point. You can then install Ubuntu onto its hard drive just as if you had a CD in its CD drive.
<pre><nowiki>
+
root@sahara:/ # apt-get install tftpd-hpa
+
root@sahara:/ # vi /etc/default/tftpd-hpa 
+
</nowiki></pre>
+
  
0. Mount the CD (media or image) under the tftpboot dir
+
The way this works, in summary is: you do some configuring of some servers, so that your client machine will 'netboot' via pxe/bootp, get an ip address, get passed a boot kernel via tftp, will boot into that kernel, and it will display a menu screen to run a 'live-(pseudoCD)-install' on your client machine. You will have defined the menu item(s) for this menu, those being how to boot into a 'Live CD/install'. When you select the menu item, it boots a second kernel which takes you into the 'Live CD'.  
<pre><nowiki>
+
root@sahara:/var/lib/tftpboot/ubuntu/edgy$ mount -o loop edgy-alternate-i386.iso alternate/
+
</nowiki></pre>
+
  
0. Setup Apache
+
Actually, to be precise, the boot kernel is a linux kernel and it is accompanied by the initial ramdisk image (initrd...). Each is a single file. Inside the initrd is the entire initial ramdisk including an init script. This script does the actual bootup and install. When we refer to a boot kernel on this page we should more precisely refer to the kernel and its partner initrd. They are a set that should be kept together.
 +
 
 +
=== Set up the servers ===
 +
 
 +
0. Ensure that you have a dhcp server (or a bootp server), a tftp (eg tftp-hpa) server, and an nfs server available on your network. If not, install them onto a machine (or over a set of machines if you want to complicate things).
 +
0. Configure the dhcp server: Set the following options in dhcpd.conf on your DHCP server:
 
<pre><nowiki>
 
<pre><nowiki>
root@sahara:~ # apt-get install apache2</nowiki></pre>
+
next-server 10.20.1.2; # this is your TFTP server
 +
filename "pxelinux.0"; # put this in verbatim
 +
</nowiki></pre> or:
 +
0. Configure a bootp server. If your router already provides dhcp, you might install and use a bootp server. The client machine's ip address will be assigned by the router. The ip address you try to assign with your bootp server will be ignored. Either way, your client machine will ask via pxe for an ip address, and will then be passed over to the tftpserver.
 +
0. Install bootpd with Synaptic (package name = bootp)
 +
0. Edit <code><nowiki>/etc/bootptab</nowiki></code>. Here is an example.
 +
<pre><nowiki>client:\
 +
td=/var/lib/tftpboot: hd=/: bf=pxelinux.0:\
 +
ip=192.168.1.4:\
 +
ha="00:1B:FC:58:69:69":\
 +
gw=192.168.1.1:\
 +
sm=255.255.255.0:
 +
client:\
 +
td=/var/lib/tftpboot: hd=/: bf=pxelinux.0:\
 +
ip=192.168.1.42:\
 +
ha="00:00:39:2B:54:B5":\
 +
gw=192.168.1.1:\
 +
sm=255.255.255.0:</nowiki></pre> For further help: <code><nowiki>man bootpd; man bootptab</nowiki></code> and also found in the etc/bootptab file itself as comments.
 +
 
 +
If you don't know the hardware address, or which ip address dhcp will assign, start bootp and/or dhcp/router, get the hardware address from the client's startup screen and the ip address assigned by the router by browsing into the router after the first startup. Update <code><nowiki>/etc/bootptab</nowiki></code> with these good values, then restart bootpd.
 +
 
 +
0. Starting bootp: Here is a wrapper to start and stop bootpd from the command line.
 +
<pre><nowiki>#!/bin/bash
 +
vDaemon=bootpd
 +
 
 +
Start () {
 +
/usr/sbin/$vDaemon -d 4 -c /var/lib/tftpboot >/tmp/$vDaemon.log 2>/tmp/$vDaemon.err &
 +
}
 +
 
 +
Stop () {
 +
kill `pidof $vDaemon`
 +
}
 +
 
 +
Status () {
 +
vPid="`pidof $vDaemon`"
 +
if [ "$vPid" ] ; then
 +
echo "$vDaemon running, pid=$vPid"
 +
else
 +
echo "$vDaemon not running"
 +
fi
 +
}
 +
 
 +
case "$1" in
 +
start) Start ;;
 +
stop) Stop ;;
 +
restart) Stop ; sleep 2; Start ;;
 +
status) Status ;;
 +
""|*) echo `basename $0` parameter: start stop status or restart ;;
 +
esac</nowiki></pre>
 +
[https://help.ubuntu.com/7.04/installation-guide/i386/install-tftp.html Preparing Files for TFTP Net Booting, Section "Setting up BOOTP server"] has more info on bootp, including instructions for starting bootp using the inetd alternative.
 +
 
 +
0. Configure the nfs server:
 +
0. Download the Ubuntu Desktop .iso.
 +
0. Mount the .iso and copy its contents to a directory on your nfs server. Eg if you use <code><nowiki>/home/ftp/...</nowiki></code>, you can also make the distro available via vs-ftpd, set for anonymous ftp. (This could include installing using an ftp server instead: another type of install, not covered here.)
 +
0. Nfs-export the directory, (or one somewhere above it,) in <code><nowiki>/etc/exports</nowiki></code> so this directory is accessible via nfs.
 +
0. Reload or restart the nfs server.
  
0. Make a symlink from apache's doc Root to the CD
+
0. Configure the tftp server:
 +
0. Download [http://archive.ubuntu.com/ubuntu/dists/feisty/main/installer-i386/current//images/netboot/386/netboot.tar.gz this tarfile from the Ubuntu Archives], and extract its contents into the tftpboot directory on your tftp server.
 +
0. Copy <code><nowiki>vmlinuz</nowiki></code> and <code><nowiki>initrd.gz</nowiki></code> from the <code><nowiki>/casper</nowiki></code> directory of the Ubuntu Desktop .iso to the tftpboot directory. Rename them if you wish, eg <code><nowiki>vmlinuz.fromUbuntu704DesktopCd, initrd.gz.fromUbuntu704DesktopCd</nowiki></code>. This is the kernel and initrd that you will select to load as your 'live CD' session. Eg
 
<pre><nowiki>
 
<pre><nowiki>
root@sahara:/var/www # ln -s /var/lib/tftpboot/ubuntu/</nowiki></pre>
+
cp -a /home/ftp/ubuntu704DesktopCd/casper/vmlinuz /var/lib/ftfpboot/vmlinuz.fromUbuntu704DesktopCd
 +
cp -a /home/ftp/ubuntu704DesktopCd/casper/initrd.gz /var/lib/ftfpboot/initrd.gz.fromUbuntu704DesktopCd</nowiki></pre> Note the use of -a so you  preserve the timestamp. This helps clarify later which version kernel you are using.
 +
0. Edit a menu LABEL entry in pxelinux.cfg/default to point to the kernel and initrd from the previous step. Also edit in options to tell casper to mount to it via NFS, eg as per the following 5 lines:
 +
<pre><nowiki>
 +
1 DEFAULT LiveDesktopCD
 +
2
 +
3 LABEL LiveDesktopCD
 +
4 kernel vmlinuz.fromUbuntu704DesktopCd
 +
5 append initrd=initrd.gz.fromUbuntu704DesktopCd boot=casper netboot=nfs nfsroot=192.168.1.40:/home/ftp/ubuntu704DesktopCd --</nowiki></pre>
 +
(The 5th line is long and might appear split here. Join them in your pxelinux.cfg/default.)
 +
nfsroot points to your NFS server and the path to the directory where you copied all the contents of the CD.
 +
0. Its useful to also edit the boot-screens/boot.txt to make the startup menu look different to the standard installation startup, and boot-screens/F3 file to document your use of the casper kernel.
  
0. Install dhcp server.
+
(More background info is at [https://help.ubuntu.com/7.04/installation-guide/i386/install-tftp.html Preparing Files for TFTP Net Booting]).
<pre><nowiki>
+
root@sahara:~ # apt-get install dhcp3-server
+
</nowiki></pre>
+
  
0. Set the dhcp server to tell the clients what to boot.  I added a default host name, you don't need it but it comes in handy for other things.
+
=== Net-boot your client machine. ===
 +
 
 +
0. The tftpboot server passes the client the boot kernel, as described in the intro. The boot kernel presents an installation screen, or menu, which looks similar to the first pre-installation screen of the Desktop live CD. You will be presented with the installation startup menu described above. If you have set up the LABEL lines correctly, simply hit [Enter].
 +
 
 +
0. The installation kernel does a simple install to RAM and starts Gnome. You get a desktop with an icon to Install to hard disk. If you start this icon, the full hard disk install proceeds. If not, you simply run a 'Live Cd' session in RAM (without the actual CD).
 +
 
 +
==== Technical Note: About Casper ====
 +
"Casper  is  a hook for initramfs-tools used to generate an initramfs capable to boot live systems as those created by make-live. This includes the Debian-Live isos, netboot tarballs, and usb stick images and Ubuntu live  cds.  At boot  time it will look for a (read-only) media containing a "/casper" directory where a root filesystems (often a compressed squashfs) is stored. If found, it will create a writable environment, using unionfs, for debian-like systems to boot from."
 +
<code><nowiki>man casper</nowiki></code> for more information.
 +
 
 +
== Basic: Hands-On Interactive Network Server Edition Install ==
 +
 
 +
These steps allow you to install an Ubuntu distro from over your network, as if you had booted and installed it from the Ubuntu installation CD. This is almost a rewrite of the above, except its using http via Apache instead of nfs. Moreover, it does not use Casper so it does not result in a live system. Instead the client boots into an installer.)
 +
 
 +
Services needed, on a server (or servers) :
 +
0. dhcp or bootp: to provide netboot server support,
 +
0. tftp: to feed the first boot image to the netboot client machine, when requested by the netboot server,
 +
0. http, ftp or nfs: to supply the Ubuntu distro to the client machine during the installation process.
 +
0. The client machine must be able to boot from its network card, else from a diskette that you built to 'netboot'.
 +
 
 +
This page focusses on the combination of dhcp, tftp, and http. In the examples below 'myserver' is the server for these 3 services. (Each of these can be run on a separate server if desired.)
 +
 
 +
0.#1 Install and configure the dhcp server. Eg to install:
 +
<pre><nowiki>
 +
root@myserver:~ # apt-get install dhcp3-server</nowiki></pre>
 +
Configure the dhcp server to tell the clients what to boot.  I added a default host name, you don't need it but it comes in handy for other things.
 
<pre><nowiki>
 
<pre><nowiki>
root@sahara:~ # cat /etc/dhcp3/dhcpd.conf
+
root@myserver:~ # cat /etc/dhcp3/dhcpd.conf
 
subnet 192.168.1.0  netmask 255.255.255.0 {
 
subnet 192.168.1.0  netmask 255.255.255.0 {
 
range 192.168.1.10 192.168.1.254;
 
range 192.168.1.10 192.168.1.254;
第43行: 第128行:
 
# put your DNS IP's here:
 
# put your DNS IP's here:
 
option domain-name-servers 192.168.1.7, 68.87.66.196 ;
 
option domain-name-servers 192.168.1.7, 68.87.66.196 ;
filename="ubuntu/edgy/alternate/install/netboot/pxelinux.0";
+
filename="ubuntu/feisty/alternate/install/netboot/pxelinux.0";
  
root@sahara:~ # /etc/init.d/dhcp3-server restart
+
root@myserver:~ # /etc/init.d/dhcp3-server restart
 
Stopping DHCP server: dhcpd3.
 
Stopping DHCP server: dhcpd3.
 
Starting DHCP server: dhcpd3.</nowiki></pre>  
 
Starting DHCP server: dhcpd3.</nowiki></pre>  
 +
0.#2 Install and configure the Trivial File Transfer Protocol server. The tftpd-hpa package is recommended. Install it. It is enabled via /etc/default/tftpd-hpa,
 +
<pre><nowiki>RUN_DAEMON="yes"
 +
OPTIONS="-l -s /var/lib/tftpboot"
 +
</nowiki></pre> Also note its base directory. The default setting is shown above.
  
0. Boot up the client box, config the bios to net boot and you should get the Ubuntu screen and Boot: prompt. Yippee!
+
Mount the CD (media or image) under the tftpboot base directory found above,eg
 +
<pre><nowiki>
 +
root@myserver:/var/lib/tftpboot/ubuntu/feisty$ mount -o loop feisty-alternate-i386.iso alternate/ </nowiki></pre> or, you can instead copy the contents of the CD into that location, instead of leaving the ISO mounted.
  
The above steps should give you an interactive setup, very similar to if you had booted from the CD.
+
See [https://help.ubuntu.com/7.04/installation-guide/i386/install-tftp.html Preparing Files for TFTP Net Booting] for detailed information.
  
---
+
0.#3 Install and configure Apache, eg:
At this point in time my goal has shifted from a typical install like if you just booted from CD to a Hands Off Install where all the questions have been answered and fed to the installer as preseed.  I may get back to the interactive setup, but for now I am focused on using preseed.cfg.
+
<pre><nowiki>
 +
root@myserver:~ # apt-get install apache2</nowiki></pre>
 +
 
 +
Make a symlink from apache's doc Root to the CD
 +
<pre><nowiki>
 +
root@myserver:/var/www # ln -s /var/lib/tftpboot/ubuntu/</nowiki></pre> Or copy the /ubuntu directory from the CD into here.
  
 +
To use a pure ftp server like the vs-ftp server instead of Apache, install the ftp server, and configure it for anonymous ftp access. Then copy the /ubuntu directory from the CD into the anonymous ftp home. With vs-ftpd, this is set to /home/ftp. (Check /etc/passwd to confirm the anonymous ftp home.) Next test that anonymous ftp works and finds the installation stuff. eg via 'ftp localhost' on that machine. The install needs to be done in 'expert' mode, so you can select the ftp protocol instead of the default 'http'.
 +
0.#4 Boot up the client machine, set its bios to net boot and you should get the Ubuntu screen and Boot: prompt. Yippee!
 
----
 
----
  
My configs to make a Hands Off Install that does not pull anything from the internet.
+
== Advanced: Hands-Off, Preseeded Network Server Install ==
  
Something changed in the last few weeks of dapper beta.  I was working, then I went on vaction, not it isn't. That doesn't mean it won't work, just what I was doing before isn't working now, which is to be expected when you are working with beta.
+
The above is for an interactive install, just as if you booted from CD. The following addresses preseeding, which enables a Hands Off Install where all the questions have been answered and fed to the installer. In addition, the following does not pull anything from the Internet.
  
A handfull of preseed options need to be passed via kernel options.  The kernel only supports 255 chars, so things are cramped.  To accomodate this, I dumped some of the paths and made symlinks.  That gave me just enough space for now.  Note that the path/name of the kernel gets appended, so even trimming that helped.
+
A handful of preseed options need to be passed via kernel options.  The kernel only supports 255 chars, so things are cramped.  To accommodate this, I dumped some of the paths and made symlinks.  That gave me just enough space for now.  Note that the path/name of the kernel gets appended, so even trimming that helped.
  
 
<pre><nowiki>root@sahara:/var/lib/tftpboot # ln -s ubuntu-installer/i386/initrd.gz
 
<pre><nowiki>root@sahara:/var/lib/tftpboot # ln -s ubuntu-installer/i386/initrd.gz
第87行: 第185行:
 
localboot 0
 
localboot 0
  
label ubuntu-breezy-normal
+
label ubuntu-feisty-normal
# ubuntu instaler
+
# ubuntu installer
kernel ubuntu-breezy/linux
+
kernel ubuntu-feisty/linux
append vga=normal initrd=ubuntu-breezy/initrd.gz ramdisk_size=14984 root=/dev/rd/0 rw  --
+
append vga=normal initrd=ubuntu-feisty/initrd.gz ramdisk_size=14984 root=/dev/rd/0 rw  --
  
label ubuntu-breezy-hands-off
+
label ubuntu-feisty-hands-off
# ubuntu instaler
+
# ubuntu installer
kernel ubuntu-breezy/linux
+
# The 'kernel' and 'initrd' paths must identify files under tftpboot.
append initrd=ubuntu-breezy/initrd.gz ramdisk_size=14984 root=/dev/rd/0 rw preseed/locale=en_US kbd-chooser/method=us netcfg/wireless_wep= netcfg/choose_interface=eth1 netcfg/get_hostname= preseed/url=http://192.168.1.7/preseed-breezy.cfg vga=6 --
+
# For example, on my system I have /var/lib/tftpboot/ubuntu-feisty/linux and /var/lib/tftpboot/ubuntu-feisty/initrd.gz.
 +
kernel ubuntu-feisty/linux
 +
append initrd=ubuntu-feisty/initrd.gz ramdisk_size=14984 root=/dev/rd/0 rw preseed/locale=en_US kbd-chooser/method=us netcfg/wireless_wep= netcfg/choose_interface=eth0 netcfg/get_hostname= preseed/url=http://192.168.1.7/preseed-feisty.cfg vga=6 --
 
</nowiki></pre>
 
</nowiki></pre>
 
netcfg/get_hostname= Is blank so that it will pick up the host-name supplied by the DHCP server.
 
netcfg/get_hostname= Is blank so that it will pick up the host-name supplied by the DHCP server.
  
netcfg/choose_interface=eth1 - for laptops, I want it to setup the wifi card, not the wired port.  Problem I am having is that some use eth1 and some wlan0.  What would be great is if the DHCP server could somehow pass this too.
+
netcfg/choose_interface=eth0 - You may wish to specify eth1 or wlan0 for laptops if you want it to setup the wifi card, not the wired port.
  
note: The DHCP server can't pass it, but pretending that the MAC address of your wireless card is 12 : CD : 56 : AB : 78 : EF you can specify a custom pxelinux.cfg/01-12-dc-56-ab-78-ef (lowercase) instead. If you are using static dhcp, you can also use the IP address in hex for a per-machine or per-subnet or per-network configuration. See http://syslinux.zytor.com/pxe.php#config for more information.
+
Note for client-specific PXE configurations: The DHCP server can't pass it, but pretending that the MAC address of your wireless card is 12 : CD : 56 : AB : 78 : EF you can specify a custom pxelinux.cfg/01-12-dc-56-ab-78-ef (lowercase) instead. If you are using static dhcp, you can also use the IP address in hex for a per-machine or per-subnet or per-network configuration. See http://syslinux.zytor.com/pxe.php#config for more information. Basically, say you have three wireless cards where the IP in hex translated to caf12d5e, caf12d6b, caf124ea, you could specify pxelinux.cfg/caf12d and pxelinux.cfg/caf12. The first two would match to the first config file and the third would match to the second config file.
  
Basically, say you have three wireless cards where the IP in hex translated to caf12d5e, caf12d6b, caf124ea, you could specify pxelinux.cfg/caf12d and pxelinux.cfg/caf12. The first two would match to the first config file and the third would match to the second config file.
+
See http://www.debian.org/releases/etch/example-preseed.txt for an example preseed file, and be sure to note the debconf-get-selections example commands.
 
+
Here are the important changes for using the copy of the install CD on your server instead of the Internet repositories during the install:
note: this is from my new breezy installer, everything else on this page was from hoary. 
+
 
+
Using http://archive.ubuntu.com/ubuntu/dists/hoary/main/installer-i386/current/doc/manual/en/apcs01.html saved to /var/www/preseed.cfg, here are the important changes:
+
 
<pre><nowiki>
 
<pre><nowiki>
 
d-i mirror/country string enter information manually
 
d-i mirror/country string enter information manually
d-i mirror/http/hostname string 192.168.1.22
+
d-i mirror/http/hostname string sahara # This is whatever HTTP server you have set up
d-i mirror/http/directory string /ubuntu
+
d-i mirror/http/directory string /ubuntu # This is the /ubuntu directory from the install CD copied (or linked) under the webroot of your HTTP server
d-i mirror/suite string hoary
+
d-i mirror/suite string feisty # Name your ubuntu version here
 
d-i mirror/http/proxy string  
 
d-i mirror/http/proxy string  
</nowiki></pre>
+
</nowiki></pre>  
  
  
第136行: 第233行:
 
group {
 
group {
 
filename="pxelinux.0" ;
 
filename="pxelinux.0" ;
 +
 +
# You need a next-server option if TFTP and DHCPd aren't on the same system.
 +
next-server sahara;
 
 
 
# 192.168.1.2 does not exist on my lan.
 
# 192.168.1.2 does not exist on my lan.
第171行: 第271行:
  
 
}
 
}
</nowiki></pre>
 
 
----
 
Get/run the installer from Linux.  These 4/5 commands download the insteller kernel and run it.  All you need is a functioning OS.  So if you can figure out how to get the 2 files (wget, usb stick, etc) onto the local fs (can be the ramdrive of a liveCD) and run something like kexec (or maybe LoadLin?) the installer can get the rest of the files from the Internet.
 
 
<pre><nowiki>
 
sudo apt-get install tftp kexec-tools
 
 
wget http://us.archive.ubuntu.com/ubuntu/dists/edgy/main/installer-i386/current/images/netboot/ubuntu-installer/i386/linux
 
wget http://us.archive.ubuntu.com/ubuntu/dists/edgy/main/installer-i386/current/images/netboot/ubuntu-installer/i386/initrd.gz
 
 
sudo kexec --load linux --initrd=initrd.gz
 
sudo kexec --reset-vga --exec
 
 
</nowiki></pre>
 
</nowiki></pre>
  
第197行: 第284行:
 
"Etherboot does not (yet) offer support for PCMCIA cards." so the older laptops will have to wait.   
 
"Etherboot does not (yet) offer support for PCMCIA cards." so the older laptops will have to wait.   
 
----
 
----
Pile of PXE related links:
+
 
 +
== Advanced: Network install using apt-mirror ==
 +
 
 +
apt-mirror is a Perl script for maintaining a mirror of the Debian or Ubuntu installation sets.  It is often set up as a cron job to download updates to the mirror automatically.  Updates are downloaded incrementally using parallel threads.  Contents of the mirror are typically served via a web server to the local network. 
 +
 
 +
apt-mirror can be installed on most Unix machine from the tarball.  On Debian or Ubuntu, the apt-mirror package can usually be installed by apt-get with the appropriate addition to sources.list.  See the [http://apt-mirror.sourceforge.net/ apt-mirror project home page] for details. 
 +
 
 +
For basic instructions pertaining to Ubuntu, see [http://www.howtoforge.com/local_debian_ubuntu_mirror How To Create A Local Debian/Ubuntu Mirror With apt-mirror].  Some modifications are required to the mirror configuration to work in conjunction with netboot.  Netboot requires debian-installer.  The following snippet from an example configuration is reported to work: 
 +
 
 +
<pre><nowiki>
 +
deb http://mirrors.kernel.org/ubuntu feisty main main/debian-installer restricted restricted/debian-installer
 +
deb http://mirrors.kernel.org/ubuntu feisty-updates main restricted
 +
deb http://mirrors.kernel.org/ubuntu feisty-security main restricted
 +
 
 +
clean http://mirrors.kernel.org/ubuntu
 +
</nowiki></pre>
 +
 
 +
You will need to modify your apt-mirror configuration file accordingly.  Often this file is located at /etc/apt/mirrors.list.  Note that not everyone chooses to mirror the security files unless the mirror updates regularly. 
 +
 
 +
If your mirror is configured to support netboot, the following directories should be present: 
 +
<pre><nowiki>
 +
/ubuntu/dists/feisty/restricted/debian-installer/
 +
/ubuntu/dists/feisty/main/debian-installer/
 +
</nowiki></pre>
 +
 
 +
If these portions of the file tree are not present on your mirror, the Feisty netboot installer displays a generic error screen beginning with the text "The installer failed to download a file from the mirror."
 +
 
 +
Surprisingly, my netboot installation of the Feisty server release set did not install openssh-server by default.  After all this work setting up netboot, it was back to the console again for a couple of minutes. 
 +
 
 +
----
 +
== Related Links ==
 +
 
 +
'''Pile of PXE related links'''
  
 
http://freshmeat.net/projects/syslinux/
 
http://freshmeat.net/projects/syslinux/
第228行: 第347行:
  
 
http://osdev.berlios.de/netboot.html - Network-booting Your Operating System - the part I like: "...loads the GRUB, the second-stage loader, off the server."  
 
http://osdev.berlios.de/netboot.html - Network-booting Your Operating System - the part I like: "...loads the GRUB, the second-stage loader, off the server."  
---
+
 
PPC Mac related links
+
'''PPC Mac related links'''
  
 
http://www.macgeekery.com/hacks/how_to_install_debian_via_network_boot_from_a_mac
 
http://www.macgeekery.com/hacks/how_to_install_debian_via_network_boot_from_a_mac
第237行: 第356行:
 
SmartBootManagerHowto
 
SmartBootManagerHowto
  
 +
----
 
[[category:CategoryDocumentation]] [[category:CategoryCleanup]]
 
[[category:CategoryDocumentation]] [[category:CategoryCleanup]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2007年11月22日 (四) 13:10的版本



Feisty Desktop Edition Install

This section (and perhaps this page) was correct for Feisty. It does not work for Gutsy.

The following describes how you can boot a machine into the Ubuntu Desktop Edition, using just its network card to "PXE netboot", via a tftp and nfs server. This means you can use the machine to run a LiveCD system, without actually needing any CD drive nor hard disk in the machine. The machine is effectively a diskless workstation at this point. You can then install Ubuntu onto its hard drive just as if you had a CD in its CD drive.

The way this works, in summary is: you do some configuring of some servers, so that your client machine will 'netboot' via pxe/bootp, get an ip address, get passed a boot kernel via tftp, will boot into that kernel, and it will display a menu screen to run a 'live-(pseudoCD)-install' on your client machine. You will have defined the menu item(s) for this menu, those being how to boot into a 'Live CD/install'. When you select the menu item, it boots a second kernel which takes you into the 'Live CD'.

Actually, to be precise, the boot kernel is a linux kernel and it is accompanied by the initial ramdisk image (initrd...). Each is a single file. Inside the initrd is the entire initial ramdisk including an init script. This script does the actual bootup and install. When we refer to a boot kernel on this page we should more precisely refer to the kernel and its partner initrd. They are a set that should be kept together.

Set up the servers

0. Ensure that you have a dhcp server (or a bootp server), a tftp (eg tftp-hpa) server, and an nfs server available on your network. If not, install them onto a machine (or over a set of machines if you want to complicate things). 0. Configure the dhcp server: Set the following options in dhcpd.conf on your DHCP server:

next-server 10.20.1.2; # this is your TFTP server
filename "pxelinux.0"; # put this in verbatim
or:

0. Configure a bootp server. If your router already provides dhcp, you might install and use a bootp server. The client machine's ip address will be assigned by the router. The ip address you try to assign with your bootp server will be ignored. Either way, your client machine will ask via pxe for an ip address, and will then be passed over to the tftpserver. 0. Install bootpd with Synaptic (package name = bootp) 0. Edit /etc/bootptab. Here is an example.

client:\
	td=/var/lib/tftpboot: hd=/: bf=pxelinux.0:\
	ip=192.168.1.4:\
	ha="00:1B:FC:58:69:69":\
	gw=192.168.1.1:\
	sm=255.255.255.0:
client:\
	td=/var/lib/tftpboot: hd=/: bf=pxelinux.0:\
	ip=192.168.1.42:\
	ha="00:00:39:2B:54:B5":\
	gw=192.168.1.1:\
	sm=255.255.255.0:
For further help: man bootpd; man bootptab and also found in the etc/bootptab file itself as comments.

If you don't know the hardware address, or which ip address dhcp will assign, start bootp and/or dhcp/router, get the hardware address from the client's startup screen and the ip address assigned by the router by browsing into the router after the first startup. Update /etc/bootptab with these good values, then restart bootpd.

0. Starting bootp: Here is a wrapper to start and stop bootpd from the command line.

#!/bin/bash
vDaemon=bootpd

Start () {
	/usr/sbin/$vDaemon -d 4 -c /var/lib/tftpboot >/tmp/$vDaemon.log 2>/tmp/$vDaemon.err &
}

Stop () {
	kill `pidof $vDaemon`
}

Status () {
	vPid="`pidof $vDaemon`"
	if [ "$vPid" ] ; then
		echo "$vDaemon running, pid=$vPid"
	else
		echo "$vDaemon not running"
	fi
}

case "$1" in
	start)	Start ;;
	stop)	Stop ;;
	restart) Stop ; sleep 2; Start ;;
	status) Status ;;
	""|*) echo `basename $0` parameter: start stop status or restart ;;
esac

Preparing Files for TFTP Net Booting, Section "Setting up BOOTP server" has more info on bootp, including instructions for starting bootp using the inetd alternative.

0. Configure the nfs server: 0. Download the Ubuntu Desktop .iso. 0. Mount the .iso and copy its contents to a directory on your nfs server. Eg if you use /home/ftp/..., you can also make the distro available via vs-ftpd, set for anonymous ftp. (This could include installing using an ftp server instead: another type of install, not covered here.) 0. Nfs-export the directory, (or one somewhere above it,) in /etc/exports so this directory is accessible via nfs. 0. Reload or restart the nfs server.

0. Configure the tftp server: 0. Download this tarfile from the Ubuntu Archives, and extract its contents into the tftpboot directory on your tftp server. 0. Copy vmlinuz and initrd.gz from the /casper directory of the Ubuntu Desktop .iso to the tftpboot directory. Rename them if you wish, eg vmlinuz.fromUbuntu704DesktopCd, initrd.gz.fromUbuntu704DesktopCd. This is the kernel and initrd that you will select to load as your 'live CD' session. Eg

cp -a /home/ftp/ubuntu704DesktopCd/casper/vmlinuz /var/lib/ftfpboot/vmlinuz.fromUbuntu704DesktopCd
cp -a /home/ftp/ubuntu704DesktopCd/casper/initrd.gz /var/lib/ftfpboot/initrd.gz.fromUbuntu704DesktopCd
Note the use of -a so you preserve the timestamp. This helps clarify later which version kernel you are using.

0. Edit a menu LABEL entry in pxelinux.cfg/default to point to the kernel and initrd from the previous step. Also edit in options to tell casper to mount to it via NFS, eg as per the following 5 lines:

1 DEFAULT LiveDesktopCD
2
3 LABEL LiveDesktopCD
4 kernel vmlinuz.fromUbuntu704DesktopCd
5 append initrd=initrd.gz.fromUbuntu704DesktopCd boot=casper netboot=nfs nfsroot=192.168.1.40:/home/ftp/ubuntu704DesktopCd --

(The 5th line is long and might appear split here. Join them in your pxelinux.cfg/default.) nfsroot points to your NFS server and the path to the directory where you copied all the contents of the CD. 0. Its useful to also edit the boot-screens/boot.txt to make the startup menu look different to the standard installation startup, and boot-screens/F3 file to document your use of the casper kernel.

(More background info is at Preparing Files for TFTP Net Booting).

Net-boot your client machine.

0. The tftpboot server passes the client the boot kernel, as described in the intro. The boot kernel presents an installation screen, or menu, which looks similar to the first pre-installation screen of the Desktop live CD. You will be presented with the installation startup menu described above. If you have set up the LABEL lines correctly, simply hit [Enter].

0. The installation kernel does a simple install to RAM and starts Gnome. You get a desktop with an icon to Install to hard disk. If you start this icon, the full hard disk install proceeds. If not, you simply run a 'Live Cd' session in RAM (without the actual CD).

Technical Note: About Casper

"Casper is a hook for initramfs-tools used to generate an initramfs capable to boot live systems as those created by make-live. This includes the Debian-Live isos, netboot tarballs, and usb stick images and Ubuntu live cds. At boot time it will look for a (read-only) media containing a "/casper" directory where a root filesystems (often a compressed squashfs) is stored. If found, it will create a writable environment, using unionfs, for debian-like systems to boot from." man casper for more information.

Basic: Hands-On Interactive Network Server Edition Install

These steps allow you to install an Ubuntu distro from over your network, as if you had booted and installed it from the Ubuntu installation CD. This is almost a rewrite of the above, except its using http via Apache instead of nfs. Moreover, it does not use Casper so it does not result in a live system. Instead the client boots into an installer.)

Services needed, on a server (or servers) : 0. dhcp or bootp: to provide netboot server support, 0. tftp: to feed the first boot image to the netboot client machine, when requested by the netboot server, 0. http, ftp or nfs: to supply the Ubuntu distro to the client machine during the installation process. 0. The client machine must be able to boot from its network card, else from a diskette that you built to 'netboot'.

This page focusses on the combination of dhcp, tftp, and http. In the examples below 'myserver' is the server for these 3 services. (Each of these can be run on a separate server if desired.)

0.#1 Install and configure the dhcp server. Eg to install:

root@myserver:~ # apt-get install dhcp3-server

Configure the dhcp server to tell the clients what to boot. I added a default host name, you don't need it but it comes in handy for other things.

root@myserver:~ # cat /etc/dhcp3/dhcpd.conf
subnet 192.168.1.0  netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.254;
}
# put your DNS IP's here:
option domain-name-servers 192.168.1.7, 68.87.66.196 ;
filename="ubuntu/feisty/alternate/install/netboot/pxelinux.0";

root@myserver:~ # /etc/init.d/dhcp3-server restart
Stopping DHCP server: dhcpd3.
Starting DHCP server: dhcpd3.

0.#2 Install and configure the Trivial File Transfer Protocol server. The tftpd-hpa package is recommended. Install it. It is enabled via /etc/default/tftpd-hpa,

RUN_DAEMON="yes"
OPTIONS="-l -s /var/lib/tftpboot"
Also note its base directory. The default setting is shown above.

Mount the CD (media or image) under the tftpboot base directory found above,eg

root@myserver:/var/lib/tftpboot/ubuntu/feisty$ mount -o loop feisty-alternate-i386.iso alternate/ 
or, you can instead copy the contents of the CD into that location, instead of leaving the ISO mounted.

See Preparing Files for TFTP Net Booting for detailed information.

0.#3 Install and configure Apache, eg:

root@myserver:~ # apt-get install apache2

Make a symlink from apache's doc Root to the CD

root@myserver:/var/www # ln -s /var/lib/tftpboot/ubuntu/
Or copy the /ubuntu directory from the CD into here.

To use a pure ftp server like the vs-ftp server instead of Apache, install the ftp server, and configure it for anonymous ftp access. Then copy the /ubuntu directory from the CD into the anonymous ftp home. With vs-ftpd, this is set to /home/ftp. (Check /etc/passwd to confirm the anonymous ftp home.) Next test that anonymous ftp works and finds the installation stuff. eg via 'ftp localhost' on that machine. The install needs to be done in 'expert' mode, so you can select the ftp protocol instead of the default 'http'. 0.#4 Boot up the client machine, set its bios to net boot and you should get the Ubuntu screen and Boot: prompt. Yippee!


Advanced: Hands-Off, Preseeded Network Server Install

The above is for an interactive install, just as if you booted from CD. The following addresses preseeding, which enables a Hands Off Install where all the questions have been answered and fed to the installer. In addition, the following does not pull anything from the Internet.

A handful of preseed options need to be passed via kernel options. The kernel only supports 255 chars, so things are cramped. To accommodate this, I dumped some of the paths and made symlinks. That gave me just enough space for now. Note that the path/name of the kernel gets appended, so even trimming that helped.

root@sahara:/var/lib/tftpboot # ln -s ubuntu-installer/i386/initrd.gz
root@sahara:/var/lib/tftpboot # ln -s ubuntu-installer/i386/linux

/var/lib/tftpboot/pxelinux.cfg/default

# pxelinux.cfg/default

# display u0buntu-installer/i386/boot-screens/syslinux.txt

default menu
prompt 1
timeout 150
ontimeout boothd

label menu
# makes a menu out of this file, allows editing the options on the client
kernel menu.c32

label boothd
# boot from the first HD
# (this is what happens if nothing is pressed for 15 seconds)
localboot 0

label ubuntu-feisty-normal
# ubuntu installer
kernel ubuntu-feisty/linux
append vga=normal initrd=ubuntu-feisty/initrd.gz ramdisk_size=14984 root=/dev/rd/0 rw  --

label ubuntu-feisty-hands-off
# ubuntu installer
# The 'kernel' and 'initrd' paths must identify files under tftpboot.
# For example, on my system I have /var/lib/tftpboot/ubuntu-feisty/linux and /var/lib/tftpboot/ubuntu-feisty/initrd.gz.
kernel ubuntu-feisty/linux
append initrd=ubuntu-feisty/initrd.gz ramdisk_size=14984 root=/dev/rd/0 rw preseed/locale=en_US kbd-chooser/method=us netcfg/wireless_wep= netcfg/choose_interface=eth0 netcfg/get_hostname= preseed/url=http://192.168.1.7/preseed-feisty.cfg vga=6 --

netcfg/get_hostname= Is blank so that it will pick up the host-name supplied by the DHCP server.

netcfg/choose_interface=eth0 - You may wish to specify eth1 or wlan0 for laptops if you want it to setup the wifi card, not the wired port.

Note for client-specific PXE configurations: The DHCP server can't pass it, but pretending that the MAC address of your wireless card is 12 : CD : 56 : AB : 78 : EF you can specify a custom pxelinux.cfg/01-12-dc-56-ab-78-ef (lowercase) instead. If you are using static dhcp, you can also use the IP address in hex for a per-machine or per-subnet or per-network configuration. See http://syslinux.zytor.com/pxe.php#config for more information. Basically, say you have three wireless cards where the IP in hex translated to caf12d5e, caf12d6b, caf124ea, you could specify pxelinux.cfg/caf12d and pxelinux.cfg/caf12. The first two would match to the first config file and the third would match to the second config file.

See http://www.debian.org/releases/etch/example-preseed.txt for an example preseed file, and be sure to note the debconf-get-selections example commands. Here are the important changes for using the copy of the install CD on your server instead of the Internet repositories during the install:

d-i	mirror/country		string enter information manually
d-i	mirror/http/hostname	string sahara # This is whatever HTTP server you have set up
d-i	mirror/http/directory	string /ubuntu # This is the /ubuntu directory from the install CD copied (or linked) under the webroot of your HTTP server
d-i	mirror/suite		string feisty # Name your ubuntu version here
d-i	mirror/http/proxy	string 


Here is my current dhcpd.conf

ping-check = 1;
log-facility local7;

option domain-name "sahara.net";
option time-servers  192.168.1.1;
option broadcast-address 192.168.1.255;

option domain-name-servers 63.240.76.4, 204.127.198.4;
option routers  192.168.1.1;

subnet 192.168.1.0  netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.254;
}

# Hoary test boxes
group {
	filename="pxelinux.0" ;

	# You need a next-server option if TFTP and DHCPd aren't on the same system.
	next-server sahara;
	
	# 192.168.1.2 does not exist on my lan.
	# I am setting it like this to make sure the box doesn't find
	# a repo on the net to pull sources from.
	# It would be good I can figure out how to i
	#  limit these setting to the install phase 
	#  (including the 2nd part after the reboot )
	
	option domain-name-servers 192.168.1.2 ;
	option routers 192.168.1.2 ;

	host dwl650p { 
		hardware ethernet 00:05:5d:5a:81:f0 ; 
		option host-name "dwl650p" ; }
	
	# tsp2 6100 - a=wired, b=wifi
	host tsp2a { 
		hardware ethernet 00:00:39:fa:ff:f3 ;
		option host-name "tsp2a" ; }
	
	host tsp2b { 
		hardware ethernet 00:02:2d:b0:c8:6c ;
		option host-name "tsp2b" ; }

	host tsp1 { 
		hardware ethernet 00:00:39:88:31:a6 ; 
		option host-name "tsp1" ; }

host e400 { 

		hardware ethernet 00:60:08:b0:62:0d ; 
		# fixed-address 192.168.1.181 ;
		option host-name "e400" ; }

}

If your box doesn't have the option to boot from lan (like one of mine) you can make a boot disk that will do that part.

http://etherboot.sourceforge.net

http://rom-o-matic.net

I am pleased to say that I was able to read, download, build, run, make the floppy in under 30 min.

"Etherboot does not (yet) offer support for PCMCIA cards." so the older laptops will have to wait.


Advanced: Network install using apt-mirror

apt-mirror is a Perl script for maintaining a mirror of the Debian or Ubuntu installation sets. It is often set up as a cron job to download updates to the mirror automatically. Updates are downloaded incrementally using parallel threads. Contents of the mirror are typically served via a web server to the local network.

apt-mirror can be installed on most Unix machine from the tarball. On Debian or Ubuntu, the apt-mirror package can usually be installed by apt-get with the appropriate addition to sources.list. See the apt-mirror project home page for details.

For basic instructions pertaining to Ubuntu, see How To Create A Local Debian/Ubuntu Mirror With apt-mirror. Some modifications are required to the mirror configuration to work in conjunction with netboot. Netboot requires debian-installer. The following snippet from an example configuration is reported to work:

deb http://mirrors.kernel.org/ubuntu feisty main main/debian-installer restricted restricted/debian-installer
deb http://mirrors.kernel.org/ubuntu feisty-updates main restricted
deb http://mirrors.kernel.org/ubuntu feisty-security main restricted

clean http://mirrors.kernel.org/ubuntu

You will need to modify your apt-mirror configuration file accordingly. Often this file is located at /etc/apt/mirrors.list. Note that not everyone chooses to mirror the security files unless the mirror updates regularly.

If your mirror is configured to support netboot, the following directories should be present:

/ubuntu/dists/feisty/restricted/debian-installer/
/ubuntu/dists/feisty/main/debian-installer/

If these portions of the file tree are not present on your mirror, the Feisty netboot installer displays a generic error screen beginning with the text "The installer failed to download a file from the mirror."

Surprisingly, my netboot installation of the Feisty server release set did not install openssh-server by default. After all this work setting up netboot, it was back to the console again for a couple of minutes.


Related Links

Pile of PXE related links

http://freshmeat.net/projects/syslinux/

http://syslinux.zytor.com/memdisk.php

http://support.3com.com/infodeli/tools/nic/mba.htm New Universal NDIS Driver for DOS

http://www.qualystem.com/en/dualboot.html

http://unattended.sourceforge.net/step-by-step.php

http://unattended.sourceforge.net/advanced.php#pxe

http://syslinux.zytor.com/archives/2003-June/002185.html

http://www.intel.com/design/network/drivers/int21143.htm

http://www.tux.org/pub/distributions/tinylinux/tomsrtbt/

http://www.winimage.com/winimage.htm

http://www.weird-solutions.com/docs/pxe_booting.pdf

http://www.weird-solutions.com/bin/util/tftp_root.zip

http://etherboot.sourceforge.net

http://marc.herbert.free.fr/linux/win2linstall.html Install GNU/Linux without any CD, floppy, USB-key, nor any other removable media.

http://osdev.berlios.de/netboot.html - Network-booting Your Operating System - the part I like: "...loads the GRUB, the second-stage loader, off the server."

PPC Mac related links

http://www.macgeekery.com/hacks/how_to_install_debian_via_network_boot_from_a_mac

http://davespicks.com/writing/programming/mackeys.html#boot

SmartBootManagerHowto