LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2092|回复: 4

linux无盘求助

[复制链接]
发表于 2007-12-20 15:53:06 | 显示全部楼层 |阅读模式
小菜我在配一个linux无盘工作站,开始按照网络上到说明使用mknbi-linux命令处理内核,结果一开始加载内核就花屏了,后来在网上查到要用initrd.img来安装,使用任意内核(自己编译或系统自带)+系统盘的initrd.img可以启动,但是启动后就进入了安装界面;如果换一个initrd.img文件,load 完内核之后就会报找不到initrd.img文件了(我再三确认过,initrd.img文件名没有写错)。  
    如果干脆不用initrd.img或者用系统安装盘里面某些initrd.img则无盘加载一半过后报错:Kernel panic - not syncing:No init found Try passing init = option to kernel
    我猜可能算initrd.img的设置问题,可是小菜我不知道怎么配置,请各位大侠帮帮忙,万分感激!!!!
pxe配置文件入下
default linux
label linux
kernel vmlinuz
#append initrd=initrd.img devfs=nomount
append initrd=initrd.img ip=dhcp root=/dev/nfsroot  nfsroot=192.168.0.123:/remote/blade01 vga=normal
    我的export  tftp  dhcp配置文件入下:
/remote/blade01 *(rw,async,no_root_squash)  
/remote/blade02 *(rw,async,no_root_squash)  
/usr *(ro,async,no_root_squash)  
/sbin *(ro,async,no_root_squash)  
/bin *(ro,async,no_root_squash)  
/lib *(ro,async,no_root_squash)  
/home *(ro,async,no_root_squash)


allow booting;
allow bootp;
host blade01 {
     hardware ethernet 00:85:20:05:09:76;
     fixed-address 192.168.0.199;
#     server-name "192.168.0.123";
#     next-server 192.168.0.123;
          filename "/pxelinux.0";
#                filename "/boot.eb";
}

service tftp
{
        disable        = no
        socket_type                = dgram
        protocol                = udp
        wait                        = yes
        user                        = root
        server                        = /usr/sbin/in.tftpd
        server_args                = -s /tftpboot
        per_source                = 11
        cps                        = 100 2
        flags                        = IPv4
}
 楼主| 发表于 2007-12-20 20:02:36 | 显示全部楼层

自己顶

怎么没高手来啊,无自己来顶!
   我用DRBL的initrd.img做参考又稍微往前面推进了一点点,可是在在这对之前挂载的虚拟文件系统与dev转移到主系统:mount --move /dev /root/dev 的时候报错了,dev怎么也挂不上去,最后报错:switch root:can't open '/dev/console': No such file or directory
   请哪位高人帮帮忙啊.
回复 支持 反对

使用道具 举报

发表于 2007-12-23 05:31:46 | 显示全部楼层
[原创]无盘ubuntu详细笔记

前言
1> 系统
服务器系统为ubuntu 7.10desktop版本(因为我全部是在虚拟机测试的,这个系统是以前安装好了的)
Linux ubuntu 2.6.22-14-generic
无盘客户机的系统为ubuntu 7.10 server版本
Linux netfs 2.6.22-14-server

第一步 安装tftp服务器
tftpd

1 安装

root@ubuntu:/# apt-get install tftpd-hpa
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
Reading state information... 完成
下列【新】软件包将被安装:
tftpd-hpa
共升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 0 个软件未被升级。
需要下载 34.0kB 的软件包。
解压缩后会消耗掉 152kB 的额外空间。
获取:1 http://Ubuntu.cn99.com gutsy/main tftpd-hpa 0.43-1.1ubuntu1 [34.0kB]
下载 34.0kB,耗时 5s (5921B/s)
正在预设定软件包 ...
选中了曾被取消选择的软件包 tftpd-hpa。
(正在读取数据库 ... 系统当前总共安装有 112536 个文件和目录。)
正在解压缩 tftpd-hpa (从 .../tftpd-hpa_0.43-1.1ubuntu1_i386.deb) ...
正在设置 tftpd-hpa (0.43-1.1ubuntu1) ...

root@ubuntu:/#

2 设置tftpd
root@ubuntu:~# nano /etc/default/tftpd-hpa
#Defaults for tftpd-hpa
RUN_DAEMON="yes"

