# Partition Editor - add swap



## weberjn (Feb 27, 2022)

I am playing with FreeBSD-13.0-RELEASE-arm64-aarch64-RPI.img.xz
on a Raspberry 3B.
I was pleasantly surprised, it booted without display attached, appeared in the network and had resized its partition. It recognized even my usb network stick (rgephy0: <RTL8169S/8110S/8211 1000BASE-T media interface> PHY 3 on miibus1). So I can build a bridge.

Then I wanted to add a swap partion (why doesn't the image contain one?). 
To practice, I flashed the system onto a second micro sd and put it into a reader attached to the Raspberry.
Idea is to add a partition to the end of free space, then boot and have the BSD partition expand to full space, or run growfs manually.






Now it only says "Invalid argument".
How can I add a swap partition to the end?

I'd rather stay with Partition Editor and not have to dig into chapter 18 of the manual and gpart, till now I could shirk the cylinders and datasets of MVS ;-)


----------



## eternal_noob (Feb 27, 2022)

weberjn said:


> why doesn't the image contain one?


Because swapping wears out the SD card. I wouldn't use swap on an SD card.


----------



## weberjn (Feb 27, 2022)

eternal_noob said:


> Because swapping wears out the SD card. I wouldn't use swap on an SD card.


Fair argument. But I rather want to use swap in rare cases than have a process killed.


----------



## covacat (Feb 27, 2022)

create it as ufs  (i don't think that a mbr / freebsd swap type exists)
also i second the no swap on the sd
i have a zero with no swap and i even built gcc on it without problems


----------



## weberjn (Feb 27, 2022)

OK, so I just also have written the image onto an SSD for a pi4. Same, how would I add a swap partition? 

With 120Gb for 17 Euros an SSD is an easy option (ok, plus 10 for the sata to usb adapter).


----------



## Menelkir (Feb 27, 2022)

weberjn said:


> Fair argument. But I rather want to use swap in rare cases than have a process killed.


ARM will have less chances of this occurs, in any case, I think is more safe (and cheaper) to use some kind of throw-away pendrive for swap.


----------



## grahamperrin@ (Feb 28, 2022)

covacat said:


> (i don't think that a mbr / freebsd swap type exists)



In the example below, `gpart add -t freebsd-swap da4s1`


```
root@mowa219-gjp4-8570p-freebsd:~ # gdisk /dev/da4
GPT fdisk (gdisk) version 1.0.8

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************

Warning! Main partition table overlaps the first partition by 2 blocks!
Try reducing the partition table size by 8 entries.
(Use the 's' item on the experts' menu.)

Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.

Command (? for help): x

Expert command (? for help): z
About to wipe out GPT on /dev/da4. Proceed? (Y/N): y
Warning: The kernel may continue to use old or deleted partitions.
You should reboot or remove the drive.
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
Blank out MBR? (Y/N): y
root@mowa219-gjp4-8570p-freebsd:~ # gpart create -s MBR da4
da4 created
root@mowa219-gjp4-8570p-freebsd:~ # gpart add -t freebsd da4
da4s1 added
root@mowa219-gjp4-8570p-freebsd:~ # gpart create -s BSD da4s1
da4s1 created
root@mowa219-gjp4-8570p-freebsd:~ # gpart add -t freebsd-swap da4s1
da4s1a added
root@mowa219-gjp4-8570p-freebsd:~ # lsblk da4
DEVICE         MAJ:MIN SIZE TYPE                                          LABEL MOUNT
da4              2:94  965M MBR                                               - -
  da4s1          0:162 965M BSD                                               - -
    da4s1a       0:164 965M freebsd-swap                                      - -
root@mowa219-gjp4-8570p-freebsd:~ # gpart destroy -F da4
da4 destroyed
root@mowa219-gjp4-8570p-freebsd:~ # gpart create -s MBR da4
da4 created
root@mowa219-gjp4-8570p-freebsd:~ # gpart add -t freebsd da4
da4s1 added
root@mowa219-gjp4-8570p-freebsd:~ # gpart create -s BSD da4s1
gpart: geom 'da4s1': File exists
root@mowa219-gjp4-8570p-freebsd:~ #
```


----------

