ZPOOL create ZFS create How to use Disk Partitions in Single DISK ZFS setup
zt.sh file below
#!/bin/sh
if [ ! -f /mnt/COPYRIGHT ]
then
echo "Forgot to mount disk image"
exit 1
fi
set -e
set -x
zpool destroy zpi || true
zpool create -O compress=lz4 -O atime=off -o altroot=/zpialt -m none zpi da1s2
zfs create -o mountpoint=none zpi/ROOT
zfs create -o mountpoint=/ zpi/ROOT/default
zfs create -o mountpoint=/tmp -o exec=on -o setuid=off zpi/tmp
zfs create -o mountpoint=/usr -o canmount=off zpi/usr
zfs create zpi/usr/home
zfs create -o setuid=off zpi/usr/ports
zfs create zpi/usr/src
zfs create -o mountpoint=/var -o canmount=off zpi/var
zfs create -o exec=off -o setuid=off zpi/var/audit
zfs create -o exec=off -o setuid=off zpi/var/crash
zfs create -o exec=off -o setuid=off zpi/var/log
zfs create -o atime=on zpi/var/mail
zfs create -o setuid=off zpi/var/tmp
zfs set mountpoint=/zpi zpi
chmod 1777 /zpialt/tmp
chmod 1777 /zpialt/var/tmp
zpool set bootfs=zpi/ROOT/default zpi
zfs set canmount=noauto zpi/ROOT/default
cd /mnt
tar cf - . | ( cd /zpialt && tar xvf - )
echo 'zfs_load="YES"' >> /zpialt/boot/loader.conf
echo 'kern.geom.label.disk_ident.enable=0' >> /zpialt/boot/loader.conf
#echo 'kern.geom.label.gptid.enable=0' >> /zpialt/boot/loader.conf
sed -i '' '/boot_serial/ s/^/#/' /zpialt/boot/loader.conf
sed -i '' '/beastie_disable/ s/^/#/' /zpialt/boot/loader.conf
echo 'zfs_enable="YES"' >> /zpialt/etc/rc.conf
sed -i '' /ufs/d /zpialt/etc/fstab
zpool export zpi
Zfs2_home.sh file below, needs some editing for zpihome zpihomealt setup
#!/bin/sh
# if [ ! -f /mnt/COPYRIGHT ]
if [ ! -f /COPYRIGHT ]
then
echo "Forgot to mount disk image"
ls -l /mnt
gpart status
gpart show -lp
exit 1
fi
set -e
set -x
cd /
zpool destroy zpi || true
zpool destroy zpihome || true
zpool create -O compress=lz4 -O atime=off -o altroot=/zpialt -m none zpi da0p3
zpool create -O compress=lz4 -O atime=off -o altroot=/zpihomealt -m none zpihome da0p4
zfs create -o mountpoint=none zpi/ROOT
zfs create -o mountpoint=/ zpi/ROOT/default
zfs create -o mountpoint=/tmp -o exec=on -o setuid=off zpi/tmp
zfs create -o mountpoint=/usr -o canmount=off zpi/usr
# zfs create zpi/usr/home
zfs create -o mountpoint=/usr2 zpihome/usr2
zfs create zpihome/usr2/home
# zfs create -o setuid=off zpi/usr/ports
# zfs create -o setuid=off -o mountpoint=/usr2/ports -o canmount=off zpihome/usr2/ports
zfs create zpihome/usr2/ports
# zfs create zpi/usr/src
zfs create zpihome/usr2/src
zfs create -o mountpoint=/var -o canmount=off zpi/var
zfs create -o exec=off -o setuid=off zpi/var/audit
zfs create -o exec=off -o setuid=off zpi/var/crash
zfs create -o exec=off -o setuid=off zpi/var/log
zfs create -o atime=on zpi/var/mail
zfs create -o setuid=off zpi/var/tmp
zfs set mountpoint=/zpi zpi
zfs set mountpoint=/zpihome zpihome
chmod 1777 /zpialt/tmp
chmod 1777 /zpialt/var/tmp
zpool set bootfs=zpi/ROOT/default zpi
zfs set canmount=noauto zpi/ROOT/default
zfs set canmount=noauto zpihome/usr2
zfs set canmount=noauto zpihome/usr2/home
zfs set canmount=noauto zpihome/usr2/ports
zfs set canmount=noauto zpihome/usr2/src
ls -l /usr/home
ls -l /usr2/home
ls -l /usr/ports
ls -l /usr2/ports
ls -l /usr/src
ls -l /usr2/src
ls -l zpi*
ls -l zpihomealt/usr2
ls -l zpihomealt/zpihome
cd /
tar cf - . | ( cd /zpialt && tar xvf - )
# cd /mnt
cd /usr/home
tar cf - . | ( cd zpihome/usr2/home && tar xvf - )
cd /usr/ports
tar cf - . | ( cd zpihome/usr2/ports && tar xvf - )
cd /usr/src
tar cf - . | ( cd zpihome/usr2/src && tar xvf - )
# now that these 3 directories have been copied, hide them to not copy a second time
# cd /usr ; mv home /mnt/tmp1 ; mv ports /mnt/tmp2 ; mv src /mnt/tmp3
# cd /
# tar cf - . | ( cd /zpialt && tar xvf - )
echo 'zfs_load="YES"' >> /zpialt/boot/loader.conf
echo 'kern.geom.label.disk_ident.enable=0' >> /zpialt/boot/loader.conf
#echo 'kern.geom.label.gptid.enable=0' >> /zpialt/boot/loader.conf
sed -i '' '/boot_serial/ s/^/#/' /zpialt/boot/loader.conf
sed -i '' '/beastie_disable/ s/^/#/' /zpialt/boot/loader.conf
echo 'zfs_enable="YES"' >> /zpialt/etc/rc.conf
sed -i '' /ufs/d /zpialt/etc/fstab
zpool export zpi
zpool export zpihome
# https://serverfault.com/questions/596812/setup-zfs-on-freebsd-from-bsd-rescue good reference page
echo move back /usr/home from /mnt/tmp1 /usr/ports from /mnt/tmp2 /usr/src from /mnt/tmp3
echo check the /mnt/msdos/boot/efi directory for the zfsboot ability.
No comments:
Post a Comment