OPNsense Forum

Archive => 19.7 Legacy Series => Topic started by: nemric on August 13, 2019, 07:04:05 pm

Title: move /tmp and /var to USB key
Post by: nemric on August 13, 2019, 07:04:05 pm
Hi,

I tri to setup /var and /tmp to an USB key formatted as

Code: [Select]
root@xxx:/etc # gpart show da0
=>     40  7866288  da0  GPT  (3.8G)
       40  4194304    1  freebsd-ufs  (2.0G)
  4194344  3671984    2  freebsd-ufs  (1.8G)

My fstab looks like :

Code: [Select]
root@xxx:/etc # cat /etc/fstab
# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/ufs/OPNsense       /               ufs     rw,noatime      1       1
/dev/da0p1              /var            tmpfs   rw              2       2
/dev/da0p2              /tmp            tmpfs   rw              2       2

Code: [Select]
root@xxx:/tmp # df -a -H
Filesystem           Size    Used   Avail Capacity  Mounted on
/dev/ufs/OPNsense    2.0G    1.0G    837M    55%    /
devfs                1.0k    1.0k      0B   100%    /dev
tmpfs                1.8G     24M    1.8G     1%    /var
tmpfs                1.8G    184k    1.8G     0%    /tmp
devfs                1.0k    1.0k      0B   100%    /var/dhcpd/dev
devfs                1.0k    1.0k      0B   100%    /var/unbound/dev

Capacities in "df" are not same a defined in "gpart"

Is there a way to make it work ?
How to be sure that /tmp and /var are well mounted on /dev/da0p1 ans /dev/de0p2 ?

thanks :)
Title: Re: move /tmp and /var to USB key
Post by: Alphabet Soup on August 14, 2019, 07:44:20 am
Not sure what else might be required, but your fstab is still declaring the file systems for /tmp and /var as 'tmpfs' instead of 'ufs'.  You've shown your USB key partitions are formatted ufs.  tmpfs is for in-memory filesystems.

And if this USB key is just flash memory, you may also want to include the 'noatime' option on those partitions to cut down on the number of writes.
Title: Re: move /tmp and /var to USB key
Post by: nemric on August 15, 2019, 02:05:27 pm
Thanks a lot for your answer Alphabet Soup :)

This solution (having /tmp and /var on usb key) isn't a good idea at all !

I did it because the update from 19.1 to 19.7 failed because of memory size ...

Having these "drives" on USB key slow down opnsense a lot and I finally decide to keep /var on MFS and /tmp on full 4GB usb key size expecting that updates uses /tmp for download and/or unpacking update files.

USB key is now freebsd-ufs ...

Last question : Is tmpfs file system make it backuped on CF (ada0) or is this done every time ?
Title: Re: move /tmp and /var to USB key
Post by: Alphabet Soup on August 17, 2019, 03:03:16 am
The tmpfs driver is only an in-memory filesystem, i.e. RAM disk.  If RAM gets low the kernel *may* write out parts of your RAM disk to the swap file (if you have one), but nobody would consider that a "backup".

The md (memory disk) driver provides RAM disks with tmpfs, but also other options like swap-backed or file-backed.  While you could use md to have a RAM disk backed up to a USB key, I don't think that would help your situation.

https://www.freebsd.org/doc/handbook/disks-virtual.html