2014年8月18日月曜日

grub4dos 簡単インスト linuxマウント

 boot openbsd by puppy's grub4dos


HDDにまずopenbsdをいれます。
それからpuppyをいれました。

puppyで fdiskをすると

# fdisk /dev/sda
Command (m for help): p

Disk /dev/sda: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders, total 78140160 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008579c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    10487807     5242880   83  Linux
/dev/sda2        10487808    55830527    22671360   83  Linux
/dev/sda3        55830528    78140159    11154816   a6  OpenBSD

となってます。

/dev/sda1 に puppyがいて
/dev/sda2 は ext2 ファイルシステムで ここはpuppyからもopenbsdからも読み書きをできるようにしていきます。


puppy はgrub4dosで openbsdを起動するのですが、
そのファイルは
sda1にある menu.lst で以下で

title OpenBSD
      chainloader (hd0,2)+1
      rootnoverify (hd0,2)
        boot


難所はopenbsdで /dev/sda2 (ext2)を読み書きできるようにすることです。
まず普通に
すると

# disklabel wd0
 #                size           offset  fstype [fsize bsize  cpg]
  a:         19426368         56886176  4.2BSD   2048 16384    1 # /
  b:          1055637         55830528    swap                   # none
  c:         78140160                0  unused                   

だけで、 ext2 がでてきません。

つまり openbsdは後からいれた ext2を認識してません。
それには disklabel -e
で編集する作業が必要になります。

まず fdisk wd0      をして
            
Disk: wd0       geometry: 4864/255/63 [78140160 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
*0: 83      0  32  33 -    652 213   9 [        2048:    10485760    ]   Linux files*
 1: 83    652 213  10 -   3475  73  54 [    10487808:    45342720  ] Linux files*
 2: A6   3475  73  55 -   4863 254  63 [    55830528:    22309632  ] OpenBSD   
 3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused  
なので 

10487808:    45342720 
とを覚えておきます。

それから
disklabel -e wd0 すると viによる編集モードに入ります。

そこで
# /dev/rwd0c:
type: ESDI
disk: ESDI/IDE disk
label: TOSHIBA MK4032GA
duid: 4ad4d11d7894f655
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 4864
total sectors: 78140160
boundstart: 55830528
boundend: 78140160
drivedata: 0

16 partitions:
#                size           offset  fstype [fsize bsize  cpg]
  a:         19426368         56886176  4.2BSD   2048 16384    1 # /
  b:          1055637         55830528    swap                   # none
  c:         78140160                0  unused
  o:         45342720         10487808  ext2fs



とします。
すると

 mount_ext2fs /dev/wd0o /EXT2
でマウントできます。

 あるいは
 cat /etc/fstab                                                              
4ad4d11d7894f655.b none swap sw
4ad4d11d7894f655.a /           ffs       rw 1 1
/dev/wd0o                 /EXT2/  ext2fs rw 1 1

でも可




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