#上面这句表示启动守护进程,tftpd工作
OPTIONS="-l -s /var/lib/tftpboot"
#上面这句表示tftp客户端能取得的文件所存放的位置

3 启动服务

root@ubuntu:/# /etc/init.d/tftpd-hpa start
Starting HPA's tftpd: in.tftpd.
root@ubuntu:/# ps aux|grep tftp
root 26853 0.0 0.1 2196 288 ? Ss 17:26 0:00 /usr/sbin/in.tftpd -l -s /var/lib/tftpboot
root 26862 0.0 0.2 3180 748 pts/1 R+ 17:27 0:00 grep tftp
root@ubuntu:/#

4 查看服务是否开始工作

root@ubuntu:/# netstat -pna|grep tft
udp 0 0 0.0.0.0:69 0.0.0.0:* 26853/in.tftpd
unix 2 [ ] DGRAM 164700 26853/in.tftpd
root@ubuntu:/#

情灭缘尽
2007.12.21

第二步 安装dhcp服务器
dhcpd

1 服务器环境

root@ubuntu:/# uname -a
Linux ubuntu 2.6.22-14-generic #1 SMP Sun Oct 14 23:05:12 GMT 2007 i686 GNU/Linux
root@ubuntu:/#

2 安装命令 ---我下面是已经安装好了的,如果没有安装好的输入命令apt-get install dhcp3-server 就可以了
root@ubuntu:/# apt-get install dhcp3-server
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
Reading state information... 完成
dhcp3-server 已经是最新的版本了。
共升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件未被升级。

3 设置dhcpd工作接口

root@ubuntu:~# nano /etc/default/dhcp3-server
# Defaults for dhcp initscript
# sourced by /etc/init.d/dhcp
# installed at /etc/default/dhcp3-server by the maintainer scripts

#
# This is a POSIX shell fragment
#

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".

# 下面这句用来定义工作接口,如果是多个就中间空格
# 比如INTERFACES="eth0 eth1 eth2"
INTERFACES="eth0"

4 主要设置

root@ubuntu:~# nano /etc/dhcp3/dhcpd.conf

#
# Sample configuration file for ISC dhcpd for Debian
#
# $Id: dhcpd.conf,v 1.1.1.1 2002/05/21 00:07:44 peloy Exp $
#

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;


#下面是全局设置,这里定义的信息全dhcp服务器生效
#我一般注释掉了,下面可以分不同的子网进行设置
# option definitions common to all supported networks...
#option domain-name "apt-get.cn";
#option domain-name-servers 202.103.0.117, 202.103.24.68;
#default-lease-time 600;
#max-lease-time 7200;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.

#subnet 10.152.187.0 netmask 255.255.255.0 {
#}

# This is a very basic subnet declaration.

#subnet 10.254.239.0 netmask 255.255.255.224 {
# range 10.254.239.10 10.254.239.20;
# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
#}

# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.

#subnet 10.254.239.32 netmask 255.255.255.224 {
# range dynamic-bootp 10.254.239.40 10.254.239.60;
# option broadcast-address 10.254.239.31;
# option routers rtr-239-32-1.example.org;
#}

# A slightly different configuration for an internal subnet.
#subnet设置一个子网192.168.1.0/24
#range定义可以分配出去的地址为1.50到1.70
#option domain-name-servers定义dns为202.103.0.117等三个,这里注意每个之间要有个逗号
#option domain-name定义域名称
#option routers定义网关地址
#broadcast-address定义广播地址
#default-lease-time默认租约时间
#max-lease-time 最大租约时间
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.50 192.168.1.70;
option domain-name-servers 202.103.0.117,202.103.24.68,202.103.150.44;
option domain-name "apt-get.cn";
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
default-lease-time 864000;
max-lease-time 86400000;
filename "pxelinux.0";
}

# Hosts which require special configuration options can be listed in
# host statements. If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.

#host passacaglia {
# hardware ethernet 0:0:c0:5d:bd:95;
# filename "vmunix.passacaglia";
# server-name "toccata.fugue.com";
#}

# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
#host fantasia {
# hardware ethernet 08:00:07:26:c0:a5;
# fixed-address fantasia.fugue.com;
#}

