2014年8月4日月曜日

openbsd,debianで PXE、Openbsdの NFS, isoのマウント


まず debianでのPXEを書きます

internet
|
|
wifi (Uroad-aero)
192.168.100.254
|
|
dhcp
debian
192.168.11.1
|
|
dhcp
PC



インストールするのものは
tftpd-hpa
isc-dhcp-server
です・

ところで  cat /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"
なので、


/srv/tftp
にファイルをおきます。

そして、
service isc-dhcp-server restart
/etc/init.d/tftpd-hpa restart
で起動します。

cat /etc/default/isc-dhcp-server
INTERFACES="eth0"



 cat /etc/dhcp/dhcpd.conf
#ddns-update-style none;
 option domain-name-servers 192.168.100.254;

default-lease-time 600;
max-lease-time 7200;

subnet 192.168.11.0 netmask 255.255.255.0 {
  range 192.168.11.10 192.168.11.19;
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.11.255;
  option routers 192.168.11.1;
  next-server 192.168.11.1;
  filename "pxelinux.0";

}





cd    /srv/tftp

lftp -c "open  ftp.debian.org:/debian/dists/squeeze/main/installer-i386/current/images/netboot ; mirror"


 lftp -c "open  http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/trusty-updates/main/installer-i386/current/images/netboot/    ; mirror "



これにて
root@debian7:/srv/tftp# ls -ltr
合計 33272
-rw-r--r-- 1 root root 13051253  4月 24 16:46 netboot.tar.gz
-rw-r--r-- 1 root root 20971520  4月 24 16:46 mini.iso
drwxr-xr-x 2 root root     4096  4月 25 01:46 pxelinux.cfg
drwxr-xr-x 3 root root     4096  4月 25 01:46 debian-installer
drwxr-xr-x 4 root root     4096  4月 25 01:50 gtk
drwxr-xr-x 2 root root     4096  4月 27 09:22 xen
-rw-r--r-- 1 root root    26474  7月  8 18:44 pxelinux.0


# du ./
8    ./pxelinux.cfg
8    ./gtk/pxelinux.cfg
8    ./gtk/debian-installer/i386/pxelinux.cfg
32    ./gtk/debian-installer/i386/boot-screens/kde
32    ./gtk/debian-installer/i386/boot-screens/lxde
32    ./gtk/debian-installer/i386/boot-screens/xfce
416    ./gtk/debian-installer/i386/boot-screens
30836    ./gtk/debian-installer/i386
30840    ./gtk/debian-installer
99116    ./gtk
8    ./debian-installer/i386/pxelinux.cfg
32    ./debian-installer/i386/boot-screens/kde
32    ./debian-installer/i386/boot-screens/lxde
32    ./debian-installer/i386/boot-screens/xfce
416    ./debian-installer/i386/boot-screens
23372    ./debian-installer/i386
23376    ./debian-installer
30660    ./xen
186420    ./
な感じです。







それではopenbsd はというと
cd /srv/tftp

 wget http://ftp.openbsd.org/pub/OpenBSD/5.5/i386/pxeboot
 wget http://ftp.openbsd.org/pub/OpenBSD/5.5/i386/bsd.rd


cd /srv/tftp mkdir etc/

cat etc/boot.conf                                                                               
boot tftp:/bsd.rd



ln -s pxeboot pxelinux.0





つまり
/srv/tftp# ls -l
合計 6436
-rw-r--r-- 1 root root 6501415  3月  6 02:19 bsd.rd
drwxr-xr-x 2 root root    4096  8月  9 08:25 etc
-rw-r--r-- 1 root root   80544  3月  6 01:47 pxeboot
lrwxrwxrwx 1 root root       7  8月  9 08:25 pxelinux.0 -> pxeboot

だけです。





openbsd をdebin の PXEサーバーとするは でが、




openbsdでは
すでに
dhcpdも
tftpdもインストールされてます。

状況は

internet
|
|
|
rooter
192.168.1.1
|
|
sis0
openbsd(PXE server)
ne3  192.168.11.1  ---PCMCIA card
|
|
PC *debian

 
cat 
ne3
 


cat 
/etc/dhcpd.conf                                                                             

 

 option  domain-name-servers 192.168.1.1;
subnet 192.168.11.0 netmask 255.255.255.0 {
        option routers 192.168.11.1;
        range 192.168.11.32 192.168.11.33;
        filename        "pxelinux.0";
        next-server 192.168.11.1;
}



cat /etc/rc.conf.local                                                                          
dhcpd_flags=""          #NO  # for normal use: ""


これでdhcpdが動きます。




tftpdを動かす準備です。
mkdir   /tftpboot
cd      /tftpboot
そして
lftp -c "open  ftp.debian.org:/debian/dists/squeeze/main/installer-i386/current/images/netboot ; mirror"




if firemware is needed , look   
     http://qiita.com/harukasan/items/98db5f4639433e5e40d4 .

# paxコマンドがなければインストールしておく
sudo aptitude install pax

mkdir -p /tmp/initrd_firmware
cd /tmp/initrd_firmware

