Solved install freebsd14 with zfs , how to manual create new dataset and mount it at /usr in zfs pool?

Dear all:
i have install freebsd14 with zfs in shell mode. but i dont' know how to create new zfs dataset /usr to mount at /usr , and other /home , /var in new datatset ?
    1. gpart destroy -F ada0
    2. gpart create -s gpt ada0.
    3. gpart add -a 4k -t efi -s 512M -l efi ada0
    4. newfs_msdos -F 32 -c 1 /dev/ada0p1
    5. mount -t msdosfs -o longnames /dev/ada0p1 /mnt
    6. mkdir -p /mnt/EFI/BOOT
    7. cp /boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi.
    8. gpart add -t freebsd-swap -s 32G -l freebsd-swap ada0
    9. swapon /dev/ada0p2
    10. gpart add -t freebsd-zfs -l system ada0.
    11. mount -t tmpfs tmpfs /mnt
    12. zpool create -o altroot=/mnt zroot ada0p3
  1. Create the file system hierarchy.
    1. Set compression.
      1. zfs set compression=on zroot
    2. Create a boot environment hierarchy and set up so you can install.
      1. zfs create -o mountpoint=none zroot/ROOT
      2. zfs create -o mountpoint=/ -o canmount=noauto zroot/ROOT/default
      3. mount -t zfs zroot/ROOT/default /mnt
Question : how to create zfs dateset to mount at /usr ? below is my configure , but that's not work for me. the new dataset can't mount to /usr . could you help me to create it ? thanks.
zfs create -o mountpoint=/home zroot/home
zfs create -o mountpoint=/usr zroot/usr
zfs create -o mountpoint=/var zroot/var

Installing the system​

  1. Install the system by copying the system files from the live CD. If there is a way to download these files off the web before uncompressing them, I'd love to hear it.
    1. cd /mnt
    2. tar xvJf /usr/freebsd-dist/base.txz
    3. tar xvJf /usr/freebsd-dist/kernel.txz
    4. tar xvJf /usr/freebsd-dist/lib32.txz
  2. Configure the boot environment
    1. zpool set bootfs=zroot/ROOT/default zroot
  3. Chroot in and configure fstab for swap and rc.conf and loader.conf to load the ZFS drivers.
    1. chroot /mnt
    2. echo /dev/ada0p2 none swap sw 0 0 > /etc/fstab
    3. sysrc zfs_enable=YES
    4. echo zfs_load=”YES” >> /boot/loader.conf
  4. Set the timezone, network and hostnames.
    1. tzsetup
thanks.....
 
Just now I installed 14.1 release in a VM (to help a friend). He has 4 disks and was asking me how to setup raid10. I did this using basically all the defaults (I forget now the option I used -- I think it was striped zfs or something). The default setup seems just about right for him. This is what I got (with 4 x 16GB virtual nvme "disks"):

Code:
 # df -h
Filesystem            Size    Used   Avail Capacity  Mounted on
zroot/ROOT/default     26G    1.6G     25G     6%    /
devfs                 1.0K      0B    1.0K     0%    /dev
/dev/gpt/efiboot0     260M    1.3M    259M     1%    /boot/efi
zroot/tmp              25G     96K     25G     0%    /tmp
zroot/home             25G     96K     25G     0%    /home
zroot/home/bakul       25G    156K     25G     0%    /home/bakul
zroot/var/tmp          25G     96K     25G     0%    /var/tmp
zroot                  25G     96K     25G     0%    /zroot
zroot/usr/ports        25G     96K     25G     0%    /usr/ports
zroot/usr/src          25G     96K     25G     0%    /usr/src
zroot/var/audit        25G     96K     25G     0%    /var/audit
zroot/var/crash        25G     96K     25G     0%    /var/crash
zroot/var/log          25G    148K     25G     0%    /var/log
zroot/var/mail         25G    104K     25G     0%    /var/mail

# swapinfo -h
Device              Size     Used    Avail Capacity
/dev/nda0p3         2.0G       0B     2.0G     0%
/dev/nda1p3         2.0G       0B     2.0G     0%
/dev/nda2p3         2.0G       0B     2.0G     0%
/dev/nda3p3         2.0G       0B     2.0G     0%
Total               8.0G       0B     8.0G     0%

