Install on UEFI + GPT

UEFI + GPTな環境にGentooをインストールした。
えらくはまってしまったのでその時の手順を残す。

SystemRescueCDからBoot後に作業を実施したが、minimalディスクからBoot後に作業を実施しても問題無いと思われる。

参考サイト
http://wiki.gentoo.org/wiki/UEFI_Gentoo_Quick_Install_Guide

partitioning disk

root@sysresccd /root % parted -a optimal /dev/sda
(parted) mklabel gpt
(parted) mkpart primary 0% 512
(parted) mkpart primary 512 2560
(parted) mkpart primary 2560 -1
(parted) set 1 boot on
(parted) name 1 efi-boot
(parted) name 2 swap
(parted) name 3 rootfs
(parted) p
Model: ATA TOSHIBA THNSNJ12 (scsi)
Disk /dev/sda: 122104MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start    End        Size       File system     Name      Flags
 1      1.00MiB  512MiB     511MiB     fat32           efi-boot  boot
 2      512MiB   2560MiB    2048MiB    linux-swap(v1)  swap
 3      2560MiB  122103MiB  119543MiB  ext4            rootfs

(parted) q
Information: You may need to update /etc/fstab.

create filesystems

root@sysresccd /root % mkfs.vfat -F 32 /dev/sda1
root@sysresccd /root % mkswap /dev/sda2
root@sysresccd /root % swapon /dev/sda2
root@sysresccd /root % mkfs.ext4 /dev/sda3

mount filesystems

root@sysresccd /root % mount /dev/sda3 /mnt/gentoo
root@sysresccd /root % mkdir -p /mnt/gentoo/boot/efi
root@sysresccd /root % mount /dev/sda1 /mnt/gentoo/boot/efi

Steage3

root@sysresccd % wget http://ftp.jaist.ac.jp/pub/Linux/Gentoo/releases/amd64/autobuilds/current-stage3-amd64/stage3-amd64-20140501.tar.bz2
root@sysresccd /mnt/gentoo % tar xvjpf stage3-amd64-20140501.tar.bz2

make.conf

root@sysresccd /mnt/gentoo % vi ./etc/portage/make.conf
root@sysresccd /mnt/gentoo % mirrorselect -i -o >> ./etc/portage/make.conf
root@sysresccd /mnt/gentoo % mirrorselect -i -r -o >> ./etc/portage/make.conf
root@sysresccd /mnt/gentoo % cat ./etc/portage/make.conf
(中略)
CFLAGS="-march=bdver2 -mcx16 -msahf -mmovbe -maes -mpclmul -mpopcnt -mabm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mbmi -mno-bmi2 -mno-tbm -mavx -mno-avx2 -msse4.2 -msse4.1 -mlzcnt -mno-rdrnd -mf16c -mno-fsgsbase --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=2048 -mtune=bdver2 -O2 -pipe"
CXXFLAGS="${CFLAGS}"
MAKEOPTS="-j5"
(中略)
GENTOO_MIRRORS="http://ftp.jaist.ac.jp/pub/Linux/Gentoo/"

SYNC="rsync://rsync3.jp.gentoo.org/gentoo-portage"

chroot

root@sysresccd /mnt/gentoo % cp -L /etc/resolv.conf /mnt/gentoo/etc
root@sysresccd /mnt/gentoo % mount -t proc proc /mnt/gentoo/proc
root@sysresccd /mnt/gentoo % mount --rbind /sys /mnt/gentoo/sys
root@sysresccd /mnt/gentoo % mount --rbind /dev /mnt/gentoo/dev
root@sysresccd /mnt/gentoo % chroot /mnt/gentoo /bin/bash
sysresccd / # source /etc/profile

portage tree

sysresccd / # emerge-webrsync
sysresccd / # eselect news list
sysresccd / # eselect news read

profile

