9.2 Installations-Script zfs root Problem cachefile

Frank

Anfänger
Hallo,

ich wollte heute morgen mein altes Installations-Script benutzen, um FreeBSD 9.2 zu installieren.
Unter 9.1 hatte ich keine Probleme damit.

Leider funktioniert es aber mit 9.2 nicht mehr und ich tue mich heute schwer, den Fehler zu finden.
Die Ursache des Fehlers hat irgendwie wohl was mit dem cachefile zu tun. Das habe ich aber gelöst,
es hakt es an der Stelle wo ich versuche die permissions zu ändern. (siehe bitte Skript weiter unten)

Das Skript wirft folgende Fehler:
chmod: /mnt/tmp: No such file or directory
ln: home : Read-only file system
chmod: /mnt/var/tmp: No such file or directory

Ich kriege den Fehler nicht weg.

Code:
#!/bin/sh
# These script is for FreeBSD 9.2.


# Ram: only 4 GB yet (should be 8 GB in the future)
# GPART Partionen:
# freebsd-boot  128 KB
# freebsd-swap  20 GB
# freebsd-zfs  200 GB (System and  jails) (lives in an own encrypted pool))
# freebsd-zfs  the rest encypted with geli in an own pool

# Run these script to install zfs-root FreeBSD system.
# Boot from a install-medium and start the script.
# boot live cd
# user root passwd just empty
# kbdmap
# ifconfig em0 192.168.0.1
# mkdir /tmp/mynfs
# mount -v 192.168.0.35:/home/fvdb/nfsshare /tmp/mynfs
# cd /tmp/mynfs
# ./install.sh
DISK0=ada0
###############################################################
##    ATTENTION:  disk will be complete deleted by the script  ##
###############################################################

# sometimes a reboot is necessary to reboot the disk.
# dd the first and the last bytes could be a solution or a improvement for the script
# but so it's ok for me too

zpool destroy zroot
gpart destroy -F $DISK0

gpart create -s gpt $DISK0
gpart add -a 4k -s 512k -t freebsd-boot $DISK0
gpart add -a 4k -s 20G -t freebsd-swap -l swap0 $DISK0
gpart add -a 4k -s 200GB -t freebsd-zfs -l disk0 $DISK0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $DISK0

# create pool
# always align at 4K
gnop create -S 4096 /dev/gpt/disk0
# this line was used for FreeBSD 9.1
#zpool create -f -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot  /dev/gpt/disk0.nop

############################################################
# das scheint zu funktionieren
# this line is for FreeBSD 9.2
#zpool create -f -m none -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot /dev/gpt/disk0.nop
zpool create -f -m none -o cachefile=/var/tmp/zpool.cache zroot /dev/gpt/disk0.nop

zpool export  zroot
gnop destroy /dev/gpt/disk0.nop
zpool import -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot

#setup pool
zpool set bootfs=zroot zroot
zfs set checksum=fletcher4 zroot
zfs set atime=off zroot

zfs create zroot/usr
zfs create zroot/usr/home
zfs create zroot/var

zfs create -o compression=on -o exec=on -o setuid=off zroot/tmp
#/usr/src und /usr/ports kann man auch gern mit "gzip" komprimieren.
# Das bringt etwas mehr Platzeinsparung, bei vernachlässigbaren
# Geschwindigkeitseinbußen. Allerdings sollte man sich dann
# mit "WRKDIRPREFIX=/usr/obj" in der /etc/make.conf das Arbeitsverzeichnis
# der Ports umbiegen.
#Zum Beispiel nach /usr/obj
# see MARK_A
zfs create -o compression=gzip-9 -o setuid=off zroot/usr/ports

zfs create -o compression=off -o exec=off -o setuid=off zroot/usr/ports/distfiles
zfs create -o compression=off -o exec=off -o setuid=off zroot/usr/ports/packages
zfs create -o compression=gzip-9 -o exec=off -o setuid=off zroot/usr/src

zfs create -o compression=lzjb -o exec=off -o setuid=off zroot/var/crash
zfs create -o exec=off -o setuid=off zroot/var/db
zfs create -o compression=lzjb -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=lzjb -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=lzjb -o exec=on -o setuid=off zroot/var/tmp

#create swap if swap is on the zfs
#zfs create -V 4G -o org.freebsd:swap=on -o checksum=off -o sync=disabled -o primarycache=none -o secondarycache=none zroot/swap