# You can declare a class of clients and then do address allocation
# based on that. The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.

#class "foo" {
# match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
#}

#shared-network 224-29 {
# subnet 10.17.224.0 netmask 255.255.255.0 {
# option routers rtr-224.example.org;
# }
# subnet 10.0.29.0 netmask 255.255.255.0 {
# option routers rtr-29.example.org;
# }
# pool {
# allow members of "foo";
# range 10.17.224.10 10.17.224.250;
# }
# pool {
# deny members of "foo";
# range 10.0.29.10 10.0.29.230;
# }
#}



5 启动服务器

root@ubuntu:/# /etc/init.d/dhcp3-server start
* Starting DHCP server dhcpd3 [ OK ]
root@ubuntu:/#
如果原来启动了的就restart

6 查看服务是否已经正常监听

root@ubuntu:/# netstat -aunp|grep dhcp
udp 0 0 0.0.0.0:67 0.0.0.0:* 23011/dhcpd3

已经在67号udp口上开始监听了



7 使用客户端看能否获取ip


结束语

这只是一个最基本的dhcp服务器设置,满足基本的ip地址分配没什么大问题,但是如果需要netboot等服务,还需要更加详细的设置,待续

情灭缘尽
2007.12.21

第三步 安装配置nfs服务器
1 安装
root@ubuntu:/# apt-get install nfs-common nfs-kernel-server nfs-client
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
Reading state information... 完成
nfs-common 已经是最新的版本了。
nfs-kernel-server 已经是最新的版本了。
注意,我选了 nfs-common 而非 nfs-client
nfs-common 已经是最新的版本了。
共升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件未被升级。

2 配置
root@ubuntu:~# nano /etc/exports

# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync) hostname2(ro,sync)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt)
# /srv/nfs4/homes gss/krb5i(rw,sync)
#暂时只为弄清楚安装方法,安全问题以后再慢慢说
/home/cache/netboot 192.168.1.0/24(rw,no_root_squash,sync)

3 启动nfs或者重新加载
启动nfs
root@ubuntu:/# /etc/init.d/nfs-kernel-server start
* Exporting directories for NFS kernel daemon...
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.0/24:/home/cache/netboot".
Assuming default behaviour ('no_subtree_check').
NOTE: this default has changed since nfs-utils version 1.0.x
...done.
* Starting NFS kernel daemon
...done.
如果是修改了/etc/exports 配置文件,不需要重新启动nfs服务器,只需要刷新一下,命令如下
root@ubuntu:/# exportfs -r
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.0/24:/home/cache/netboot".
Assuming default behaviour ('no_subtree_check').
NOTE: this default has changed since nfs-utils version 1.0.x
情灭缘尽
2007.12.21

第四步 安装syslinux
1 安装syslinux,其实也就是为了要里面的pxelinux部分的文件
root@ubuntu:/# apt-get install syslinux
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
Reading state information... 完成
syslinux 已经是最新的版本了。
共升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件未被升级。

2 拷贝pxelinux.0文件到tftpboot目录
root@ubuntu:/# cp /usr/lib/syslinux/pxelinux.0 /var/lib/tftpboot/
root@ubuntu:/#

3 在tftpboot目录建立pxelinux.cfg目录,然后在pxelinux.cfg目录下建立default文件
也可以是以某个ip地址为文件名称
root@ubuntu:/# nano /var/lib/tftpboot/pxelinux.cfg/default

DEFAULT ubuntu
LABEL ubuntu
kernel linux
append initrd=initrd.nfs root=/dev/nfs nfsroot=192.168.1.88:/home/cache/netboot/root ip=dhcp rw
PROMPT 1
TIMEOUT 3


第五步 安装一个新的将来用来在无盘机器上运行的linux,我这里安装的是一个ubuntu 7的服务器版本
1 安装ubuntu 服务器,你也可以安装你需要的linux版本
注意的是
1> 安装好nfs的client
root@netfs:~# apt-get install nfs-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting nfs-common instead of nfs-client
nfs-common is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.

2> ip分配需要修改为手动,因为开机器的时候已经分配了ip
root@netfs:~# nano /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet manual

