Powered by SmartDoc

2.3 ではやってみよう

  1. ブートイメージでブートしパーティション操作でシェルプロンプトへ
    1. Welcome: [<Install>]
    2. Keymap Selection: [>>> Continue with deault keymap]
    3. Set Hostname: "t.pis"
    4. Distribution Select: doc, lib32, src, tests
    5. Partitioning: [Shell]
  2. ZFSカーネルモジュールのロード
    # kldload zfs
    
  3. 既存のpoolを調べる
    # zpool import
       pool: zroot
         id: 13983011036213050597
      state: ONLINE
    action: The pool can be imported using its name or numeric \
        identifier.
     config:
        
           zroot       ONLINE
             da0p3     ONLINE
    # zpool list
    no pools available
    # 
    
  4. GPTパーティションを切る
    1. デスクを殺す
      # gpart destroy -F da0
      da0 destroyed
      # zpool import
         pool: zroot
           id: 13983011036213050597
        state: ONLINE
      action: The pool can be imported using its name or numeric \
          identifier.
       config:
          
             zroot       ONLINE
               da0p3     ONLINE
      # 
      
    2. GPTなディスクを生成
      # gpart create -s gpt da0
      da0 created
      # 
      
    3. 各パーティションを切る
      # gpart add -s 1024 -a 4k -t freebsd-boot da0
      da0p1 added
      # gpart add -s 4g -a 4k -t freebsd-swap da0
      da0p2 added
      # gpart add -s 1500g -a 4k -t freebsd-zfs da0
      da0p3 added
      # gpart add -a 4k -t freebsd-ufs da0
      da0p4 added
      # gpart show da0
      =>        40  3906249648  da0  GPT  (1.8T)
                40        1024    1  freebsd-boot  (512K)
              1064     8388608    2  freebsd-swap  (4.0G)
           8389672  3145728000    3  freebsd-zfs  (1.5T)
        3154117672   752132008    4  freebsd-ufs  (359G)
        3906249680           8         - free -  (4.0K)
      # zpool import
         pool: zroot
           id: 13983011036213050597
        state: ONLINE
      action: The pool can be imported using its name or numeric \
          identifier.
       config:
          
             zroot       ONLINE
               da0p3     ONLINE
      # 
      
  5. ブートコードをコピー
    # gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0
    bootcode written to da0
    # 
    
  6. `advanced format' drive対応
    # sysctl vfs.zfs.min_auto_ashift=12
    vfs.zfs.min_auto_ashift: 9 -> 12
    #
    
  7. ZFS poolの作成
    # zpool create -o altroot=/mnt -O canmount=off -m none zroot \
        /dev/da0p3
    invalid vdev specification
    use `-f' to override the following errors:
    /dev/da0p3 is part of potentially active pool `zroot'
    # zpool create -f -o altroot=/mnt -O canmount=off -m none zroot \
        /dev/da0p3
    # zpool list
    NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
    zroot 1.46T 540K 1.46T - 0% 0% 1.00x ONLINE /mnt
    # 
    
  8. ZFSファイルシステムの作成
    # zfs set checksum=fletcher4 zroot
    # zfs set atime=off zroot
    # zfs create -o mountpoint=none zroot/ROOT
    # zfs create -o mountpoint=/ zroot/ROOT/default
    # zfs create -o mountpoint=/tmp -o compression=lz4 -o setuid=off \
        zroot/tmp
    # chmod 1777 /mnt/tmp
    # zfs create -o mountpoint=/usr zroot/usr
    # zfs create zroot/usr/local
    # zfs create -o setuid=off zroot/usr/home
    # zfs create -o compression=lz4 -o setuid=off zroot/usr/ports
    # zfs create zroot/usr/portbuild
    # zfs create -o compression=off -o exec=off -o setuid=off \
        zroot/usr/distfiles
    # zfs create -o compression=off -o exec=off -o setuid=off \
        zroot/usr/packages
        
    # zfs create -o compression=lz4 -o exec=off -o setuid=off \
        zroot/usr/src
    # zfs create zroot/usr/obj
        
    # zfs create -o mountpoint=/var zroot/var
    # zfs create -o compression=lz4 -o exec=off -o setuid=off \
        zroot/var/crash
    # zfs create -o exec=off -o setuid=off zroot/var/db
    # zfs create -o compression=lz4 -o exec=on -o setuid=off \
        zroot/var/db/pkg
    # zfs create -o exec=off -o setuid=off zroot/var/empty
    # zfs create -o compression=lz4 -o exec=off -o setuid=off \
        zroot/var/log
    # zfs create -o compression=gzip -o exec=off -o setuid=off \
        zroot/var/mail
    # zfs create -o exec=off -o setuid=off zroot/var/run
    # zfs create -o compression=lz4 -o exec=on -o setuid=off \
        zroot/var/tmp
    # chmod 1777 /mnt/var/tmp
    # 
    
  9. UFSファイルシステムの作成
    # newfs /dev/vtbd0p4
    # 
    
  10. ブートファイルシステムの設定
    # zpool set bootfs=zroot/ROOT/default zroot
    # 
    
  11. スワップ&起動時のファイルシステムの設定
    # printf "# Device\t\tMountpoint\tFStype\tOptions\tDump\tPass#\n" \
        > /tmp/bsdinstall_etc/fstab
    # printf "/dev/da0p2\t\tnone\t\tswap\tsw\t0\t0\n" >> \
        /tmp/bsdinstall_etc/fstab
    # printf "/dev/da0p4\t\t\/bds\t\tufs\trw\t1\t1\n" >> \
        /tmp/bsdinstall_etc/fstab
    # cat /tmp/bsdinstall_etc/fstab
    # Device Mountpoint FStype Options Dump Pass#
    /dev/da0p2              none            swap    sw      0       0
    /dev/da0p4              /bds            ufs     rw      1       1
    # 
    
  12. `FreeBSD Installer'に戻る
    # exit
    
  13. アカウントの設定
    FreeBSD Installer
    ========================
    
    Please select a password for the system management account(root):
    Changing local password for root
    New Password:********
    Retype Password:********
    
  14. ネットワーク環境の設定
    1. Network Configuration: [em0]
    2. Network Configuration "Would you like to configure IPv4 for this interface": [<Yes>]
    3. Network Configuration "Would you like to use DHCP to configure this interface": [<No>]
    4. Network Configuration "Static Network Interface Configuration"

      • IP Address: "192.168.1.132"
      • Subnet Mask: "255.255.255.0"
      • IP Address: "192.168.1.254"

      : [<OK>]

    5. Network Configuration "Would you like to configure IPv6 for this interface": [<No>]
    6. Network Configuration "Resolver Configuration"

      • Search: "pis"
      • IPv4 DNS #1: "192.168.1.2"

      : [<OK>]

  15. タイムゾーンの設定
    1. Select local or UTC (Greenwich Mean Time) clock: [<No>]
    2. Time Zone Selector: 5 Asia
    3. Countries in Asia: 18 Japan
      1. Confirmation: [<Yes>]
  16. 起動時の設定

    System Configuration: local_unbound, sshd, moused, ntpd, powerd, dumpdev

    [<Ok>]

  17. ユーザアカウントの追加

    Add User Accounts: [<Yes>]

    FreeBSD Installer
    ========================
    Add Users
        
    Username: admin
    Full name: Administrator of PIS
    Uid(leave empty for default): 999
    Login group [admin]:
    Login group is admin. Invite admin into other groups? []: wheel
    Login class [default]:
    Shell (sh csh tcsh nologin) [sh]: tcsh
    Home directory [/home/admin]: /usr/home/admin
    Home directory permission (Leave empty for default):
    Use password-based authentication? [yes]:
    Use an empty password? (yes/no) [no]:
    Use a random password? (yes/no) [no]:
    Enter password:********
    Enter password again:********
    Lock out the account after creation? [no]:
    Username   : admin
    Password   : *****
    Full Name  : Administrator of PIS
    Uid            : 999
    Class      :
    Groups     : admin wheel
    Home       : /usr/home/admin
    Home Mode  :
    Shell      : /bin/tcsh
    Locked     : no
    Ok? (yes/no):yes
    adduser: INFO: Successfully added (admin) to the user database.
    Add another user? (yes/no): no
    
  18. 最後にシェルプロンプトへ
    1. Final Configuration: [Exit]
    2. Manual Configuration: [<Yes>]
  19. ZFSブートの設定
    # echo 'zfs_enable="YES"' >> /etc/rc.conf
    
  20. /var/emptyをリードオンリーに
    # zfs set readonly=on zroot/var/empty
    
  21. `FreeBSD Installer'に戻る
    # exit
    
  22. リブート
    1. Complete: [<Reboot>]
  23. ハードディスクからログインし仮マウント用のUFSディレクトリ(zroot/bds)を削除(1)
    # zfs destroy zroot/bds
    
  1. これは良くわからないところだ.基本的に/がZFSの場合,UFSなファイルシステムを同居させるにはどうしてもZFS上でそのマウントポイントを切る必要があるのだが,一旦UFSにマウントすれば,それはUFSなマウントポイントとなるのでZFSで切ったのと重複する.事実dfで見るとそのようになっている.で,ZFSの方は必要ないので削除することになる.