# activate swap on raspberry PI2



## philo_neo (Aug 21, 2016)

Hi,
I'm enjoy when I read that there are an distribution of FreeBSD on Raspberry PI2 with HDMI,
I've installed system but now I should to install GNOME3, and what's happening there a out of memory, of course there is no swap!
1/ `fdisk`

```
root@rpi2:~ # fdisk
******* Working on device /dev/mmcsd0 *******
parameters extracted from in-core disklabel are:
cylinders=3880 heads=255 sectors/track=63 (16065 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=3880 heads=255 sectors/track=63 (16065 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 12 (0x0c),(DOS or Windows 95 with 32 bit FAT (LBA))
  start 63, size 102375 (49 Meg), flag 80 (active)
   beg: cyl 0/ head 1/ sector 1;
   end: cyl 6/ head 95/ sector 63
The data for partition 2 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
  start 102438, size 62230490 (30385 Meg), flag 0
   beg: cyl 6/ head 96/ sector 1;
   end: cyl 1023/ head 255/ sector 63
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>
root@rpi2:~ #
```

2/ I do :
`dd if=/dev/zero bs=1m count=2048 of=/memory/swap`

3/ `gpart`


```
root@rpi2:~ # [CMD]gpart show [/CMD]
=>  63  62333889  mmcsd0  MBR  (30G)
  63  102375  1  !12  [active]  (50M)
  102438  62230490  2  freebsd  (30G)
  62332928  1024  - free -  (512K)

=>  0  62230490  mmcsd0s2  BSD  (30G)
  0  90  - free -  (45K)
  90  62230400  1  freebsd-ufs  (30G)
```

4/ `swapinfo`


```
root@rpi2:~ # swapinfo
Device  1K-blocks  Used  Avail Capacity
root@rpi2:~ #
```

5/ `swapon -a`


```
root@rpi2:~ # swapon -a
fstab: /etc/fstab:6: Inappropriate file type or format
root@rpi2:~ #
```
6/ /etc/fstab

```
/dev/mmcsd0s1  /boot/msdos  msdosfs rw,noatime  0 0
/dev/mmcsd0s2a  /  ufs rw,noatime  1 1
md  /tmp  mfs rw,noatime,-s50m  0 0
md  /var/log  mfs rw,noatime,-s15m  0 0
md  /var/tmp  mfs rw,noatime,-s10m  0 0
md  /memory/swap  mfs  swap  sw  0 0
```
I think that at near the solution just I don't format fine, and issue to file /etc/fstab.

Regards
Philippe


----------



## tobik@ (Aug 21, 2016)

See fstab(5) in the EXAMPLES section:

```
md            none            swap    sw,file=/memory/swap       0 0
```


----------



## philo_neo (Aug 21, 2016)

tobik said:


> See fstab(5) in the EXAMPLES section:
> 
> ```
> md            none            swap    sw,file=/memory/swap       0 0
> ```


I do it and i don't see the swap memory used and free with the command `top` into the VT320.

May be i deceive for this issue !

this my output :


```
so.1\" -DSHLIB_PREFIX=\"lib\" -DSHLIB_VERSION=\"3\" -DSOFTOKEN_SHLIB_VERSION=\"3\" -DRIJNDAEL_INCLUDE_TABLES -UDEBUG -DNDEBUG -D_THREAD_SAFE -D_REENTRANT -DNSS_NO_INIT_SUPPORT -DUSE_UTIL_DIRECTLY -DNO_NSPR_10_SUPPORT -DSSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES -DFREEBL_LOWHASH -DMP_API_COMPATIBLE -I../../../dist/FreeBSD11.0_OPT.OBJ/include -I../../../dist/public/nss -I../../../dist/private/nss -Impi -Iecl  pqg.c
pqg.c:345:16: error: comparison of constant 18446744073709551615 with expression
  of type 'unsigned long' is always true
  [-Werror,-Wtautological-constant-out-of-range-compare]
  if (addend < MP_DIGIT_MAX) {
  ~~~~~~ ^ ~~~~~~~~~~~~
1 error generated.
gmake[17]: *** [../../coreconf/rules.mk:392: FreeBSD11.0_OPT.OBJ/FreeBSD_SINGLE_SHLIB/pqg.o] Error 1
gmake[17]: Leaving directory '/usr/ports/security/nss/work/nss-3.26/nss/lib/freebl'
gmake[16]: *** [Makefile:626: libs] Error 2
gmake[16]: Leaving directory '/usr/ports/security/nss/work/nss-3.26/nss/lib/freebl'
gmake[15]: *** [../coreconf/rules.mk:104: libs] Error 2
gmake[15]: Leaving directory '/usr/ports/security/nss/work/nss-3.26/nss/lib'
gmake[14]: *** [coreconf/rules.mk:104: libs] Error 2
gmake[14]: Leaving directory '/usr/ports/security/nss/work/nss-3.26/nss'
*** Error code 1

Stop.
make[13]: stopped in /usr/ports/security/nss
*** Error code 1

Stop.
```


----------



## tobik@ (Aug 21, 2016)

See PR 209482


----------



## Murph (Aug 21, 2016)

N.B. swap on flash is potentially a good way to kill the flash through its maximum write cycle count (SSDs with TRIM are a partial exception to that, although do still suffer from the same problem).


----------



## philo_neo (Aug 25, 2016)

I work into the directory /usr/ports/security/nss
this is the issue :


```
pqg.c:345:16: error: comparison of constant 18446744073709551615 with expression
  of type 'unsigned long' is always true
  [-Werror,-Wtautological-constant-out-of-range-compare]
```
I've deactivate swap, `make MAKE_JOBS_UNSAFE=yes reinstall`

I don't understand poudriere because the link is with `DISABLE_MAKE_JOBS=poudriere`

How I can deactivate: 'unsigned long'?


----------



## cpm@ (Aug 25, 2016)

Again see PR 209482.

The attached patch fixes the issue.


----------



## philo_neo (Aug 26, 2016)

Sorry, I don't understand!

Is this the patch?

```
Index: files/patch-coreconf_FreeBSD.mk
===================================================================
--- files/patch-coreconf_FreeBSD.mk    (revision 413103)
+++ files/patch-coreconf_FreeBSD.mk    (working copy)
@@ -13,7 +13,7 @@
  RANLIB            = ranlib

  CPU_ARCH        = $(OS_TEST)
-@@ -52,6 +52,13 @@ endif
+@@ -52,6 +52,16 @@ endif
  ifeq ($(CPU_ARCH),amd64)
  CPU_ARCH        = x86_64
  endif
@@ -20,6 +20,9 @@
+ifneq (,$(filter powerpc%, $(CPU_ARCH)))
+CPU_ARCH        = ppc
+endif
++ifeq ($(CPU_ARCH),armv6)
++CPU_ARCH              = arm
++endif
+
+ifneq (,$(filter %64, $(OS_TEST)))
+USE_64            = 1
```

but where is the file, I  must copy this code, for example the file 'mk.conf', I don't know?


----------



## acheron (Aug 26, 2016)

```
cd /usr/ports/security/nss
fetch -o nss.patch 'https://bz-attachments.freebsd.org/attachment.cgi?id=170244'
patch < nss.patch
```


----------



## philo_neo (Aug 26, 2016)

I did your recommendation, but I still have the same issue.


----------



## acheron (Aug 26, 2016)

Have you done a `make clean` before?

```
cd /usr/ports/security/nss
make clean;make
```


----------