No manual setup (other than to select the 4 "disks"). If you install from "FreeBSD-14.1-RELEASE-amd64-bootonly.iso" you can download everything else you need once you setup the network connection.

See if this works for you. If not, you can use this as a template to add more disks etc. You can use "zpool history" to see what the system did:

Code:
# zpool history
History for 'zroot':
2024-06-04.12:58:13 zpool create -o altroot=/mnt -O compress=lz4 -O atime=off -m none -f zroot mirror nda0p4 nda1p4 mirror nda2p4 nda3p4
2024-06-04.12:58:13 zfs create -o mountpoint=none zroot/ROOT
2024-06-04.12:58:13 zfs create -o mountpoint=/ zroot/ROOT/default
2024-06-04.12:58:13 zfs create -o mountpoint=/home zroot/home
2024-06-04.12:58:13 zfs create -o mountpoint=/tmp -o exec=on -o setuid=off zroot/tmp
2024-06-04.12:58:13 zfs create -o mountpoint=/usr -o canmount=off zroot/usr
2024-06-04.12:58:13 zfs create -o setuid=off zroot/usr/ports
2024-06-04.12:58:13 zfs create zroot/usr/src
2024-06-04.12:58:13 zfs create -o mountpoint=/var -o canmount=off zroot/var
2024-06-04.12:58:13 zfs create -o exec=off -o setuid=off zroot/var/audit
2024-06-04.12:58:13 zfs create -o exec=off -o setuid=off zroot/var/crash
2024-06-04.12:58:13 zfs create -o exec=off -o setuid=off zroot/var/log
2024-06-04.12:58:14 zfs create -o atime=on zroot/var/mail
2024-06-04.12:58:14 zfs create -o setuid=off zroot/var/tmp
2024-06-04.12:58:14 zfs set mountpoint=/zroot zroot
2024-06-04.12:58:14 zpool set bootfs=zroot/ROOT/default zroot
2024-06-04.12:58:14 zpool set cachefile=/mnt/boot/zfs/zpool.cache zroot
2024-06-04.12:58:14 zfs set canmount=noauto zroot/ROOT/default
2024-06-04.13:01:44 zfs create -u zroot/home/bakul
2024-06-04.13:01:44 zfs set mountpoint=legacy zroot/home/bakul
2024-06-04.13:01:44 zfs allow bakul create,destroy,mount,snapshot zroot/home/bakul
2024-06-04.13:01:44 zfs inherit mountpoint zroot/home/bakul
 
Just now I installed 14.1 release in a VM (to help a friend). He has 4 disks and was asking me how to setup raid10. I did this using basically all the defaults (I forget now the option I used -- I think it was striped zfs or something). The default setup seems just about right for him. This is what I got (with 4 x 16GB virtual nvme "disks"):

Code:
 # df -h
Filesystem            Size    Used   Avail Capacity  Mounted on
zroot/ROOT/default     26G    1.6G     25G     6%    /
devfs                 1.0K      0B    1.0K     0%    /dev
/dev/gpt/efiboot0     260M    1.3M    259M     1%    /boot/efi
zroot/tmp              25G     96K     25G     0%    /tmp
zroot/home             25G     96K     25G     0%    /home
zroot/home/bakul       25G    156K     25G     0%    /home/bakul
zroot/var/tmp          25G     96K     25G     0%    /var/tmp
zroot                  25G     96K     25G     0%    /zroot
zroot/usr/ports        25G     96K     25G     0%    /usr/ports
zroot/usr/src          25G     96K     25G     0%    /usr/src
zroot/var/audit        25G     96K     25G     0%    /var/audit
zroot/var/crash        25G     96K     25G     0%    /var/crash
zroot/var/log          25G    148K     25G     0%    /var/log
zroot/var/mail         25G    104K     25G     0%    /var/mail

