Manual partitioning

Hi, I'm novice with FreeBSD but have some experience with Linux.

My Hardware:
  • Threadripper 1900
  • 64 GB RAM
  • 2 TB nvme 4k PBS/LBS (physical/logical block size) = 1863 GiB

My Partitions on twin nvme
sgdisk -n 1:1M:+1G -t 1:ef00 -c 1:EFI-0002 $DISK sgdisk -n 2:0:+1766G -t 2:8300 -c 2:ARTIX-0002 $DISK sgdisk -n 3:0:+96G -t 3:8200 -c 3:SWAP-0002 $DISK
Note: Full GiB are used 16.07 MiB at end not used

My wished partitioning:
  • Partition Type Size Mountpoint Label
  1. freebsd-boot 1GiB
  2. freebsd-zfs 1766GiB /? BSDZ-001?
  3. freebsd-swap 96GiB
Questions:
  1. How are structured the disk-layers on ZFS? Disk-controller (PBS/LBS) structure at base, partitions boundaries on disk-structure, and formatting on top for at least boot and swap?
  2. Can I use 'manual partitioning' even for ZFS just choosing `freebsd-zfs` or have I to make many other "adjustment" for using ZFS?
  3. Can I use 1GiB boot partition or is there a size limitation?
  4. Can I make the partitions boundaries like shown, or must swap be absolutely on second place?
  5. Do you recommend an encrypted swap?
  6. Is inside the "dvd1.iso" an installation script there, e.g. for "Auto (ZFS)" where I can modify at least the partitions-size?
  7. Do ZFS span on all the partitions in this case or only on / (root)? And if swap is encrypted, too?
  8. Do I need an L2ARC and/or ZIL for such amount of RAM and SWAP on NVMe?

Sorry for so much, and maybe silly questions, to you. Thanks anyway if you can help me.
 
My wished partitioning:
  1. freebsd-boot 1GiB
1 GiB for a FreeBSD boot partition is exaggerated. These are the sizes in a GPT BIOS+UEFI partition scheme for 'efi' and 'freebsd-boot' partitions created by bsdinstall(8) guided installations:
Code:
# gpart show -p
=>      40  30001072    ada0  GPT  (14G)
        40    532480  ada0p1  efi  (260M)
    532520      1024  ada0p2  freebsd-boot  (512K)
    ...

  1. freebsd-swap 96GiB
See thread New freebsd-swap space with 400GB but htop shows 66.0G

2. Can I use 'manual partitioning' even for ZFS just choosing `freebsd-zfs` or have I to make many other "adjustment" for using ZFS?
Choosing 'freebsd-zfs' is sufficient.

3. Can I use 1GiB boot partition or is there a size limitation?
No size limitation, but see above response.

6. Is inside the "dvd1.iso" an installation script there, e.g. for "Auto (ZFS)" where I can modify at least the partitions-size?
That installation script on the installation image is /usr/libexec/bsdinstall/zfsboot. It creates the 'ZFS Configuration' menu and is also used for scripted installations (see bsdinstall(8), keyword /etc/installerconfig). But it doesn't allow to set a 'freebsd-zfs' partition size, except on 14.0-CURRENT, and only for scripted Root-on-ZFS.

To set the 'freebsd-zfs' partition size you need to open a shell at the "Partitioning" menu and set the size manually, or use a modified zfsboot script [1] [2], to get a menu with the option to set the zroot pool size.
 
1 GiB for a FreeBSD boot partition is exaggerated.
Not only that, freebsd-boot can't be larger than 545 KB or it will fail to load. The default size of 512 KB is more than enough.

Contrary to Linux freebsd-boot does NOT contain /boot, that directory is simply part of the root filesystem. The freebsd-boot partition contains code from gptzfsboot(8) or gptboot(8), and depends on if you boot to ZFS or UFS. It is not a filesystem, that partition is read as-is into memory and executed.

No size limitation, but see above response.
freebsd-boot does have a size limitation.

Code:
 The freebsd-boot partition should be smaller than 545 KB.
See gpart(8).
 
RFC2119 says that "SHOULD" means
This word, or the adjective "RECOMMENDED", mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.
As opposed to "MUST" which means
This word, or the terms "REQUIRED" or "SHALL", mean that the definition is an absolute requirement of the specification.
I conclude that the 545 KB limit is not mandatory.
 
RFC2119 says that "SHOULD" means

As opposed to "MUST" which means