mkdir firmware
wget http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/squeeze/current/firmware.tar.gz
tar -C firmware -zxf firmware.tar.gz
pax -x sv4cpio -s'%firmware%/firmware%' -w firmware | gzip -c >firmware.cpio.gz

# initrd.gzに結合する
cat initrd.gz firmware.cpio.gz > initrd_nonfree.gz



pf.cpnfをすごく一時的に甘くしますが、ここまでへりくだらなくてもよいと思いますが、

  cat /etc/pf.conf                                                                               







ext=sis0

icmp_types = "{echoreq, unreach}"
set block-policy return
set loginterface $ext
set skip on lo0

# to some packet scrubbing
match in all scrub (no-df max-mss 1440)


# Handles NAT for the wireless clients
match out on $ext inet from !($ext:network) to any nat-to ($ext:0)

# Block everything by default
#block log all

# Let all traffic out
pass out quick

# Let all traffic in
# allowing 'gre' is useful to allow PPTP VPN traffic
pass in quick inet proto { tcp udp gre } from any to any
pass in quick inet proto icmp all icmp-type $icmp_types keep state





 




もちろん
more /etc/sysctl.conf  
net.inet.ip.forwarding=1        # 1=Permit forwarding (routing) of IPv4 packets
#net.inet.ip.mforwarding=1      # 1=Permit forwarding (routing) of IPv4 multicast packets



最後に
tftpd  /tftpboot/
をして tftpdを動かせばもうこれでOKです、
 libretto L2では N+電源 で ネットワークインストーラーが たちあがってきます.









OpenBSDのNFSです。

NFSは大変神経質です。
5.5をsnapshotsにあげるとうまくいかなくなります。

まず状況です。

internet
|
sis0
openbsd NFSサーバー
ne3
|
debian

そして openbsdの設定ファイルは
 

 # cat /etc/dhcpd.interfaces                                                  
ne3




# cat /etc/dhcpd.conf      
option  domain-name-servers 192.168.1.1;
subnet 192.168.11.0 netmask 255.255.255.0 {
       option routers 192.168.11.1;
        range 192.168.11.3 192.168.11.7;
}




# cat /etc/pf.conf                                                            

# macros
int_if="ne3"
ext_if="sis0"tcp_services="{ 22, 113 }"
icmp_types="echoreq"

# options
set block-policy return
set loginterface egress
set skip on lo


# match rules
match out on $ext_if inet from !($ext_if:network) to any nat-to ($ext_if:0)


 # filter rules
block in log
pass out quick
antispoof quick for { lo $int_if }
pass in on egress inet proto tcp from any to (ext_if) port $tcp_servicespass in inet proto icmp all icmp-type $icmp_types
pass in on $int_if




http://unix.stackexchange.com/questions/7503/nfs-permissions-and-slow-copy
を参考にして、

openbsdで 
/etc/rc.conf.local を                                                                              portmap_flags=""
mountd_flags=""
nfsd_flags="-tun 4"





そして最大の問題は
http://www.ozzu.com/unix-linux-forum/openbsd-nfs-cannot-export-t56956.html
にならって

 # cat /etc/exports                                                           
 /RW  -alldirs -maproot=tuyosi -network=192.168.11 -mask=255.255.255.0

 /EXT2 -maproot=tuyosi:wheel -network=192.168 -mask=255.255.0.0

/EXT2  -alldirs -maproot=tuyosi -network=192.168 mask=255.255.0.0




昔は
cat /etc/exports
/RW     -mapall=tuyosi:tuyosi  -network=192.168.11 -mask=255.255.255.0
読み書きできる


# /etc/rc.d/mountd reload  <-忘れないために
 


openbsdで
mkdir /EXT2
chown tuyosi  /EXT2
chmod -r 777 /EXT2


そうして
debianから
mount  -t  nfs  192.168.11.1:/EXT2    /mnt
でいけます。



だめ  mount -t nfs -o udp 192.168.1.202:/EXT2 /EXT2
mount.nfs: an incorrect mount option was specified




イメージのマウントは
# vnconfig /dev/vnd1c lupu-528JP.iso
# mount /dev/vnd1c k/

# ls k/
AUTORUN.INF               READMEJA.HTM              initrd.gz                 seamonkey-2.11-ja-1.sfs
PUPPY.ICO                 boot.cat                  lupu_528.sfs              splash.xpm
PUPPYJP.ICO               goffice-lupu-528JP.sfs    menu-advanced.lst         vmlinuz
README.HTM                grldr                     menu.lst




puppy's smb.conf
[global]
message command = /usr/local/bin/LinPopUp "%f" "%m" %s; rm %s
workgroup = puppy-wg
server string = puppy-samba
; hosts allow = 192.168.1. 192.168.2.0./24 192.168.3.0/255.255.255.0 127.0.0.1
log file = /var/log.%m
; log level = 1
max log size = 50
security = user
map to guest = Never
dns proxy = no
[-root-SAMBA-]

path = /root/SAMBA
available = yes
browsable = yes
public = yes
writable = yes
guest ok = no

0 件のコメント:

コメントを投稿