Benutzer Diskussion:Matthias Jakobi: Unterschied zwischen den Versionen

Aus Wiki StuRa HTW Dresden
Zur Navigation springen Zur Suche springen
Zeile 30: Zeile 30:
[[Benutzer:JohannesSchneemann]]
[[Benutzer:JohannesSchneemann]]


== Laptop ==
Greeting, I had a bit time, free slice on the disk with MBR and the desire to play with the new installation of FreeBSD 9.0-RC1 .
Below is just a simple example ; there will be one ZFS filesystem on /, no swap, no keys for GELI, passphrase only. Nevertheless, I decided to share the method which can be used in different setups and configurations.


=== Load Geli ===
My setup consists of:
ada0 - hard drive
ada0s1 - slice will be used for boot 1G
ada0s2 - slice will be used for swap 4G
ada0s3 - slice will be used for ZFS  50G


Fixit> kldload geom_eli
1. Boot with your FreeBSD install disk and choose “Live CD” when prompted, login as root, no password is required.
2. This step is optional but it's a good idea.
Code:


=== Festplatte ===
dd if=/dev/urandom of=/dev/ada0s1
dd if=/dev/urandom of=/dev/ada0s3


Fixit> gpart create -s GPT ada0
3. bsdlabeling:
Fixit> gpart add -s 64K -t freebsd-boot ada0
Code:
Fixit> gpart add -s 1G -t freebsd-ufs ada0
Fixit> gpart add -s 55G -t freebsd-zfs ada0
Fixit> gpart set -a active -1 ada0 # funzt nicht
Fixit> gpart bootcode -b /dist/boot/pmbr -p /dist/boot/gptzfsboot -i 1 ada0
Fixit> newfs -O2 /dev/ada0p2


*aktuelle Festplatten Einteilung
bsdlabel -w /dev/ada0s3
-ad0 GPT
    |-1 freebsd-boot 64K
    |-2 freebsd-ufs 1G /boot
    |-3 freebsd-zfs 55G / (crypto)


=== Encrypt ===
4. Loading the required modules:
Code:


Fixit> geli init -b -s 4096 -l 256 /dev/ada0p3
kldload geom_eli zfs


=== Attach ===
5. Labeling partition:
Code:


Fixit> geli attach /dev/ada0p3
glabel label zrpool /dev/ada0s1a


=== ZFS ===
6. Initiation and attachment GELI:
Code:


Fixit> kldload zfs
geli init -b /dev/label/zrpool
Fixit> zpool create tank /dev/ad0p3.eli
geli attach /dev/label/zrpool
# Fixit> zpool create home
# Fixit> zpool set bootfs=tank tank
# Fixit> mkdir /tank/bootdir
# Fixit> mount /dev/ad0p2 /tank/bootdir
Fixit# zfs set checksum=fletcher4                                      zroot
Fixit# zfs create -o compression=on    -o exec=on      -o setuid=off  zroot/tmp
Fixit# chmod 1777 /zroot/tmp
Fixit# zfs create                                                      zroot/usr
Fixit# zfs create                                                      zroot/usr/home
Fixit# cd /zroot ; ln -s /usr/home home
Fixit# zfs create -o compression=lzjb                  -o setuid=off  zroot/usr/ports
Fixit# zfs create -o compression=off  -o exec=off    -o setuid=off  zroot/usr/ports/distfiles
Fixit# zfs create -o compression=off  -o exec=off    -o setuid=off  zroot/usr/ports/packages
Fixit# zfs create -o compression=lzjb  -o exec=off    -o setuid=off  zroot/usr/src
Fixit# zfs create                                                      zroot/var
Fixit# zfs create -o compression=lzjb  -o exec=off    -o setuid=off  zroot/var/crash
Fixit# zfs create                      -o exec=off    -o setuid=off  zroot/var/db
Fixit# zfs create -o compression=lzjb  -o exec=on      -o setuid=off  zroot/var/db/pkg
Fixit# zfs create                      -o exec=off    -o setuid=off  zroot/var/empty
Fixit# zfs create -o compression=lzjb  -o exec=off    -o setuid=off  zroot/var/log
Fixit# zfs create -o compression=gzip  -o exec=off    -o setuid=off  zroot/var/mail
Fixit# zfs create                      -o exec=off    -o setuid=off  zroot/var/run
Fixit# zfs create -o compression=lzjb  -o exec=on      -o setuid=off  zroot/var/tmp
Fixit# chmod 1777 /zroot/var/tmp


=== Install FreeBSD ===
7. Creation ZFS pool and FS:
Code:


Fixit> zfs set mountpoint=/tank/usr/home home
zpool create -O mountpoint=/mnt -O canmount=off zrpool /dev/label/zrpool.eli
Fixit# cd /dist/8.2-*
zfs create -o mountpoint=legacy zrpool/FreeBSD
Fixit# export DESTDIR=/zroot
Fixit# for dir in base catpages dict doc games info lib32 manpages ports; \
          do (cd $dir ; ./install.sh) ; done


*lib32 oder  proflibs
8. Installation FreeBSD:
Code:


Fixit# cd src ; ./install.sh all
mount -t zfs zrpool/FreeBSD /mnt
Fixit# cd ../kernels ; ./install.sh generic
tar -xf /usr/freebsd-dist/base.txz -C /mnt
Fixit# cd /zroot/boot ; cp -Rlp GENERIC/* /zroot/boot/kernel/
tar -xf /usr/freebsd-dist/kernel.txz -C /mnt


Fixit# zfs set readonly=on zroot/var/empty
You can select and install something else, please take a look at /usr/freebsd-dist/
9. ada0s1, preparation:
Code:


