# Use partition created with gpart with no label in fstab



## i.am.the.problem (Jul 21, 2022)

Hi,

If I've partitioned my drive using the following commands


```
gpart add -s 512K -t freebsd-boot da0
gpart add -s 10G -t freebsd-swap da0
gpart add -t freebsd-zfs da0
```

Can I add the second partition as swap in fstab without it having a label?


----------



## i.am.the.problem (Jul 21, 2022)

```
/dev/da0p2 none                    swap    sw              0       0
```

Seems to work OK.


----------



## wb7odyfred (Jul 23, 2022)

Yes, you can add second partition as swap in fstab without if having a label.  The beauty in using a file system label or the glabel command.  Is when you add a new disk to your system and what was da0, becomes da2 or da5, because of cable changes or BIOS disk recogition order.   Your file /etc/fstab now with old data confuses booting with your new disks installed.

Some of these  label names are carried over from the 'file label' name and not the given 'glabel' name in the listings above.
https://www.ithands-on.com/2020/10/freebsd-101-disk-labels.html * BEST WEB PAGE about glabel*

https://people.freebsd.org/~trhodes/doc/handbook/geom-glabel.html

https://people.freebsd.org/~rodrigc/doc/handbook/geom-glabel.html

https://flylib.com/books/en/3.326.1.183/1/

Use a GPT /dev/diskid  name to select the "drive"  not /dev/da1p2​sudo glabel  label -v  swap_unirex_244g /dev/diskid/DISK-333457EBD0F2p3
Metadata value stored on /dev/diskid/DISK-333457EBD0F2p3.
Done.
sudo swapctl -A
swapctl: adding /dev/gpt/swap-unirex-224 as swap device

cat /etc/fstab
# Device        Mountpoint        FStype        OptionsDump Pass
# diskid/DISK-333457EBD0F2p3  801fd8c2-7926-11ec-b6e6-0021ccd45dec
# /dev/gptid/801fd8c2-7926-11ec-b6e6-0021ccd45dec
# /dev/label/swap0    none        swap    sw    0    0

# /dev/label/swap-unirex-224 none           swap         sw        0      0
/dev/gpt/swap-unirex-224     none           swap         sw        0      0

procfs            /proc            procfs        rw    00
linprocfs        /compat/linux/proc    linprocfs    rw    00
tmpfs /compat/linux/dev/shm tmpfs rw,mode=1777 0 0
linsysfs /compat/linux/sys linsysfs rw 0 0
fdesc /dev/fd fdescfs rw 0 0

*I get confused about which label goes with which partition.  So here are commands to use for finding information.
*
gpart status
gpart show
gpart show -l
gpart list
glabel list

See what labels exist in which directories:
ls -l  /dev/gpt /dev/gptid  /dev/diskid /dev/label   


Only when a partition is * unmounted  *can you assign a label with glabel command
glabel  label -v rootfs_unirex_244g   /dev/diskid/DISK-333457EBD0F2p2

So the answer is to  Glabel your GPT UUID external USB 3.0 SSD drive,   Next use that as the first or 2nd line in the /etc/fstab file to name your SWAP Partition
/dev/label/swap-unirex-224  none           swap         sw            0      0
/dev/gpt/swap-unirex-224     none           swap         sw        0      0


swapon -aL   to  turn the swap on for all swap partitions listed in the file /etc/fstab

swapinfo  -m    will tell you how much of your swap space is used in megabytes.


----------