I conclude that the 545 KB limit is not mandatory.
The code inside pmbr doesn't agree with that. It's really mandatory because freebsd-boot partition is loaded in x86 real-mode and you have less than 1 MiB of memory...

Code:
next_boot:    incl (%si)             # Next LBA
              adcl $0,4(%si)
              mov %es,%ax            # Adjust segment for next
              addw $SECSIZE/16,%ax   #  sector
              cmp $0x9000,%ax        # Don't load past 0x90000,
              jae err_big            #  545k should be enough for
              mov %ax,%es            #  any boot code. :)
              jmp load_boot
 
Code:
Code:
# gpart show -p
=>      40  30001072    ada0  GPT  (14G)
        40    532480  ada0p1  efi  (260M)
    532520      1024  ada0p2  freebsd-boot  (512K)
    ...
My GPT partitions (under Linux) start at sector 256 (by 4k PBS/LBS) not at sector 40, is there a reason for that? Or a special need from BSD?
40*4k=160k is enough space for GPT-information? Or is sector 40 "only for MBR? Or 512k/4k=128, 255-128 =127 hence start on 120~127 sector?
If I used a disk for FreeBSD-OS and later-on want to use it for ZFS-Data-Storage, have I at least to erase the first MiB on the disk with dd and afterward make a new GPT-table?
Some application like Firefox take so much RAM making the whole machine slow or freezing if swap is not oversized, this phenomena stop (by me) as I set 1.5*RAM as swap, to be tested or replace web-browser in freebsd.
Not only that, freebsd-boot can't be larger than 545 KB or it will fail to load. The default size of 512 KB is more than enough.

Contrary to Linux freebsd-boot does NOT contain /boot, that directory is simply part of the root filesystem. The freebsd-boot partition contains code from gptzfsboot(8) or gptboot(8), and depends on if you boot to ZFS or UFS. It is not a filesystem, that partition is read as-is into memory and executed.

I read some instructions assigning also 800k to freebsd-boot but these instructions confirm yours.
Does anyone know where zbm (zfs-boot-menu) (in case) will take place? or is this not supported by free-bsd?
Is this code making FAT32 or VFAT EFI?
Code:
gpart add -a 4k -s 800K -t efi ada0
 # prior to FreeBSD 12.x
 gpart bootcode -p /boot/boot1.efifat -i 1 ada0
 # for FreeBSD 12.x and up, create a FAT32 partition
 newfs_msdos -F 32 -c 1 /dev/ada0p1
 mount -t msdosfs -o longnames /dev/ada0p1 /mnt
 mkdir -p /mnt/EFI/BOOT
 cp /boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi
I ask this because, if I want format efi-partition, I have to use vfat instead, see:
Code:
mkfs.vfat -F32 -s 2 -S 4096 -v /dev/nvme0n1p1
fat32 don't work at all, this code (at least under Linux not):
Code:
mkfs.fat -F 32 -n EFI /dev/nvme0n1p1

How do FreeBSD installer handle swap?
if freebsd-udf is chosen, then make a freebsd-swap partition and...
if freebsd-zfs is chosen, then make a "swap" volume or subvolume on the (remaining) disk?
Is necessary or recommended encrypting swap choosing ZFS?

How do FreeBSD installer handle encryption?
I read full-disk-encryption with GELI, "only" zroot encryption with OpenZFS (apparently not at all recommended, in Ubuntu 21.10 also not working, I read in forum).
It's possible to choose (using the installer) the type/kind of encryption or succeed automatically, depending on FS (udf, zfs) and/or swap (encrypted or not)?
But it doesn't allow to set a 'freebsd-zfs' partition size, except on 14.0-CURRENT, and only for scripted Root-on-ZFS.
Partition size or empty space at end of disk (if you want to replace a raid-disk) is very important and not only for that.
Well, if 14.0-CURRENT allow it, allow it in the installer like with swap or script modifying is still necessary?

Thank you guy for all the given answers, that's good for my knowledge and... please don't misunderstand me, I just would understand well how FreeBSD works.
 
