“UbuntuHelp:Installation/OnNFSDriveWithLocalBoot”的版本间的差异
来自Ubuntu中文
小 (新页面: {{From|https://help.ubuntu.com/community/Installation/OnNFSDriveWithLocalBoot}} {{Languages|UbuntuHelp:Installation/OnNFSDriveWithLocalBoot}} This article describes how to install Feisty ...) |
小 |
||
(未显示同一用户的8个中间版本) | |||
第2行: | 第2行: | ||
{{Languages|UbuntuHelp:Installation/OnNFSDriveWithLocalBoot}} | {{Languages|UbuntuHelp:Installation/OnNFSDriveWithLocalBoot}} | ||
This article describes how to install Feisty onto a machine that has a hard drive (Or, as I'll be doing, A CompactFlash (CF) card) for /boot only with root being on an NFS share somewhere on the network. | This article describes how to install Feisty onto a machine that has a hard drive (Or, as I'll be doing, A CompactFlash (CF) card) for /boot only with root being on an NFS share somewhere on the network. | ||
− | + | First off, you'll want a MiniCD ([[UbuntuHelp:Installation/MinimalCD|Installation/MinimalCD]]) to install the base system. The base system when installed takes up about 850MB, so make sure your drive or CF card has enough space to handle this. You may prefer to install to hard drive first and transfer /boot to CF later on. | |
− | First off, you'll want a MiniCD ([[UbuntuHelp:Installation/MinimalCD]]) to install the base system. The base system when installed takes up about 850MB, so make sure your drive or CF card has enough space to handle this. You may prefer to install to hard drive first and transfer /boot to CF later on. | + | |
− | + | ||
Minimal install is pretty textbook, don't select any of the extra (BIND, LAMP, Xubuntu etc) packages yet, just get the base system installed. Note that when partitioning, you'll want to disable swap and ensure /boot has its own partition (100MB is more than enough). | Minimal install is pretty textbook, don't select any of the extra (BIND, LAMP, Xubuntu etc) packages yet, just get the base system installed. Note that when partitioning, you'll want to disable swap and ensure /boot has its own partition (100MB is more than enough). | ||
− | |||
Once you are booted into your minimal install, login and: | Once you are booted into your minimal install, login and: | ||
− | |||
<pre><nowiki> | <pre><nowiki> | ||
sudo su - | sudo su - | ||
第15行: | 第11行: | ||
mount -tnfs -onolock 192.168.0.15:/mnt/storage/NFS jarlsbergNFS/ | mount -tnfs -onolock 192.168.0.15:/mnt/storage/NFS jarlsbergNFS/ | ||
</nowiki></pre> | </nowiki></pre> | ||
− | + | You may want to install also nfs-common and smbfs packages if you have problems to mount the nfs: | |
+ | <pre><nowiki> | ||
+ | sudo apt-get install nfs-common smbfs | ||
+ | </nowiki></pre> | ||
This relies on there being a working NFS server on 192.168.0.15. The /etc/exports on that machine reads: | This relies on there being a working NFS server on 192.168.0.15. The /etc/exports on that machine reads: | ||
− | |||
<pre><nowiki> | <pre><nowiki> | ||
# /etc/exports: the access control list for filesystems which may be exported | # /etc/exports: the access control list for filesystems which may be exported | ||
第23行: | 第21行: | ||
/mnt/storage 192.168.0.1/24(rw,no_root_squash,async) | /mnt/storage 192.168.0.1/24(rw,no_root_squash,async) | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Now you want to copy the current (mini) install over to the NFS server: | Now you want to copy the current (mini) install over to the NFS server: | ||
<pre><nowiki> | <pre><nowiki> | ||
cp -ax /. jarlsbergNFS/ | cp -ax /. jarlsbergNFS/ | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
And make the NFS install our working directory: | And make the NFS install our working directory: | ||
<pre><nowiki> | <pre><nowiki> | ||
cd jarlsbergNFS/ | cd jarlsbergNFS/ | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
And now for some hackery. We need to add /proc and /sys to fstab if they do not exist already. Note there is no first / on /etc/fstab. We're editing the copy on the NFS server. You will also want to comment out the entries for / and swap, but leave /boot as it is. | And now for some hackery. We need to add /proc and /sys to fstab if they do not exist already. Note there is no first / on /etc/fstab. We're editing the copy on the NFS server. You will also want to comment out the entries for / and swap, but leave /boot as it is. | ||
<pre><nowiki> | <pre><nowiki> | ||
第41行: | 第36行: | ||
sys /sys sysfs defaults 0 0 | sys /sys sysfs defaults 0 0 | ||
</nowiki></pre> | </nowiki></pre> | ||
− | + | There is currently a bug in [[UbuntuHelp:NetworkManager|NetworkManager]] that means even though the machine gets an IP just fine from the kernel booting the network IF goes down and up again. This is bad, we don't want the network to go down while trying to read files over the network! | |
− | There is currently a bug in NetworkManager that means even though the machine gets an IP just fine from the kernel booting the network IF goes down and up again. This is bad, we don't want the network to go down while trying to read files over the network! | + | |
− | + | ||
A quick hack is... | A quick hack is... | ||
<pre><nowiki> | <pre><nowiki> | ||
第49行: | 第42行: | ||
Comment out the lines for eth0 (Or whatever your ethernet card is called) | Comment out the lines for eth0 (Or whatever your ethernet card is called) | ||
</nowiki></pre> | </nowiki></pre> | ||
− | + | We also need to do this to stop [[UbuntuHelp:NetworkManager|NetworkManager]] messing with the network card. Bit of a hack... | |
− | We also need to do this to stop NetworkManager messing with the network card. Bit of a hack... | + | |
<pre><nowiki> | <pre><nowiki> | ||
vim etc/default/NetworkManager | vim etc/default/NetworkManager | ||
第56行: | 第48行: | ||
Add a line with "exit" to both files | Add a line with "exit" to both files | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
We now need to generate an NFS'able initramfs. (Note the first / means we're editing the local copy.) | We now need to generate an NFS'able initramfs. (Note the first / means we're editing the local copy.) | ||
<pre><nowiki> | <pre><nowiki> | ||
第63行: | 第54行: | ||
Edit BOOT=local to read BOOT=nfs | Edit BOOT=local to read BOOT=nfs | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Before we update the init images, we should back up the current ones just so we can still get back into the local install if ever anything goes horribly wrong... | Before we update the init images, we should back up the current ones just so we can still get back into the local install if ever anything goes horribly wrong... | ||
<pre><nowiki> | <pre><nowiki> | ||
第69行: | 第59行: | ||
mv initrd.img-2.6.20-16-generic initrd.img-2.6.20-16-generic-OLD | mv initrd.img-2.6.20-16-generic initrd.img-2.6.20-16-generic-OLD | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Now we want to update the initramfs image: | Now we want to update the initramfs image: | ||
<pre><nowiki> | <pre><nowiki> | ||
update-initramfs -k all -c | update-initramfs -k all -c | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
We (should!) have a new image called initrd.img-2.6.20-16-generic in /boot. We want this to be the NFS one. | We (should!) have a new image called initrd.img-2.6.20-16-generic in /boot. We want this to be the NFS one. | ||
<pre><nowiki> | <pre><nowiki> | ||
第80行: | 第68行: | ||
mv initrd.img-2.6.20-16-generic-OLD initrd.img-2.6.20-16-generic | mv initrd.img-2.6.20-16-generic-OLD initrd.img-2.6.20-16-generic | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Now we need to edit grubs menu to make it boot from NFS rather than the local drive. You can substitute in an IP address rather than letting kernel sort the IP, but doing things by dhcp means things like nameservers will be set up for you (Provided your dhcp server is set up nicely! :-) | Now we need to edit grubs menu to make it boot from NFS rather than the local drive. You can substitute in an IP address rather than letting kernel sort the IP, but doing things by dhcp means things like nameservers will be set up for you (Provided your dhcp server is set up nicely! :-) | ||
<pre><nowiki> | <pre><nowiki> | ||
第90行: | 第77行: | ||
initrd /initrd.img-2.6.20-16-generic-NFS | initrd /initrd.img-2.6.20-16-generic-NFS | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Now you might want to change back your initramfs.conf, just in case you want to get back to your non-NFS mini-install. | Now you might want to change back your initramfs.conf, just in case you want to get back to your non-NFS mini-install. | ||
<pre><nowiki> | <pre><nowiki> | ||
第96行: | 第82行: | ||
Change BOOT=nfs to BOOT=local | Change BOOT=nfs to BOOT=local | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Now you should be able to reboot, select the NFS boot grub option you added to menu.lst and boot into root-over-NFS ubuntu! Note that you will only have CLI access with very limited tools. So check you are up to date...: | Now you should be able to reboot, select the NFS boot grub option you added to menu.lst and boot into root-over-NFS ubuntu! Note that you will only have CLI access with very limited tools. So check you are up to date...: | ||
<pre><nowiki> | <pre><nowiki> | ||
第102行: | 第87行: | ||
sudo apt-get upgrade | sudo apt-get upgrade | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
And then install a flavour of ubuntu: | And then install a flavour of ubuntu: | ||
<pre><nowiki> | <pre><nowiki> | ||
第113行: | 第97行: | ||
xubuntu-desktop - Xubuntu desktop system | xubuntu-desktop - Xubuntu desktop system | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Hopefully by now you should have a working ubuntu desktop machine, with /boot on a small partition on hard drive (Or CompactFlash!) and everything else on your NFS server. | Hopefully by now you should have a working ubuntu desktop machine, with /boot on a small partition on hard drive (Or CompactFlash!) and everything else on your NFS server. | ||
− | |||
You may wish to add swap to the machine; I ran into the problem of not having a local swap partition and having fun getting swap-over-NFS working. What follows are some instructions for getting nbd working. nbd (Network Block Device) allows you to sort-of do block devices over ethernet :). Seeing as linux kernel doesn't allow for swap-over-NFS, this seems to be the easiest way to get root over NFS with remote swap. | You may wish to add swap to the machine; I ran into the problem of not having a local swap partition and having fun getting swap-over-NFS working. What follows are some instructions for getting nbd working. nbd (Network Block Device) allows you to sort-of do block devices over ethernet :). Seeing as linux kernel doesn't allow for swap-over-NFS, this seems to be the easiest way to get root over NFS with remote swap. | ||
− | |||
Note that this _very_ buggy and can cause a lot of problems. I'm running without swap on my box and it seems to be fine :-) | Note that this _very_ buggy and can cause a lot of problems. I'm running without swap on my box and it seems to be fine :-) | ||
− | |||
On your server, you'll want to grab the nbd-server package. | On your server, you'll want to grab the nbd-server package. | ||
<pre><nowiki> | <pre><nowiki> | ||
apt-get install nbd-server | apt-get install nbd-server | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Now you'll want to make some swap space. cd to your root-over-NFS root directory and mess around a bit. | Now you'll want to make some swap space. cd to your root-over-NFS root directory and mess around a bit. | ||
<pre><nowiki> | <pre><nowiki> | ||
第132行: | 第111行: | ||
chmod 777 swap | chmod 777 swap | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Still on the server, you'll want to initialise the nbd-server. | Still on the server, you'll want to initialise the nbd-server. | ||
<pre><nowiki> | <pre><nowiki> | ||
nbd-server 1100 /mnt/jarlsbergNFS/swap/swap | nbd-server 1100 /mnt/jarlsbergNFS/swap/swap | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Now back on your client machine (Replacing the IP with that of the server) | Now back on your client machine (Replacing the IP with that of the server) | ||
<pre><nowiki> | <pre><nowiki> | ||
第143行: | 第120行: | ||
nbd-client 192.168.0.33 1100 /dev/nbd0 | nbd-client 192.168.0.33 1100 /dev/nbd0 | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
And now you will want to make this block device into swap, mount it and check everything is okay: | And now you will want to make this block device into swap, mount it and check everything is okay: | ||
<pre><nowiki> | <pre><nowiki> | ||
第152行: | 第128行: | ||
>>/dev/nbd0 partition 262136 0 -1 | >>/dev/nbd0 partition 262136 0 -1 | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
Having swap on a machine somewhere else on the network is going to get pretty slow when your machine does start to swap, so you are better off having lots and lots of RAM rather than relying on swap. | Having swap on a machine somewhere else on the network is going to get pretty slow when your machine does start to swap, so you are better off having lots and lots of RAM rather than relying on swap. | ||
− | |||
Done! | Done! | ||
---- | ---- | ||
− | [[category: | + | [[category:CategoryInstallation]] [[category:CategoryNetworking]] |
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2008年12月16日 (二) 18:58的最新版本
点击翻译: |
English |
请不要直接编辑翻译本页,本页将定期与来源同步。 |
This article describes how to install Feisty onto a machine that has a hard drive (Or, as I'll be doing, A CompactFlash (CF) card) for /boot only with root being on an NFS share somewhere on the network. First off, you'll want a MiniCD (Installation/MinimalCD) to install the base system. The base system when installed takes up about 850MB, so make sure your drive or CF card has enough space to handle this. You may prefer to install to hard drive first and transfer /boot to CF later on. Minimal install is pretty textbook, don't select any of the extra (BIND, LAMP, Xubuntu etc) packages yet, just get the base system installed. Note that when partitioning, you'll want to disable swap and ensure /boot has its own partition (100MB is more than enough). Once you are booted into your minimal install, login and:
sudo su - cd /mnt/ mkdir jarlsbergNFS/ mount -tnfs -onolock 192.168.0.15:/mnt/storage/NFS jarlsbergNFS/
You may want to install also nfs-common and smbfs packages if you have problems to mount the nfs:
sudo apt-get install nfs-common smbfs
This relies on there being a working NFS server on 192.168.0.15. The /etc/exports on that machine reads:
# /etc/exports: the access control list for filesystems which may be exported # to NFS clients. See unfsd(8). /mnt/storage 192.168.0.1/24(rw,no_root_squash,async)
Now you want to copy the current (mini) install over to the NFS server:
cp -ax /. jarlsbergNFS/
And make the NFS install our working directory:
cd jarlsbergNFS/
And now for some hackery. We need to add /proc and /sys to fstab if they do not exist already. Note there is no first / on /etc/fstab. We're editing the copy on the NFS server. You will also want to comment out the entries for / and swap, but leave /boot as it is.
vim etc/fstab Add the lines: proc /proc proc defaults 0 0 sys /sys sysfs defaults 0 0
There is currently a bug in NetworkManager that means even though the machine gets an IP just fine from the kernel booting the network IF goes down and up again. This is bad, we don't want the network to go down while trying to read files over the network! A quick hack is...
vim etc/network/interfaces Comment out the lines for eth0 (Or whatever your ethernet card is called)
We also need to do this to stop NetworkManager messing with the network card. Bit of a hack...
vim etc/default/NetworkManager vim etc/default/NetworkManagerDispatcher Add a line with "exit" to both files
We now need to generate an NFS'able initramfs. (Note the first / means we're editing the local copy.)
cd /etc/initramfs-tools/ vim initramfs.conf Edit BOOT=local to read BOOT=nfs
Before we update the init images, we should back up the current ones just so we can still get back into the local install if ever anything goes horribly wrong...
cd /boot mv initrd.img-2.6.20-16-generic initrd.img-2.6.20-16-generic-OLD
Now we want to update the initramfs image:
update-initramfs -k all -c
We (should!) have a new image called initrd.img-2.6.20-16-generic in /boot. We want this to be the NFS one.
mv initrd.img-2.6.20-16-generic initrd.img-2.6.20-16-generic-NFS mv initrd.img-2.6.20-16-generic-OLD initrd.img-2.6.20-16-generic
Now we need to edit grubs menu to make it boot from NFS rather than the local drive. You can substitute in an IP address rather than letting kernel sort the IP, but doing things by dhcp means things like nameservers will be set up for you (Provided your dhcp server is set up nicely! :-)
vim /boot/grub/menu.lst Add the lines: title Ubuntu, NFS Boot (POLARIS), kernel 2.6.20-16-generic root (hd0,5) kernel /vmlinuz-2.6.20-16-generic root=/dev/nfs nfsroot=192.168.0.15:/mnt/storage/NFS ip=dhcp initrd /initrd.img-2.6.20-16-generic-NFS
Now you might want to change back your initramfs.conf, just in case you want to get back to your non-NFS mini-install.
vim /etc/initramfs-tools/initramfs.conf Change BOOT=nfs to BOOT=local
Now you should be able to reboot, select the NFS boot grub option you added to menu.lst and boot into root-over-NFS ubuntu! Note that you will only have CLI access with very limited tools. So check you are up to date...:
sudo apt-get update sudo apt-get upgrade
And then install a flavour of ubuntu:
sudo apt-get install <something> (Alternatives...) edubuntu-desktop - edubuntu desktop system kubuntu-desktop - Kubuntu desktop system ubuntu-desktop - The Ubuntu desktop system xubuntu-desktop - Xubuntu desktop system
Hopefully by now you should have a working ubuntu desktop machine, with /boot on a small partition on hard drive (Or CompactFlash!) and everything else on your NFS server. You may wish to add swap to the machine; I ran into the problem of not having a local swap partition and having fun getting swap-over-NFS working. What follows are some instructions for getting nbd working. nbd (Network Block Device) allows you to sort-of do block devices over ethernet :). Seeing as linux kernel doesn't allow for swap-over-NFS, this seems to be the easiest way to get root over NFS with remote swap. Note that this _very_ buggy and can cause a lot of problems. I'm running without swap on my box and it seems to be fine :-) On your server, you'll want to grab the nbd-server package.
apt-get install nbd-server
Now you'll want to make some swap space. cd to your root-over-NFS root directory and mess around a bit.
cd /mnt/jarlsbergNFS/ mkdir swap/ dd if=/dev/zero of=swap/swap count=256 bs=1024k chmod 777 swap
Still on the server, you'll want to initialise the nbd-server.
nbd-server 1100 /mnt/jarlsbergNFS/swap/swap
Now back on your client machine (Replacing the IP with that of the server)
apt-get install nbd-client nbd-client 192.168.0.33 1100 /dev/nbd0
And now you will want to make this block device into swap, mount it and check everything is okay:
mkswap /dev/nbd0 swapon /dev/nbd0 cat /proc/swaps >>Filename Type Size Used Priority >>/dev/nbd0 partition 262136 0 -1
Having swap on a machine somewhere else on the network is going to get pretty slow when your machine does start to swap, so you are better off having lots and lots of RAM rather than relying on swap. Done!