UEFI + ZFSインストール

別のメディアで起動して

  • この起動メディアはsshリモートログインできルートパスワードが設定されているUSB
zpool destroy zroot
sysctl vfs.zfs.min_auto_ashift=12
  • ここは新品なら不要
    gpart destroy -F ada0
    zpool labelclear -f /dev/ada0
    gpart create -s gpt ada0
    gpart destroy -F ada0
gpart create -s gpt ada0
gpart add -a 4k -l efiboot0 -t efi -s 800k ada0
gpart bootcode -p /boot/boot1.efifat -i 1 ada0
gpart add -a 1m -l swap0 -t freebsd-swap -s 2G ada0
gpart add -a 1m -l zfs0 -t freebsd-zfs -s 2T "ada0"
  • ここも新品なら不要
    zpool labelclear -f /dev/ada0p2
    zpool labelclear -f /dev/ada0p3
    
    gpart destroy -F ada1
    graid delete ada1
    zpool labelclear -f /dev/ada1
    gpart create -s gpt ada1
    gpart destroy -F ada1
gpart create -s gpt ada1
gpart add -a 4k -l efiboot1 -t efi -s 800k ada1
gpart bootcode -p "/boot/boot1.efifat" -i 1 ada1
gpart add -a 1m -l swap1 -t freebsd-swap -s 2G ada1
gpart add -a 1m -l zfs1 -t freebsd-zfs -s 2T ada1
  • ここも新品なら不要
    zpool labelclear -f /dev/ada1p2
    zpool labelclear -f /dev/ada1p3
zpool create -R /mnt -O compress=lz4 -O atime=off -m none -f zroot mirror  ada0p3 ada1p3
zfs create -o mountpoint=/ zroot/ROOT
zfs create -o mountpoint=/usr/ports  zroot/ports
zfs create -o mountpoint=/usr/src  zroot/src

zpool set bootfs=zroot/ROOT zroot

######################################################
## zfs set "canmount=noauto" "zroot/ROOT/default"

mount /dev/da0 /media
cd /media/usr/freebsd-dist
tar -xvzf base.txz -C /mnt
tar -xvzf kernel.txz -C /mnt
tar -zxvf src.txz -C /mnt

sshd 再起動後に即リモートログインできるように

cp /mnt/etc/ssh/sshd_config /mnt/etc/ssh/sshd_config.org
sed s/'#PermitRootLogin no'/'PermitRootLogin yes'/ < /mnt/etc/ssh/sshd_config.org > /mnt/etc/ssh/sshd_config
# 確認 
diff /mnt/etc/ssh/sshd_config.org  /mnt/etc/ssh/sshd_config

cp /etc/master.passwd /mnt/etc/master.passwd
pwd_mkdb -u root -d /mnt/etc /mnt/etc/master.passwd

loader.conf

echo 'hint.atkbd.0.flags="0x1"' >> /mnt/boot/loader.conf
echo 'autoboot_delay="2"' >> /mnt/boot/loader.conf
echo 'kern.geom.label.gptid.enable="0"' >> /mnt/boot/loader.conf
echo 'zfs_load="YES"' >> /mnt/boot/loader.conf

rc.conf

cat /etc/rc.conf >> /mnt/etc/rc.conf

zfs_enable="YES"
hostname="test.zenno.net"
keymap="jp.106.kbd"
ifconfig_em0="inet 192.168.0.120 netmask 255.255.255.0"
defaultrouter="192.168.0.140"
sshd_enable="YES"

fstab

sh
FSTAB_FMT='%s\t\t%s\t%s\t%s\t\t%s\t%s\n'
printf "$FSTAB_FMT" "# Device" "Mountpoint" "FStype" "Options" "Dump" "Pass#"  >> "/mnt/etc/fstab"
FSTAB_FMT='%s\t\t%s\t\t%s\t%s\t\t%s\t%s\n'
printf "$FSTAB_FMT" "/dev/ada0p2" "none" "swap" "sw" "0" "0" >>  "/mnt/etc/fstab"
printf "$FSTAB_FMT" "/dev/ada1p2" "none" "swap" "sw" "0" "0" >> "/mnt/etc/fstab"
exit

Timezone

tzsetup -C /mnt Asia/Tokyo

再起動前に

cd ~
zfs unmount zroot/src
zfs unmount zroot/ports
zfs unmount zroot/ROOT
zfs set mountpoint=/mnt zroot/ROOT

# 確認
zfs get mountpoint
zpool get bootfs

zpool export zroot
shutdown -r now

11.0R インストールログより

printf "$FSTAB_FMT" "# Device" "Mountpoint" "FStype" "Options" "Dump" "Pass#" >> "/tmp/bsdinstall_etc/fstab"

zpool destroy "zroot"
sysctl vfs.zfs.min_auto_ashift=12

gpart destroy -F "ada0"
graid delete "ada0"
zpool labelclear -f "/dev/ada0"
gpart create -s gpt "ada0"
gpart destroy -F "ada0"

gpart create -s gpt "ada0"
gpart add -a 4k -l efiboot0 -t efi -s 800k "ada0"
gpart bootcode -p "/boot/boot1.efifat" -i 1 "ada0"
gpart add -a 1m -l swap0 -t freebsd-swap -s 2147483648b "ada0"
zpool labelclear -f "/dev/ada0p2"
gpart add -a 1m -l zfs0 -t freebsd-zfs "ada0"
zpool labelclear -f "/dev/ada0p3"

printf "$FSTAB_FMT" "/dev/ada0p2" "none" "swap" "sw" "0" "0" >> "/tmp/bsdinstall_etc/fstab"

zpool create -o altroot=/mnt -O compress=lz4 -O atime=off -m none -f "zroot"   ada0p3
zfs create -o mountpoint=none "zroot/ROOT"
zfs create -o mountpoint=/ "zroot/ROOT/default"
zfs create -o mountpoint=/tmp -o exec=on -o setuid=off "zroot/tmp"
zfs create -o mountpoint=/usr -o canmount=off "zroot/usr"
zfs create  "zroot/usr/home"
zfs create -o setuid=off "zroot/usr/ports"
zfs create  "zroot/usr/src"
zfs create -o mountpoint=/var -o canmount=off "zroot/var"
zfs create -o exec=off -o setuid=off "zroot/var/audit"
zfs create -o exec=off -o setuid=off "zroot/v11ar/crash"
zfs create -o exec=off -o setuid=off "zroot/var/log"
zfs create -o atime=on "zroot/var/mail"
zfs create -o setuid=off "zroot/var/tmp"

zfs set "mountpoint=/zroot" "zroot"
mkdir -p "/mnt/tmp"
chmod 1777 "/mnt/tmp"
mkdir -p "/mnt/var/tmp"
chmod 1777 "/mnt/var/tmp"
zpool set bootfs="zroot/ROOT/default" "zroot"
mkdir -p "/mnt/boot/zfs"
zpool set cachefile="/mnt/boot/zfs/zpool.cache" "zroot"
zfs set "canmount=noauto" "zroot/ROOT/default"
echo "zfs_enable=\"YES\"" >> "/tmp/bsdinstall_etc/rc.conf.zfs"
echo "kern.geom.label.disk_ident.enable=\"0\"" >> "/tmp/bsdinstall_boot/loader.conf.zfs"
echo "kern.geom.label.gptid.enable=\"0\"" >> "/tmp/bsdinstall_boot/loader.conf.zfs"

FreeBSD

FreeBSD/UEFIについて


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2017-01-24 (火) 11:53:54 (610d)