Questions:
  1. How are structured the disk-layers on ZFS? Disk-controller (PBS/LBS) structure at base, partitions boundaries on disk-structure, and formatting on top for at least boot and swap?
  2. Can I use 'manual partitioning' even for ZFS just choosing `freebsd-zfs` or have I to make many other "adjustment" for using ZFS?
  3. Can I use 1GiB boot partition or is there a size limitation?
  4. Can I make the partitions boundaries like shown, or must swap be absolutely on second place?
  5. Do you recommend an encrypted swap?
  6. Is inside the "dvd1.iso" an installation script there, e.g. for "Auto (ZFS)" where I can modify at least the partitions-size?
  7. Do ZFS span on all the partitions in this case or only on / (root)? And if swap is encrypted, too?
  8. Do I need an L2ARC and/or ZIL for such amount of RAM and SWAP on NVMe?
  1. For starters, ZFS is a very different beast. You can configure the datasets to be roughly equivalent to "partitions" of UFS - and even do it post-install, and adjust it later - but there are reasons to leave it alone. A big reason is Boot Environments - that stuff works best with the defaults offered at installation.
  2. Not impossible, but it's more sensible to stick with defaults if you choose ZFS at install.
  3. Per SirDice post earlier, you only need 545 KB or less, and yes, that is a limitation. Fortunately, ZFS install will take care of that for you.
  4. Swap? no such animal in ZFS. Take a look here.
  5. See answer #4.
  6. See answer #1.
  7. Not impossible, but mixing of different filesystems is not recommended on a single disk. Once again, no swap needed.
  8. No idea, but your system's specs suggest that you don't need any special messing around with compression to successfully run ZFS. Once again, no swap even needed.
 
Actually, VFAT and FAT32 are orthogonal. Any FAT filesystem can be used as "VFAT" (hiding "long" filenames in extra directory entries that have attributes considered invalid by original FAT and therefore are just invisble when VFAT ist not supported), it's just a question of how it is mounted. It's totally irrelevant when creating a FAT filesystem.
 
Well, I should use the standard bsd-installer and I will do it.

Now, the Linux standard installers (Ubiquity, Calamares) don't recognize my native 4k PBS & LBS (4096 physical and logical block size) of my 2TB NVMe at all, so I'm forced to make partitioning and formatting manually and advice the installer to use part 1 for EFI, part 2 for ROOT and part 3 for SWAP.
See here (1st code-block partitioning, 2nd code-block formatting):
Code:
sgdisk -n 1:1M:+1G -t 1:ef00 -c 1:EFI-0002 $DISK

sgdisk -n 2:0:+1766G -t 2:8300 -c 2:ARTIX-0002 $DISK

sgdisk -n 3:0:+96G -t 3:8200 -c 3:SWAP-0002 $DISK

mkfs.vfat -F32 -s 2 -S 4096 -v $DISK-part1

mkfs.ext4 -F -b 4096 -F $DISK-part2

mkswap -f -p 4096 $DISK-part3
I can understand if you are not familiar with Linux, hence I put my question as simple as possible:
Will the bsd-installer recognize the native 4k sector of my NVMe 100%? or have I to make tricks?
Note: Native 4k (no 512 and no 512e (fake 4k)) on NVMe.

FAT32. See newfs_msdos(8):
Code:
-F FAT-type
FAT type (one of 12, 16, or 32).
In this precise case: Will newfs_msdos of bsd-installer recognize native 4k and use automatically the -S switch/option or have I to force it anyway?
Code:
-S    sector-size
         Number of bytes per sector.  Acceptable values are    powers of 2 in
         the range 512 through 32768, inclusive.
Swap? no such animal in ZFS. Take a look here.
Bad news (in any sense), Swap is there, the size can be increased and the option to encrypt it is present too.
Maybe not under zroot, maybe in an additional partition, maybe as swap-file, BUT... if the bsd-installer (§ 2.6.4 Guided Partitioning Using Root-on-ZFS) say, is there, then should it be somewhere and reported in fstab.
I don't ask "Where is Bill" (like in Tarantino film) but "Where is Swap" and which kind of swap is, e.g. frebsd-swap or something else.
Not impossible, but mixing of different filesystems is not recommended on a single disk. Once again, no swap needed.
I don't want mix anything, nor convert Freebsd to act as a Linux, I just want to install a rock-solid FreeBSD and would understand some particularity. Swap is there by default and is needed too.
No idea, but your system's specs suggest that you don't need any special messing around with compression to successfully run ZFS. Once again, no swap even needed.
L2ARC and/or ZIL are not compression but "data-buffers", lz4 compression is recommended even in BSD-forum but not present as option in bsd-installer. I don't understand this, but I don't care too because of 2TB NVMe. I don't intent to use FreeBSD as "Server" but as OS without 'SystemD' but with perfect integrated ZFS.

