Disk leeren:
wipefs /dev/sda
sgdisk -Z /dev/sda
dd if=/dev/zero of=/dev/sda bs=4k count=250k
wipefs /dev/sdb
sgdisk -Z /dev/sdb
Partitionieren: Für BIOS Rechner:
sgdisk -a 4096 --new=1:+0:+2M --typecode=1:EF02 --change-name=1:"BIOS boot partition" /dev/sda
sgdisk -a 4096 --new=2:+129M:+1G --typecode=2:8300 --change-name=2:"gentoo boot" /dev/sda
sgdisk -a 4096 --new=3:+129M:-129M --typecode=3:8300 --change-name=3:"tank1" --attributes=3:set:2 /dev/sda
sgdisk -a 4096 --new=1:+129M:-129M --typecode=1:8300 --change-name=1:"tank2" /dev/sdb
Jetzt ist ein Neustart erforderlich, damit Linux das neue Partitions-Schema erkennt.
ls -l /dev/disk/by-id/
Zeigt die Partitions IDs an
Erstellen der btrfs-Partition:
mkfs.btrfs -m raid1 -d raid1 -L "tank" /dev/sda3 /dev/sdb1
mkdir -p /mnt/tank
mount /dev/sda3 /mnt/tank
cd /mnt/tank
btrfs subvolume create @
btrfs subvolume create @/var
# create Home-Dirs
btrfs subvolume create HOME
btrfs subvolume create HOME/root
# Dirs for Gentoo-stuff
btrfs subvolume create GENTOO
btrfs subvolume create GENTOO/portage
btrfs subvolume create GENTOO/distfiles
btrfs subvolume create GENTOO/build-tmp
# Mount Dirs
mount /dev/sda3 /mnt/gentoo -o subvol=@,noatime,autodefrag
cd /mnt/gentoo/
mkdir ./root
mkdir -p ./usr/portage
mkdir -p ./home
mount /dev/sda3 ./home -o subvol=HOME,relatime,autodefrag,compress=lzo
mount /dev/sda3 ./root -o subvol=HOME/root,relatime,autodefrag,compress=lzo
mount /dev/sda3 ./usr/portage -o subvol=GENTOO/portage,noatime,autodefrag,compress=lzo
mkdir -p ./usr/portage/distfiles
mount /dev/sda3 ./usr/portage/distfiles -o subvol=GENTOO/distfiles,noatime
mkdir -p ./var/tmp/portage
mount /dev/sda3 ./var/tmp/portage -o subvol=GENTOO/build-tmp,noatime,compress=lzo,async
TODO: Swap-Partition
Stage3 herunterladen.
cd
wget 'ftp://gentoo.osuosl.org/pub/gentoo/releases/amd64/autobuilds/current-stage3-amd64/stage3-amd64-[0-9]*.tar.bz2'
tar -xvjpf stage3-amd64-*.tar.bz2 -C /mnt/gentoo
cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
Nun können wir unseren neuen Rechner beziehen.
mount -t proc none /mnt/gentoo/proc
mount --rbind /dev /mnt/gentoo/dev
mount --rbind /sys /mnt/gentoo/sys
chroot /mnt/gentoo /bin/bash
env-update; source /etc/profile; export PS1="(chroot) $PS1"; cd
Portage-Dateien herunterladen & einen Kernel compilieren.
env GENTOO_MIRRORS="http://gentoo.osuosl.org" emerge-webrsync
mkdir -p /etc/portage/package.accept_keywords
echo "sys-kernel/dracut ~amd64" >> /etc/portage/package.accept_keywords/system
emerge sys-kernel/gentoo-sources sys-kernel/dracut
emerge app-editors/vim app-misc/tmux
# btrfs progs Installieren
echo "sys-fs/btrfs-progs ~amd64" >> /etc/portage/package.accept_keywords/system
emerge sys-fs/btrfs-progs sys-apps/gptfdisk
touch /etc/mtab
mkfs.ext2 /dev/sda2
mount /dev/sda2 /boot
Grub2 installieren:
# Flush the page cache to ensure GRUB2 sees the latest disk content
echo 1 > /proc/sys/vm/drop_caches
mkdir -p /etc/portage/package.accept_keywords
echo "sys-boot/grub:2 -truetype -fonts -themes" >> /etc/portage/package.use/system
echo "sys-boot/grub:2 ~amd64" >> /etc/portage/package.accept_keywords/system
emerge sys-boot/grub:2
grub2-install /dev/sda
touch /boot/grub/grub.cfg
Kernel kompilieren:
sed -i -e "s_/dev/BOOT_$(blkid -o export /dev/sda2 | sed -n '/^UUID=/ p')_g" \
-e "s/\(.*\)\/\(ROOT\|SWAP\)\(.*\)/\#\1\/\2\3/g" /etc/fstab
eval $(blkid -o export /dev/sdb1 | sed -n '/^UUID=/ p' )
cat >> /etc/fstab << EOF
UUID=$UUID /mnt/tank btrfs noauto 0 0
UUID=$UUID / btrfs noatime,subvol=@,autodefrag 0 0
UUID=$UUID /home btrfs relatime,subvol=HOME,autodefrag,compress=lzo 0 0
UUID=$UUID /root btrfs relatime,subvol=HOME/root,autodefrag,compress=lzo 0 0
UUID=$UUID /usr/portage btrfs noatime,subvol=GENTOO/portage,autodefrag,compress=lzo 0 0
UUID=$UUID /usr/portage/distfiles btrfs noatime,subvol=GENTOO/distfiles 0 0
UUID=$UUID /var/tmp/portage btrfs noatime,subvol=GENTOO/build-tmp,compress=lzo 0 0
EOF
cat > /etc/dracut.conf.d/local.conf << EOF
hostonly="yes"
add_dracutmodules+="btrfs"
compress="xz"
EOF
cd /usr/src/linux
make localmodconfig
# verify BTRFS is included
sed -i -e 's!^.*\(CONFIG_BTRFS_FS\)[ =].*!\1=y!' .config
make -j 4
make install
make modules_install
dracut '' $(readlink -f /usr/src/linux | sed -e 's!.*linux-!!')
grub2-mkconfig -o /boot/grub/grub.cfg
System vorbereiten:
echo PORTAGE_NICENESS=19 >> /etc/portage/make.conf
emerge app-admin/rsyslog app-admin/logrotate sys-process/cronie
rc-update add cronie default
rc-update add sshd default
# setting root password
passwd
Referenzen: