Tuesday, March 28, 2023

ZPOOL create ZFS create How to use Disk Partitions in Single DISK ZFS setup

ZPOOL create    ZFS create  How to use Disk Partitions in Single DISK ZFS setup 

URLs to Read. For you to gain understanding.  Takes time to Learn well
:

https://unix.stackexchange.com/questions/672151/create-zfs-partition-on-existing-drive   Create ZFS Partition on existing disk  like  /dev/sda3 

https://docs.oracle.com/cd/E19253-01/819-5461/gaynr/index.html  Create a ZFS root pool  Oracle Docs on ZFS Zettabyte File System
https://github.com/openzfs/zfs  OpenZFS  Readme.md file


  
What I want to do with my ZFS disk system.  I am using UEFI GPT, two partitions one for root /dev/sda5, one larger for home /dev/sda6 .   Boot from the ESP EFI FAT32 /EFI/freebsd/bootx64aa.efi  into the ZFS file system on a Raspberry Pi 4B with 8 gigabytes of dram memory.  I want 50 -80 GB for the root "/"  disk space.   I want 130-180 GB for the home "/home"  "/usr/ports" "/usr/home" "/usr/src"   "/home" is symbolic link to "/usr/home" 

  I am using rEFInd EFI app to select which operating system to boot on the Raspberry Pi.  I would like to boot  PuppyLinux Raspup 32bit, POP!_OS ARM64, Manjaro ARM64,  and other test arm64 OS like Raspberry Pi OS.
 
forums.freebsd.org 


https://lists.freebsd.org/archives/freebsd-arm/  FreeBSD arm mailing list subscribe



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