The need or not of swap will I not comment again or anymore. It's true, I don't know FreeBSD but I know e.g. Firefox, KDE5, etc., so... I don't know if BSD modified those packages and really swap is not needed, but I have plenty of place (2TB), bsd-installer offer it and I will definitely have on BSD.
 
Bad news (in any sense), Swap is there, the size can be increased and the option to encrypt it is present too.
Maybe not under zroot, maybe in an additional partition, maybe as swap-file, BUT... if the bsd-installer (§ 2.6.4 Guided Partitioning Using Root-on-ZFS) say, is there, then should it be somewhere and reported in fstab.
I don't ask "Where is Bill" (like in Tarantino film) but "Where is Swap" and which kind of swap is, e.g. frebsd-swap or something else.
Yeah, the FreeBSD installer screenie that you link to does mention swap even when selecting the ZFS install. However no, it's not reported in /etc/fstab. You can safely ignore that option, leave it on whatever default value is supplied, and continue the installation. If you select UFS (as opposed to ZFS) at install - then yeah, you gotta worry about swap. But ZFS is a totally different beast, it frees you from that. I haven't tried Linux on ZFS (no time for that for me), but I keep seeing info that this is where FreeBSD is WAY ahead of Linux :p

FWIW, my rig has a Ryzen 5 1400, 32 GB of RAM, and a 256 GB SSD. I'm on 13-RELEASE, but was messing around with ZFS-based FreeBSD installs since 2017, when my processor was just released. And - no issues with ZFS, no messing with options to fine-tune my install, just plain a bit of exploring to squeeze interesting juice out of that. :P
 
If you select UFS (as opposed to ZFS) at install - then yeah, you gotta worry about swap. But ZFS is a totally different beast, it frees you from that.
Are you suggesting to use ZFS volumes for swap? ?

If so, don't. Always use classic swap partitions. The reason is, ZFS itself can need dynamically allocated memory. If that allocation triggers a page fault and the pager must "swap out" pages to solve it, it would need ZFS to do so, creating a nice deadlock.
 
Partition size or empty space at end of disk (if you want to replace a raid-disk) is very important and not only for that.
Well, if 14.0-CURRENT allow it, allow it in the installer like with swap or script modifying is still necessary?
The zfsboot script from 14.0-CURRENT doesn't provide a menu option in the "ZFS Configuration" dialog. It provides a environment variable which can be used to determine the pool size in a scripted installation only. As example how to use, taking from the bsdinstall(8) manual, chapter "SCRIPTING":

/etc/installerconfig (file not a part of the official installer media, needs to be created):
Code:
DISTRIBUTIONS="kernel.txz base.txz"
export ZFSBOOT_VDEV_TYPE=stripe
export ZFSBOOT_DISKS="ada0 ada1"

export ZFSBOOT_POOL_SIZE=1766g

export nonInteractive="YES"
If you want a menu option in the "ZFS Configuration" dialog you can replace the original script with the modified zfsboot I linked to at the end of post #3
 
Zirias : Did you see OP's HW specs? several steps up from mine. I never had to worry about page faults, so I see no reason why OP should, either.
 
If you don't, why add swap at all? Without swap, if you ever hit such a situation, OOM-killer will take care of it (at the expense of a killed process). IMHO still better than running into a deadlock.
 
I don't know about version 14.0-CURRENT, but, using FreeBSD-13.0-RELEASE-amd64-memstick.img with the automatic ZFS install option gave me a freebsd-swap partition on partition 3, and this swap partition is specifed in the /etc/fstab file in exactly the same way as in a UFS install.

The freebsd-boot and freebsd-zfs partitions are not in /etc/fstab, but the efi and the freebsd-swap partitions are.
 
Thank you all for your contributions.
FAT32 will not work at all with native 4k PBS/LBS, at least don't work in Linux. Before I start such thing, I would be sure FreeBSD is 100% able to handle native 4k properly. Anyone knows it?

As example how to use, taking from the bsdinstall(8) manual, chapter "SCRIPTING":
The zfsboot script from 14.0-CURRENT doesn't provide a menu option in the "ZFS Configuration" dialog. It provides a environment variable which can be used to determine the pool size in a scripted installation only. As example how to use, taking from the bsdinstall(8) manual, chapter "SCRIPTING":

From § scriptedpart parameters/size
[/I] specifies the partition size to create in bytes (K, M, and G suffixes can be appended to specify kilo- bytes, megabytes, and gigabytes respectively) [I]

