Add a swap slice (partition) on a mirror
Notes for creating swap for a NAS4Free box as a workaround to some form of crash/panic.
The swap space is on a plain set of disks. Not on a ZFS filesystem.
Partitions
Ensure the mirror is clean by deleting any old partion tables
# gpart destroy -F mirror/1TBRedMirror mirror/1TBRedMirror destroyed
Create a new GUID partition table:
# gpart create -s GPT mirror/1TBRedMirror mirror/1TBRedMirror created
Add a swap partition
# gpart add -t freebsd-swap -a 4k -s 64G mirror/1TBRedMirror mirror/1TBRedMirrorp1 added
Use the rest of the disk for a UFS filesystem
# gpart add -t freebsd-ufs -a 4k mirror/1TBRedMirror mirror/1TBRedMirrorp2 added
Verify what is there:
# gpart show mirror/1TBRedMirror => 34 1953525100 mirror/1TBRedMirror GPT (931G) 34 6 - free - (3.0k) 40 134217728 1 freebsd-swap (64G) 134217768 1819307360 2 freebsd-ufs (867G) 1953525128 6 - free - (3.0k)
Filesystem
Create a UFS filesystem on the second partition:
# newfs -U /dev/mirror/1TBRedMirrorp2 /dev/mirror/1TBRedMirrorp2: 888333.7MB (1819307360 sectors) block size 32768, fragment size 4096 using 1419 cylinder groups of 626.09MB, 20035 blks, 80256 inodes. with soft updates super-block backups (for fsck_ffs -b #) at: 192, 1282432, 2564672, 3846912, 5129152, 6411392, 7693632, 8975872, .... lots more ...
Links
- https://www.freebsd.org/doc/handbook/geom-mirror.html
- https://www.freebsd.org/cgi/man.cgi?gpart%288%29
Appendicies
gpart partition types
bios-boot The system partition dedicated to second stage of the boot loader program. Usually it is used by the GRUB 2 loader for GPT partitioning schemes. The scheme-specific type is "!21686148-6449-6E6F-744E-656564454649". efi The system partition for computers that use the Extensible Firmware Interface (EFI). In such cases, the GPT partitioning scheme is used and the actual partition type for the system partition can also be specified as "!c12a7328-f81f-11d2-ba4b-00a0c93ec93b". freebsd A FreeBSD partition subdivided into filesystems with a BSD disklabel. This is a legacy partition type and should not be used for the APM or GPT schemes. The scheme-specific types are "!165" for MBR, "!FreeBSD" for APM, and "!516e7cb4-6ecf-11d6-8ff8-00022d09712b" for GPT. freebsd-boot A FreeBSD partition dedicated to bootstrap code. The scheme-specific type is "!83bd6b9d-7f41-11dc-be0b-001560b84f0f" for GPT. freebsd-swap A FreeBSD partition dedicated to swap space. The scheme-specific types are "!FreeBSD-swap" for APM, "!516e7cb5-6ecf-11d6-8ff8-00022d09712b" for GPT, and tag 0x0901 for VTOC8. freebsd-ufs A FreeBSD partition that contains a UFS or UFS2 filesystem. The scheme-specific types are "!FreeBSD-UFS" for APM, "!516e7cb6-6ecf-11d6-8ff8-00022d09712b" for GPT, and tag 0x0902 for VTOC8. freebsd-vinum A FreeBSD partition that contains a Vinum volume. The scheme-specific types are "!FreeBSD-Vinum" for APM, "!516e7cb8-6ecf-11d6-8ff8-00022d09712b" for GPT, and tag 0x0903 for VTOC8. freebsd-zfs A FreeBSD partition that contains a ZFS volume. The scheme-specific types are "!FreeBSD-ZFS" for APM, "!516e7cba-6ecf-11d6-8ff8-00022d09712b" for GPT, and 0x0904 for VTOC8.