=== post install ===
bsdlabel -B -v /dev/ada0s1
newfs /dev/ada0s1a


Fixit# chroot /zroot
10. Copying /boot to ada0s1:
Code:


*rc.conf
mkdir /tmp/boot
zfs_enable="YES"
mount /dev/ada0s1 /tmp/boot
hostname="beastie.mydomain.local"
cp -Rp /mnt/boot /tmp/boot/
ifconfig_re0="DHCP"


*loader.conf
11. Creation fstab and loader.conf:
zfs_load="YES"
a) create /tmp/usbboot/boot/loader.conf and add the following lines:
vfs.root.mountfrom="zfs:zroot"
Code:
geom_eli_load="YES"
geli_ad0p4_keyfile0_load="YES"
geli_ad0p4_keyfile0_type="ad0p4:geli_keyfile0"
geli_ad0p4_keyfile0_name="/boot/key/ad0.key"


*fstab
geom_eli_load="YES"
# Device                      Mountpoint              FStype Options        Dump    Pass#
zfs_load="YES"
/dev/ad0s2                    /bootdir                ufs    rw              0      0
# aesni_load="YES" # option see man aesni
vfs.root.mountfrom="zfs:zrpool/FreeBSD"


b) create /mnt/etc/fstab:
Code:


Fixit> passwd
# cat > /mnt/etc/fstab
Fixit> tzsetup
zrpool/FreeBSD / zfs rw 0 0
Fixit> cd /etc/mail
^D
Fixit> make aliases
Fixit> umount /dev
Fixit> exit
Fixit# cp /boot/zfs/zpool.cache /zroot/boot/zfs/zpool.cache
Fixit> mkdir /tank/boot/key
Fixtit> cp /boot/key/* /tank/boot/key


=== Finish install ===
12. Generation and recording zpool.cache to USB stick:
Code:


Fixit# cd /zroot
zpool export zrpool
Fixit# mv boot bootdir/
zpool import -o cachefile=/tmp/usbboot/boot/zfs/zpool.cache zrpool
Fixit# ln -s bootdir/boot /zroot/boot
Fixit# chflags -h sunlink /zroot/boot


Fixit# export LD_LIBRARY_PATH=/mnt2/lib
13. Change pool mountpoint to /
Code:


Fixit# umount /zroot/bootdir
zfs set mountpoint=/ zrpool
Fixit# zfs unmount -a


Fixit# zfs set mountpoint=legacy zroot
14. Finish.
Fixit# zfs set mountpoint=/tmp zroot/tmp
Code:
Fixit# zfs set mountpoint=/usr zroot/usr
 
Fixit# zfs set mountpoint=/var zroot/var
shutdown -r now
Fixit# zfs set mountpoint=/usr/home home

Version vom 2. Februar 2012, 21:33 Uhr

Beobachtungsseiten

weitere Admins

Benutzer:JohannesSchneemann

Greeting, I had a bit time, free slice on the disk with MBR and the desire to play with the new installation of FreeBSD 9.0-RC1 . Below is just a simple example ; there will be one ZFS filesystem on /, no swap, no keys for GELI, passphrase only. Nevertheless, I decided to share the method which can be used in different setups and configurations.

My setup consists of: ada0 - hard drive ada0s1 - slice will be used for boot 1G ada0s2 - slice will be used for swap 4G ada0s3 - slice will be used for ZFS 50G

1. Boot with your FreeBSD install disk and choose “Live CD” when prompted, login as root, no password is required. 2. This step is optional but it's a good idea. Code:

dd if=/dev/urandom of=/dev/ada0s1 dd if=/dev/urandom of=/dev/ada0s3

3. bsdlabeling: Code:

bsdlabel -w /dev/ada0s3

4. Loading the required modules: Code:

kldload geom_eli zfs

5. Labeling partition: Code:

glabel label zrpool /dev/ada0s1a

6. Initiation and attachment GELI: Code:

geli init -b /dev/label/zrpool geli attach /dev/label/zrpool

7. Creation ZFS pool and FS: Code:

zpool create -O mountpoint=/mnt -O canmount=off zrpool /dev/label/zrpool.eli zfs create -o mountpoint=legacy zrpool/FreeBSD

8. Installation FreeBSD: Code:

mount -t zfs zrpool/FreeBSD /mnt tar -xf /usr/freebsd-dist/base.txz -C /mnt tar -xf /usr/freebsd-dist/kernel.txz -C /mnt

You can select and install something else, please take a look at /usr/freebsd-dist/ 9. ada0s1, preparation: Code:

bsdlabel -B -v /dev/ada0s1 newfs /dev/ada0s1a

10. Copying /boot to ada0s1: Code:

mkdir /tmp/boot mount /dev/ada0s1 /tmp/boot cp -Rp /mnt/boot /tmp/boot/

11. Creation fstab and loader.conf: a) create /tmp/usbboot/boot/loader.conf and add the following lines: Code:

geom_eli_load="YES" zfs_load="YES"

  1. aesni_load="YES" # option see man aesni

vfs.root.mountfrom="zfs:zrpool/FreeBSD"

b) create /mnt/etc/fstab: Code:

  1. cat > /mnt/etc/fstab

zrpool/FreeBSD / zfs rw 0 0 ^D

12. Generation and recording zpool.cache to USB stick: Code:

zpool export zrpool zpool import -o cachefile=/tmp/usbboot/boot/zfs/zpool.cache zrpool

13. Change pool mountpoint to / Code:

zfs set mountpoint=/ zrpool

14. Finish. Code:

shutdown -r now