To assure 4k boundary the size must be given in KiB, MiB and GiB (Kibibyte, Mebibyte, Gibibyte) and not KB, MB, GB that not assure anything but boundary fragmentation.

The freebsd-boot and freebsd-zfs partitions are not in /etc/fstab, but the efi and the freebsd-swap partitions are.
Thanks for your confirmation. Is the FEI-partition the one starts at sector 40 on first 1 MiB of disk? Or it's something different?


I'm a little bit surprised, frustrated and dismayed in discovering the need of such long (and sometimes controversial) discussion just talking/asking about partitioning only.

I hope, some developers and wiki-maintainers read this thread and can provide some clarification and/or modify the options of bsdinstall/pre.

For me is disk-handling in an OS the most important thing, I also expect a "GUI"-installer detect/recognize if disk-block-size is switchable and ask for or execute the switch e.g. from 512 to 4096 automatically.

Please don't hesitate to contact me as soon you have some (for me) important information.

Thank you all again for your effort, bye!
 
It's not necessary to start at sector 40.
The designation is not FEI, it's EFI, or UEFI. Yes, it's something different. You can read all about it here:
Sorry, that was a writing mistake (FEI), naturally I mean EFI/UEFI.

And no, your link don't clarify anything because there are only dare description about EFI on Linux, Windows and Mac-OS but not in BSD.
Beside, this don't clarify how the "GUI-installer" handle the EFI-partition, where put it exactly and if recognize the native 4k-sectors properly.

Wikipedia is not a reliable source in this case but the experts of FreeBSD and hence I ask here and not wikipedia to include an article for EFI on FreeBSD.

Pointing me (or anybody else) to wikipedia article is a very bad idea, I don't like it at all, is not polite (to send client to pastry to ask how is the pork-tenderloin), sorry!
And I prove it using the ext4 file-system as an example:

If you have a disk with native (already 10 years old) 4k-sectors, the Ext4 file-system don't recognize it at all, but relay on what is listening from Kernel, if the kernel is well/right configured or loaded.
This mean ext4-fs is blind but hear/listen from kernel, here the prove:
mkfs.ext4 -F -b 4096 -F $DISK-part2
as you can see, the use of switch/option -F (that mean FORCE) is needed twice to oblige ext4 to recognize the 4k-sector on themselves and not only listening from kernel.

The same is valid for vfat and linux-swap,,, fat32 don't work at all but, these are other stories.
The conclusion about Linux-file-systems on 4k disks is:
- The partitioning ==> setting partitions-boundaries (partitions-delimitations) in GPT is OK and contains FAT32 (EFI, code: ef00), ext4 (/ called also root, code: 8300) and linux-swap (code: 8200).
- The formatting is NOT OK ==> EFI: force vfat and 4k-bs (block-size), ROOT: force 4k-bs twice, SWAP: set ps (page-size= block-size) to 4096=4k

Now you can read the wikipedia article on ext4 and tell me (afterwards) if any of this topics are handled or at least mentioned with one word in the article.

And, how will you feel if you ask me about ext4 and I post a wikipedia-article instead? It's not shaming to say "I don't know"! And, yes, I (myself) don't know anything about Freebsd and hence ask here.

Listen: Screens have controllers with EDID-information, disks have controllers telling how big is a data-carrier, the sectors-size and so on, GPUs have controllers, each piece of hardware have a controller sending information about itself, but... data-carriers/disks are the most important piece of HW where all the information and data of an OS are stored on them, that allow the OS to work at all / boot.

It's not like reload EDID in xorg or install GPU-driver after the installation. If disks are not handled well/properly, you cannot boot at all, and you have no possibility to remedy to it at all.

If you (or anybody else here) cannot tell me how to remove efi-boot-loader (safely) from first MiB of disk without damaging the disk same for using this same disk as file-storage or to use it with another OS (installing another OS on it), I will not risk wasting a 2TB NVMe costs 250-350$ only for experimenting with FreeBSD. I will not even waste a USB-stick for that, for it are VMs (virtual machines) that don't tell almost anything about a real (bare-metal) OS.

We/I still talking about just normal/standard FreeBSD with own "GUI-installer" hence "Auto-ZFS", we/I not talking now (anymore) about special partitioning or "rEFInd + zbm (zfs-boot-manager) + FreeBSD + Artix-Linux + Debian" like here.
 
Back
Top