# swapinfo -h
Device              Size     Used    Avail Capacity
/dev/nda0p3         2.0G       0B     2.0G     0%
/dev/nda1p3         2.0G       0B     2.0G     0%
/dev/nda2p3         2.0G       0B     2.0G     0%
/dev/nda3p3         2.0G       0B     2.0G     0%
Total               8.0G       0B     8.0G     0%

No manual setup (other than to select the 4 "disks"). If you install from "FreeBSD-14.1-RELEASE-amd64-bootonly.iso" you can download everything else you need once you setup the network connection.

See if this works for you. If not, you can use this as a template to add more disks etc. You can use "zpool history" to see what the system did:

Code:
# zpool history
History for 'zroot':
2024-06-04.12:58:13 zpool create -o altroot=/mnt -O compress=lz4 -O atime=off -m none -f zroot mirror nda0p4 nda1p4 mirror nda2p4 nda3p4
2024-06-04.12:58:13 zfs create -o mountpoint=none zroot/ROOT
2024-06-04.12:58:13 zfs create -o mountpoint=/ zroot/ROOT/default
2024-06-04.12:58:13 zfs create -o mountpoint=/home zroot/home
2024-06-04.12:58:13 zfs create -o mountpoint=/tmp -o exec=on -o setuid=off zroot/tmp
2024-06-04.12:58:13 zfs create -o mountpoint=/usr -o canmount=off zroot/usr
2024-06-04.12:58:13 zfs create -o setuid=off zroot/usr/ports
2024-06-04.12:58:13 zfs create zroot/usr/src
2024-06-04.12:58:13 zfs create -o mountpoint=/var -o canmount=off zroot/var
2024-06-04.12:58:13 zfs create -o exec=off -o setuid=off zroot/var/audit
2024-06-04.12:58:13 zfs create -o exec=off -o setuid=off zroot/var/crash
2024-06-04.12:58:13 zfs create -o exec=off -o setuid=off zroot/var/log
2024-06-04.12:58:14 zfs create -o atime=on zroot/var/mail
2024-06-04.12:58:14 zfs create -o setuid=off zroot/var/tmp
2024-06-04.12:58:14 zfs set mountpoint=/zroot zroot
2024-06-04.12:58:14 zpool set bootfs=zroot/ROOT/default zroot
2024-06-04.12:58:14 zpool set cachefile=/mnt/boot/zfs/zpool.cache zroot
2024-06-04.12:58:14 zfs set canmount=noauto zroot/ROOT/default
2024-06-04.13:01:44 zfs create -u zroot/home/bakul
2024-06-04.13:01:44 zfs set mountpoint=legacy zroot/home/bakul
2024-06-04.13:01:44 zfs allow bakul create,destroy,mount,snapshot zroot/home/bakul
2024-06-04.13:01:44 zfs inherit mountpoint zroot/home/bakul
dear bakful:
i know how to create dataset in zfs pool. my question is when i create pool14/home dataset in pool14 by manual(zfs create -o mountpoint=/home pool14/home ), i want to mount pool14/home to /home . i don't know where i can do it . when i try to mount it , the system will fail, and don't start up. thanks.
 
solution : below part of code show how to build our custom dataset mountpoint in zfs system only .

# mkdir tmp/xxx
# zpool create -o altroot=/tmp/xxx -f p99 vtbd0p3
# zfs create -o mountpoint=/ p99/system
# zfs create -o mountpoint=/home p99/home
# zfs create -o mountpoint=/usr p99/usr
# zfs create -o mountpoint=/var p99/var
# cd tmp/xxx/
# ls
home usr var
# tar xvJf /usr/freebsd-dist/base.txz
# tar xvJf /usr/freebsd-dist/kernel.txz
# ee boot/loader.conf
add zfs_load="yes"
# ee etc/rc.conf
add zfs_enable="yes"

# zpool set bootfs=p99/system p99
#reboot

new system will up now.

import core : we must configure altroot option first before create root pool. and then create other zfs dataset . if you don't give altroot options first, we can't operate creating dataset in right location. thanks for all. i have spent 7days and operate more than 100 test . a new guy in freebsd 14.
 
Back
Top