sysresccd / # eselect profile list
Available profile symlink targets:
  [1]   default/linux/amd64/13.0 *
  [2]   default/linux/amd64/13.0/selinux
  [3]   default/linux/amd64/13.0/desktop
  [4]   default/linux/amd64/13.0/desktop/gnome
  [5]   default/linux/amd64/13.0/desktop/gnome/systemd
  [6]   default/linux/amd64/13.0/desktop/kde
  [7]   default/linux/amd64/13.0/desktop/kde/systemd
  [8]   default/linux/amd64/13.0/developer
  [9]   default/linux/amd64/13.0/no-multilib
  [10]  default/linux/amd64/13.0/x32
  [11]  hardened/linux/amd64
  [12]  hardened/linux/amd64/selinux
  [13]  hardened/linux/amd64/no-multilib
  [14]  hardened/linux/amd64/no-multilib/selinux
  [15]  hardened/linux/amd64/x32
  [16]  hardened/linux/uclibc/amd64
sysresccd / # eselect profile set 1

use flag

sysresccd / # nano -w /etc/portage/make.conf
sysresccd / # cat /etc/portage/make.conf
(中略)
USE="-bindist avx avx2 mmx sse sse2 ssse3 sse4_1 -ipv6"
(中略)

timezone

sysresccd portage # ls -1 /usr/share/zoneinfo/ | grep Japan
Japan
sysresccd portage # echo "Japan" > /etc/timezone
sysresccd portage # emerge --config sys-libs/timezone-data


Configuring pkg...

 * Updating /etc/localtime with /usr/share/zoneinfo/Japan

locale

sysresccd portage # nano -w /etc/locale.gen
sysresccd portage # cat /etc/locale.gen
(中略)

#en_US ISO-8859-1
#en_US.UTF-8 UTF-8
#ja_JP.EUC-JP EUC-JP
ja_JP.UTF-8 UTF-8
#ja_JP EUC-JP
#en_HK ISO-8859-1
#en_PH ISO-8859-1
#de_DE ISO-8859-1
#de_DE@euro ISO-8859-15
#es_MX ISO-8859-1
#fa_IR UTF-8
#fr_FR ISO-8859-1
#fr_FR@euro ISO-8859-15
#it_IT ISO-8859-1
sysresccd portage # locale-gen
 * Generating 1 locales (this might take a while) with 1 jobs
 *  (1/1) Generating ja_JP.UTF-8 ... [ ok ]
 * Generation complete
sysresccd portage # eselect locale list
/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_COLLATE to default locale: No such file or directory
Available targets for the LANG variable:
  [1]   C
  [2]   POSIX
  [3]   ja_JP.utf8
  [ ]   (free form)
sysresccd portage # eselect locale set 3
/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_COLLATE to default locale: No such file or directory
Setting LANG to ja_JP.utf8 ...
Run ". /etc/profile" to update the variable in your shell.
sysresccd portage # env-update && source /etc/profile
>>> Regenerating /etc/ld.so.cache...

kernel

sysresccd portage # emerge gentoo-sources
sysresccd portage # cd /usr/src/linux
sysresccd linux # make menuconfig
(中略)
Processor type and features  --->
    [*] EFI runtime service support 
    [*]   EFI stub support
(中略)
    [*] Built-in kernel command line
    (root=/dev/sda2)
(中略)
sysresccd linux # make && make modules_install
sysresccd linux # cp arch/x86_64/boot/bzImage /boot/kernel-3.12.13-gentoo

grub2

sysresccd linux # nano -w /etc/portage/make.conf
sysresccd linux # cat /etc/portage/make.conf
(中略)
GRUB_PLATFORMS="efi-64"
sysresccd linux # emerge sys-boot/grub

/boot/efiUEFI対応のgrub2をインストールしたいのだけれど、
すでにUEFIでBootされた環境からしかインストールできない。
そこでUEFIブートできるように細工したUSB Memoryを作る。
partedを使用したいので、chrootしていない環境で以下を実施した。

root@sysresccd /root % parted /dev/sdb
(parted) mklabel gpt
(parted) unit mib
(parted) mkpart esi fat32 0% -1
(parted) set 1 boot on
(parted) p
Model: JetFlash Transcend 4GB (scsi)
Disk /dev/sdb: 3861MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start    End      Size     File system  Name  Flags
 1      1.00MiB  3860MiB  3859MiB               esi   boot

(parted) q
Information: You may need to update /etc/fstab.

