NetBSD環境の構築 Edit

  • 方針
    Linux上からNetBSD環境の構築を行う。
    (本方法を使えば、NetBSDの母艦が無くても環境構築可能です。)

  • パーティション構成
    /dev/hda6上にNetBSDシステムを構築することにします。
    landisk:~# fdisk -l /dev/hda
    
    Disk /dev/hda: 160.0 GB, 160041885696 bytes
    255 heads, 63 sectors/track, 19457 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/hda1               1        1020     8193118+  83  Linux
    /dev/hda2            1021        1053      265072+  82  Linux swap / Solaris
    /dev/hda3            1054        6153    40965750   83  Linux
    /dev/hda4            6154       19457   106864380    5  Extended
    /dev/hda5            6154       15880    78132096   83  Linux
    /dev/hda6           15881       17097     9775521   83  Linux
    /dev/hda7           17098       19457    18956668+  a9  NetBSD
    
  • ext2fsを選択
    理由は、Linuxからext2fsをマウントしてNetBSDの構築を行うため。
    (NetBSD母艦を用意できる方は、こんな回りくどいことをする必要ないです。)

  • /dev/hda6の初期化
    mkfs、e2fckを行います。
    landisk:~# mke2fs /dev/hda6
    landisk:~# e2fsck -c /dev/hda6
    
  • マウント
    landisk:~# mkdir /mnt/hda6
    landisk:~# mount /dev/hda6 /mnt/hda6
    
  • NetBSDバイナリパッケージ
    tokudaさんという方がLANDISK用のバイナリセットを公開してくれていますので、
    ありがたく、それを使用させて頂くことにします。
  • バイナリセットの展開
    上記場所から、base.tgz と etc.tgzをダウンロードして、次のようにして展開します。
    landisk:~# cd /mnt/hda6
    landisk:/mnt/hda6# tar vxfzp base.tgz
    landisk:/mnt/hda6# tar vxfzp etc.tgz
    
  • 設定
    • /mnt/hda6/etc/fstab
      NeBSDのデバイス /dev/wd0e〜wd0j は Linuxの /dev/hda1〜hda6 に対応するようです。
      /dev/hda6 (/dev/wd0j) をルート、/dev/hda2 (/dev/wd0f)をスワップとしてマウントします。
      #/dev/wd0j /    ext2fs rw 1 1 <- fsckでこけるみたい。
      /dev/wd0j /    ext2fs rw 0 0
      /dev/wd0f none swap   sw 0 0
      
    • /mnt/hda6/etc/rc.conf
      下記を追加。(host名を"netbsd"とした例です。)
      # Add local overrides below
      #
      rc_configured=YES
      hostname=netbsd
      defaultroute=192.168.1.1
      domainname=""
      
    • /mnt/hda6/etc/hosts
      下記を追加。
      192.168.1.81	netbsd
      
    • /mnt/hda6/etc/ifconfig.rtk0
      inet 192.168.1.81 netmask 255.255.255.0 
      
    • /mnt/hda6/etc/resolve.conf
      nameserver xxx.xxx.xxx.xxx
      lookup file bind
      

SH-Linux Kernel Swicherで起動 Edit

  • kernelsw.plを使って起動
    どうやら成功したみたい。
    rootデバイスを聞かれたら、wd0j (/dev/hda6)を指定するのがミソ。
    ちなみに、wd0e〜wd0p は、/dev/hda1〜/dev/hda12 に対応しているらしい。
    … 途中省略 …
    boot device: <unknown>
    root device: wd0j
    dump device (default wd0b):
    file system (default generic):
    root on wd0j dumps on wd0b
    root file system type: ext2fs
    warning: no /dev/console
    init path (default /sbin/init):
    init: trying /sbin/init
    init: Creating mfs /dev (405 blocks, 1024 inodes)
    Fri Aug 26 13:46:21 UTC 2005
    swapctl: adding /dev/wd0f as swap device at priority 0
    Checking for botched superblock upgrades: done.
    Starting file system checks:
    Setting tty flags.
    Setting sysctl variables:
    Starting network.
    Hostname: netbsd
    IPv6 mode: host
    Configuring network interfaces: rtk0.
    add net default: gateway 192.168.1.1
    Adding interface aliases:
    Building databases...
    Starting syslogd.
    Checking for core dump...
    savecore: /netbsd: kvm_openfiles: /netbsd: No such file or directory
    Aug 26 13:46:35 netbsd savecore:
     /netbsd: kvm_openfiles: /netbsd: No such file or directory
    Mounting all filesystems...
    Clearing /tmp.
    Checking quotas: done.
    Setting securelevel: kern.securelevel: 0 -> 1
    Starting virecover.
    Starting local daemons:.
    Updating motd.
    sendmail: /etc/mail/aliases.db not present, generating
    Aug 26 13:46:45 netbsd sendmail[1147]: 
     My unqualified host name (netbsd) unknown; sleeping for retry
    Aug 26 13:47:45 netbsd sendmail[1147]: 
     unable to qualify my own domain name (netbsd) -- using short name
    WARNING: local host name (netbsd) is not qualified; see cf/README: WHO AM I?
    /etc/mail/aliases: 22 aliases, longest 10 bytes, 246 bytes total
    Starting sendmail.
    Aug 26 13:47:46 netbsd sm-mta[1175]:
     My unqualified host name (netbsd) unknown; sleeping for retry
    Aug 26 13:48:46 netbsd sm-mta[1175]:
     unable to qualify my own domain name (netbsd) -- using short name
    Starting inetd.
    Starting cron.
    Fri Aug 26 13:48:48 UTC 2005
    
    NetBSD/landisk (netbsd) (console)
    
    login: root
    Aug 26 13:48:54 netbsd login: ROOT LOGIN (root) ON console
    Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
        The NetBSD Foundation, Inc.  All rights reserved.
    Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
    
    NetBSD 3.99.7 (GENERIC) #2: Sun Aug 21 23:50:47 JST 2005
    
    Welcome to NetBSD!
    
    Terminal type? [unknown] vt100
    Terminal type is vt100.
    We recommend creating a non-root account and using su(1) for root access.
    netbsd#
    netbsd#
    netbsd#
    

telnetdの設定 Edit

  • ユーザlandiskの設定
    netbsd # useradd -m landisk
    netbsd # usermod -G wheel landisk
    netbsd # passwd landisk
    
  • inetdの設定
    • /etc/inetd.conf
      行頭の#(コメント)を削除し、"-a none"に変更
      telnet stream  tcp nowait root /usr/libexec/telnetd  telnetd -a none
      
    • inetdの再起動
      netbsd# /etc/rc.d/inetd restart
      Stopping inetd.
      Starting inetd.
      
  • telnet接続
    先ほど作成したユーザlandiskでログインできます。
    また、rootになるには、suコマンドを使用します。
    NetBSD/landisk (netbsd) (ttyp1)
    
    login: landisk
    Password:
    Last login: Wed Aug 31 13:58:11 2005 from 192.168.1.2 on ttyp1
    Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
        The NetBSD Foundation, Inc.  All rights reserved.
    Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
    
    NetBSD 3.99.7 (GENERIC) #2: Sun Aug 21 23:50:47 JST 2005
    
    Welcome to NetBSD!
    
    An ounce of prevention is worth a pound of purge.
    netbsd: {1} whoami
    landisk
    netbsd: {2} su
    netbsd: {1} whoami
    root
    netbsd: {2}
    
  • 補足…rootで直接ログインするのは?
    /etc/ttys へ次の行を追加します。
    ttyp0 none network off secure
    ttyp1 none network off secure
    





トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2009-10-25 (日) 10:32:40 (5291d)