3> 编辑fstab文件,把除了proc外的所有都注释掉,udev会自动完成这个工作

4> 编辑udev的rules中关于网络借口记录的文件,去掉已经定义了的网络接口,否则无盘启动了有个报错
root@netfs:~# :>/etc/udev/rules.d/70-persistent-net.rules


2 安装initramfs-tools
root@netfs:~# apt-get install initramfs-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
initramfs-tools is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
root@netfs:~#

3 编辑initramfs.conf把BOOT=local改为BOOT=nfs
#
# initramfs.conf
# Configuration file for mkinitramfs(Cool. See initramfs.conf(5).
#

#
# MODULES: [ most | netboot | dep | list ]
#
# most - Add all framebuffer, acpi, filesystem, and harddrive drivers.
#
# dep - Try and guess which modules to load.
#
# netboot - Add the base modules, network modules, but skip block devices.
#
# list - Only include modules from the 'additional modules' list
#

MODULES=most

# BUSYBOX: [ y | n ]
#
# Use busybox if available.
#

BUSYBOX=y

#
# NFS Section of the config.
#

#
# BOOT: [ local | nfs ]
#
# local - Boot off of local media (harddrive, USB stick).
#
# nfs - Boot using an NFS drive as the root of the drive.
#

BOOT=nfs

#
# DEVICE: ...
#
# Specify the network interface, like eth0
#

DEVICE=eth0

#
# NFSROOT: [ auto | HOST:MOUNT ]
#

NFSROOT=auto


4 创建支持nfs的initrd.img文件
首先我们把nfs挂上来,创建的文件直接丢到nfs服务器上去
root@netfs:/# mkdir /netfs
root@netfs:/# mount -t nfs 192.168.1.88:/home/cache/netboot /netfs
建立两目录
root@netfs:/# cd /netfs/;mkdir root tftpboot
创建支持nfs启动的initrd.img文件
root@netfs:/# mkinitramfs -o /netfs/tftpboot/initrd.nfs
拷贝内核到tftpboot目录
root@netfs:/# cp /boot/vmlinuz-2.6.22-14-server /netfs/tftpboot/linux