root@sysresccd /root % mkfs.vfat -F 32 /dev/sdb1
root@sysresccd /mnt % mkdir /mnt/tmp
root@sysresccd /mnt % mount /dev/sdb1 /mnt/tmp
root@sysresccd /mnt % mkdir -p /mnt/tmp/efi/boot
root@sysresccd /mnt % cp /mnt/gentoo/usr/src/linux/arch/x86_64/boot/bzImage /mnt/tmp/efi/boot/bootx64.efi
root@sysresccd /mnt % umount /mnt/tmp

hostname, ethernet, syslog-ng, eronie, sshd, inittab, fstab

sysresccd ~ # nano -w /etc/conf.d/hostname
sysresccd ~ # nano -w /etc/conf.d/net
sysresccd init.d # emerge syslog-ng
sysresccd init.d # rc-update add syslog-ng default
sysresccd init.d # emerge cronie
sysresccd init.d # rc-update add cronie default
sysresccd init.d # rc-update add sshd default
sysresccd init.d # nano -w /etc/inittab
sysresccd init.d # blkid /dev/sda1
/dev/sda1: UUID="DB2E-E353" TYPE="vfat" PARTLABEL="efi-boot" PARTUUID="a03cde49-1184-42ce-8c62-e68fbe0d3d34"
sysresccd init.d # blkid /dev/sda2
/dev/sda2: UUID="cd4f49b9-d0cc-44ad-9ae9-2204c23b50e7" TYPE="swap" PARTLABEL="swap" PARTUUID="f264b37f-d885-4ed5-a518-3a03432e27c2"
sysresccd init.d # blkid /dev/sda3
/dev/sda3: UUID="8cb00e4e-15a8-4d4b-a38c-c77fb5d90ba3" TYPE="ext4" PARTLABEL="rootfs" PARTUUID="0752a29e-ea2e-468a-85dc-8a25013bbdeb"
sysresccd init.d # nano -w /etc/fstab
# <fs>                                          <mountpoint>    <type>          <opts>                          <dump>  <pass>
UUID="DB2E-E353"                                /boot/efi       vfat            defaults                        0       2
UUID="cd4f49b9-d0cc-44ad-9ae9-2204c23b50e7"     none            swap            defaults                        0       0
UUID="8cb00e4e-15a8-4d4b-a38c-c77fb5d90ba3"     /               ext4            defaults,noatime,discard        0       1

リブートして、grub2をインストール

sysresccd linux # exit
root@sysresccd /mnt/gentoo % cd /
root@sysresccd / % umount -l /mnt/gentoo/dev{/shm,/pts,}
root@sysresccd / % umount -l /mnt/gentoo{/boot,/proc,}
root@sysresccd / % reboot
gentoo ~ # grub2-install --target=x86_64-efi --efi-direcotry=/boot/efi --bootloader-id=Gentoo
gentoo ~ # grub2-mkconfig -o /boot/grub/grub.cfg

リブートすると無事にDiskからGentooがあがってくるはず・・・。

ZFSのバックアップ

備忘録

# zfs list
NAME         USED  AVAIL  REFER  MOUNTPOINT
bkup        6.41G  2.65T  6.41G  /bkup
tank        1.22T  6.76T   152K  /tank
tank/sftp   86.7G  6.76T  86.7G  /tank/sftp
tank/store  1.13T  7.79T   106G  -
# zfs snapshot tank/store@`date +%Y%m%d`
# zfs list -t snapshot
NAME                  USED  AVAIL  REFER  MOUNTPOINT
tank/store@20140119      0      -   106G  -
# zfs send -p tank/store@20140119 | pigz --fast > /bkup/store.20140119.gz

NICのBonding

備忘録

# kldload if_lagg
# ifconfig em0 up
# ifconfig em1 up
# ifconfig lagg0 create
# ifconfig lagg0 laggproto failover lagport em0 laggport em1 192.168.2.50 netmask 255.255.255.0
# ifconfig lagg0
lagg0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=4019b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,VLAN_HWTSO>
        ether 00:15:17:08:02:11
        inet 192.168.2.50 netmask 0xffffff00 broadcast 192.168.2.255
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: Ethernet autoselect
        status: no carrier
        laggproto failover lagghash l2,l3,l4
        laggport: em1 flags=0<>
        laggport: em0 flags=1<MASTER>