##gmirror-swap##
#gmirror label -b prefer swap gpt/swap0 gpt/swap1
##gmirror-swap##

####################################################
# hier gehts in die Butze #####################################
####################################################
# zfs list zeigt mir, dass nichst gemountet ist....aber es muesste doch unter /mnt ?????

#fix permissions
chmod 1777 /mnt/tmp
cd /mnt ; ln -s usr/home home
chmod 1777 /mnt/var/tmp




#install FreeBSD
cd /usr/freebsd-distdem
export DESTDIR=/mnt
for file in base.txz kernel.txz doc.txz src.txz; #ports.txz lib32.txz
do (cat $file | tar --unlink -xpJf - -C ${DESTDIR:-/}); done

#final configuration
cp /var/tmp/zpool.cache /mnt/boot/zfs/zpool.cache
echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf
echo 'keymap="german.iso"' >> /mnt/etc/rc.conf
echo 'zfs_load="YES"' >> /mnt/boot/loader.conf
echo 'vfs.root.mountfrom="zfs:zroot"' >> /mnt/boot/loader.conf
echo 'LOADER_ZFS_SUPPORT=YES' > /mnt/etc/src.conf
##########
# MARK_A #
##########
echo 'WRKDIRPREFIX=/usr/obj' >> /mnt/etc/make.conf

touch /mnt/etc/fstab

##gmirror-swap##
#echo '/dev/mirror/swap none swap sw 0 0' >> /mnt/etc/fstab
#echo 'geom_mirror_load="YES"' >> /mnt/boot/loader.conf
##gmirror-swap##

echo '/dev/gpt/swap0 none swap sw 0 0' >> /mnt/etc/fstab
zfs set readonly=on zroot/var/empty
zfs umount -a

##reboot into the new system
#kbdmap
#passwd root
#tzsetup
#cd /etc/mail ; make aliases
#sysinstall network
#/etc/rc.d/netif start
#route add default 192.168.0.2
#/etc/rc.d/routing stop start restart

# ich lasse diesmal die standardshell csh
# alias stehen in /root/.cshrc z.B. alias ls  ls -G
# das ist eine andere Syntax im Vergleich zur .bashrc
# /etc/profile und /root/.profile wird von der csh nicht gelesen

#???echo 'WITH_PKGNG=yes' >> /etc/make.conf
#???in login.conf eintragen unter default:
#:charset=UTF-8:\
##:lang=de_DE.UTF-8:\

# Remember to rebuild the database after each change to the
# file /etc/login.conf
#cap_mkdb /etc/login.conf
 
So gehts....
und ich nutze jetzt gleich mal FreeBSD 10.0 Beta 3
Code:
#!/bin/sh

# Ram: only 4 GB yet (should be 8 GB in the future)
# GPART Partionen:
# freebsd-boot  128 KB
# freebsd-swap  20 GB
# freebsd-zfs  200 GB (System and  jails) (lives in an own encrypted pool))
# freebsd-zfs  the rest encypted with geli in an own pool

# Run these script to install zfs-root FreeBSD system.
# Boot from a install-medium and start the script.
# boot live cd
# user root passwd just empty
# kbdmap
# ifconfig em0 192.168.0.1
# mkdir /tmp/mynfs
# mount -v 192.168.0.35:/home/fvdb/nfsshare /tmp/mynfs
# cd /tmp/mynfs
# ./install.sh
DISK0=ada0
###############################################################
##    ATTENTION:  disk will be complete deleted by the script  ##
###############################################################

# sometimes a reboot is necessary to reboot the disk.
# dd the first and the last bytes could be a solution or a improvement for the script
# but so it's ok for me too

zpool destroy zroot
gpart destroy -F $DISK0

gpart create -s gpt $DISK0
gpart add -a 4k -s 512k -t freebsd-boot $DISK0
gpart add -a 4k -s 20G -t freebsd-swap -l swap0 $DISK0
gpart add -a 4k -s 200GB -t freebsd-zfs -l disk0 $DISK0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $DISK0

# create pool
# always align at 4K
gnop create -S 4096 /dev/gpt/disk0
# this line was used for FreeBSD 9.1
#zpool create -f -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot  /dev/gpt/disk0.nop

############################################################
# das scheint zu funktionieren
# this line is for FreeBSD 9.2
zpool create -f -m none -o cachefile=/var/tmp/zpool.cache zroot /dev/gpt/disk0.nop
zpool export  zroot
gnop destroy /dev/gpt/disk0.nop
zpool import -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot

#setup pool
zpool set bootfs=zroot zroot
zfs set checksum=fletcher4 zroot
zfs set atime=off zroot

zfs set mountpoint=/ zroot    # <------------------- das hat gefehlt......

zfs create zroot/usr
zfs create zroot/usr/home
zfs create zroot/var

zfs create -o compression=on -o exec=on -o setuid=off zroot/tmp
#/usr/src und /usr/ports kann man auch gern mit "gzip" komprimieren.
# Das bringt etwas mehr Platzeinsparung, bei vernachlässigbaren
# Geschwindigkeitseinbußen. Allerdings sollte man sich dann
# mit "WRKDIRPREFIX=/usr/obj" in der /etc/make.conf das Arbeitsverzeichnis
# der Ports umbiegen.
####################
# (unter FreeBSD 10 besser lz4)
####################
#Zum Beispiel nach /usr/obj
# see MARK_A
zfs create -o compression=gzip-9 -o setuid=off zroot/usr/ports

zfs create -o compression=off -o exec=off -o setuid=off zroot/usr/ports/distfiles
zfs create -o compression=off -o exec=off -o setuid=off zroot/usr/ports/packages
zfs create -o compression=gzip-9 -o exec=off -o setuid=off zroot/usr/src

zfs create -o compression=lzjb -o exec=off -o setuid=off zroot/var/crash
zfs create -o exec=off -o setuid=off zroot/var/db
zfs create -o compression=lzjb -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=lzjb -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=lzjb -o exec=on -o setuid=off zroot/var/tmp

#create swap if swap is on the zfs
#zfs create -V 4G -o org.freebsd:swap=on -o checksum=off -o sync=disabled -o primarycache=none -o secondarycache=none zroot/swap

##gmirror-swap##
#gmirror label -b prefer swap gpt/swap0 gpt/swap1
##gmirror-swap##

####################################################
# hier gehts in die Butze #####################################
####################################################
# zfs list zeigt mir, dass nichst gemountet ist....aber es muesste doch unter /mnt ?????

#fix permissions
chmod 1777 /mnt/tmp
cd /mnt ; ln -s usr/home home
chmod 1777 /mnt/var/tmp




#install FreeBSD
cd /usr/freebsd-distdem
export DESTDIR=/mnt
for file in base.txz kernel.txz doc.txz src.txz; #ports.txz lib32.txz
do (cat $file | tar --unlink -xpJf - -C ${DESTDIR:-/}); done

#final configuration
cp /var/tmp/zpool.cache /mnt/boot/zfs/zpool.cache
echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf
echo 'keymap="german.iso"' >> /mnt/etc/rc.conf
echo 'zfs_load="YES"' >> /mnt/boot/loader.conf
echo 'vfs.root.mountfrom="zfs:zroot"' >> /mnt/boot/loader.conf
echo 'LOADER_ZFS_SUPPORT=YES' > /mnt/etc/src.conf
##########
# MARK_A #
##########
echo 'WRKDIRPREFIX=/usr/obj' >> /mnt/etc/make.conf

touch /mnt/etc/fstab

##gmirror-swap##
#echo '/dev/mirror/swap none swap sw 0 0' >> /mnt/etc/fstab
#echo 'geom_mirror_load="YES"' >> /mnt/boot/loader.conf
##gmirror-swap##

echo '/dev/gpt/swap0 none swap sw 0 0' >> /mnt/etc/fstab
zfs set readonly=on zroot/var/empty
zfs umount -a

##reboot into the new system
#kbdmap
#passwd root
#tzsetup
#cd /etc/mail ; make aliases
#sysinstall network
#/etc/rc.d/netif start
#route add default 192.168.0.2
#/etc/rc.d/routing stop start restart

# ich lasse diesmal die standardshell csh
# alias stehen in /root/.cshrc z.B. alias ls  ls -G
# das ist eine andere Syntax im Vergleich zur .bashrc
# /etc/profile und /root/.profile wird von der csh nicht gelesen

#???echo 'WITH_PKGNG=yes' >> /etc/make.conf
#???in login.conf eintragen unter default:
#:charset=UTF-8:\
##:lang=de_DE.UTF-8:\

# Remember to rebuild the database after each change to the
# file /etc/login.conf
#cap_mkdb /etc/login.conf
 
Zurück
Oben