5 打包ubuntu服务器版本的/为tgz文件并且放到nfs上保存,您可以不需要这样,我这样做的目的是创建了一个拷贝,如果出问题了,可以在nfs服务器上快速的恢复无盘客户机的系统,先apt-get update一下,然后apt-get clean
一下,打包的时候请排除掉proc等目录
root@netfs:/etc# apt-get clean
root@netfs:/etc# apt-get autoclean
Reading package lists... Done
Building dependency tree
Reading state information... Done
#用下面的命令打包
root@netfs:/# tar zcvfp /netfs/root/netfs.tgz / --exclude=/sys/* --exclude=/netfs --exclude=mnt/* \
--exclude=/lost+found --exclude=/var/tmp/* --exclude=/proc/*

OK,打包完成了以后,关掉这个机器,到nfs服务器上那个机器去

第六步
1> 在nfs服务器上拷贝内核和initrd.img到到/var/lib/tfptboot/
root@ubuntu:~# cp /home/cache/netboot/tftpboot/* /var/lib/tftpboot/

2> 把刚才压缩的netfs.tgz文件移动到我们准备长期保存的地方,然后把他解压缩一份到
/home/cache/netboot/root/
root@ubuntu:/home/cache/netboot/root# ls -lh netfs.tgz
-rw-r--r-- 1 root root 96M 2007-12-22 06:03 netfs.tgz

root@ubuntu:/home/cache/netboot/root# cp netfs.tgz /home/cache/
root@ubuntu:/home/cache/netboot/root#

root@ubuntu:/home/cache/netboot/root# tar zxvf netfs.tgz && rm -fr netfs.tgz
root@ubuntu:/home/cache/netboot/root# ls
bin dev home initrd.img media opt root srv tmp var
cdrom etc initrd lib mnt proc sbin sys usr vmlinuz
删除mtab文件
root@ubuntu:/# cd /home/cache/netboot/root/etc/
root@ubuntu:/home/cache/netboot/root/etc# rm mtab
root@ubuntu:/home/cache/netboot/root/etc#


第七步 设置一个虚拟机从网卡启动,或者找一个真实的客户机设置从网卡启动
当然你的机器一定要支持网络启动,并且网卡的驱动已经在内核里面了,如果没在,请重新编译内核,找到对应的网卡驱动,然后敲空格选择星号表示把驱动编译到内核里面

下面打包的是启动过程的录象



补1
常常无盘网络有多个客户端,这个时候我们需要修改dhcp服务器和tftp下的pxelinux.cfg下的设置
我们首先来说一下dhcp3-server的修改
首先我们打开全局设置的部分,统一的设置网关 dns 租约期限等统一的信息
#设置所在域的名称
option domain-name "apt-get.cn";
#设置dns解析服务器
option domain-name-servers 202.103.0.117, 202.103.24.68;
#下面的时间使用-1表示永久租约
default-lease-time -1;
max-lease-time -1;
然后找到我们先设置的地方
没改的时候如下
# A slightly different configuration for an internal subnet.
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.50 192.168.1.70;
option domain-name-servers 202.103.0.117,202.103.24.68,202.103.150.44;
option domain-name "apt-get.cn";
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
default-lease-time 864000;
max-lease-time 86400000;
filename "pxelinux.0";
}

修改方式如下
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.50 192.168.1.50
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;

host A01 {
hardware ethernet 00:0c:29:81:bf:41;
option host-name "A001";
fixed-address 192.168.1.50;
filename "pxelinux.0";
}

host A02 {
hardware ethernet 00:0c:29:df:38:be;
option host-name "A002";
fixed-address 192.168.1.51;
filename "pxelinux.0";
}

}

多客户机的dhcpd的修改方法就是上面这样,下面我们设置一下pxelinux.cfg里面的内容
root@ubuntu:/var/lib/tftpboot/pxelinux.cfg# ls
01-00-0c-29-81-bf-41 01-00-0c-29-df-38-be default
root@ubuntu:/var/lib/tftpboot/pxelinux.cfg#
看一下,把default文件复制一个名修改为
01-开头,后面是无盘客户机的mac地址,看清楚中间是-不是: 字母必须是小写,否则启动报错
也可以把名字修改为16进制的数字,比如192.168.1.50
修改为C0A80132
比如192转成了16进制的C0
168转成了16进制的A8
这里必须是大写,小写启动的时候报错
如果启动的时候nfs连接的位置不同,记得修改这个文件里面的内容哦
情灭缘尽
2007.12.22 武汉
全文完



附记
各软件版本
DHCP服务器
root@ubuntu:/home/cache/netboot/root/etc# dpkg --status dhcp3-server
Package: dhcp3-server
Status: install ok installed
Priority: optional
Section: net
Installed-Size: 756
Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: i386
Source: dhcp3
Version: 3.0.5-3ubuntu4

TFTP服务器
root@ubuntu:/home/cache/netboot/root/etc# dpkg --status tftpd-hpa
Package: tftpd-hpa
Status: install ok installed
Priority: extra
Section: net
Installed-Size: 148
Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: i386
Source: tftp-hpa
Version: 0.43-1.1ubuntu1
Provides: tftpd

NFS服务器
root@ubuntu:/home/cache/netboot/root/etc# dpkg --status nfs-kernel-server
Package: nfs-kernel-server
Status: install ok installed
Priority: optional
Section: net
Installed-Size: 360
Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: i386
Source: nfs-utils
Version: 1:1.1.1~git-20070709-3ubuntu1

netfs.rar
描述:        
       
下载
文件名:          netfs.rar
文件大小:          750.82 KB
下载过的:          文件被下载或查看 5 次
回复 支持 反对

使用道具 举报

发表于 2007-12-23 17:32:40 | 显示全部楼层
回复 支持 反对

使用道具 举报

发表于 2007-12-28 11:48:07 | 显示全部楼层
在pxelinux.cfg目录下建立default文件。这个文件是客户端具体执行什么内容
的配置文件。下面是我试验中使用的default文件
default linux
timeout 10
prompt 10

label linux
kernel  bzImage
append initrd=rootfs.gz

rootfs.gz下载地址如下
http://ys-c.ys168.com/?rootfs.gz ... j5bkt2btnn5bu03f22z
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表