# Install FreeBSD on a flash drive?



## marcelesperante (Sep 6, 2018)

Is it possible to install FreeBSD on a flash drive or memory stick and use them as an HD?


----------



## Beastie (Sep 7, 2018)

Hello and welcome to the forums.



marcelesperante said:


> Is it possible to install FreeBSD on a flash drive or memory stick and use them as an HD?


Yes. Instead of installing to something like ada0, you install to something like da0.
The most significant difference is that USB devices are much slower.
Mounting /tmp on tmpfs(5) is highly recommended for such setup.


----------



## SirDice (Sep 11, 2018)

marcelesperante said:


> Is it possible to install FreeBSD on a flash drive or memory stick and use them as an HD?


All are treated as regular disks and can therefor be used to install onto. One thing to note though, flash drives or memory sticks tend to "move around" depending on other sticks being inserted. So it can show up as da0, da1, da2, etc. In order to make sure it always works, regardless of the actual device name, make sure to use labels instead of referring to disks. 

http://www.wonkity.com/~wblock/docs/html/labels.html


----------



## gkontos (Sep 11, 2018)

My home NAS is set up to boot from a usb thumb drive. One thing I recommend is to disable daily/weekly periodic scripts that tend to use excessive I/O for usb thumb drives.


----------



## mefizto (Sep 12, 2018)

Hi gkontos,

how do you deal with log files?

Kindest regards,

M


----------



## SirDice (Sep 12, 2018)

You could send them to a remote syslog server. Or log to a mdmfs(8) or tmpfs(5) filesystem, but you'll lose the logs when you reboot.


----------



## mefizto (Sep 12, 2018)

Hi SirDice,

examining hier(7), it appears that all(?) the log files are in /var/log.   Is this correct?  If so, how does on practically accomplish logging to a different location, _i.e.,_ a different drive on the same machine or a specific location on a different machine?

Kindest regards,

M


----------



## SirDice (Sep 12, 2018)

mefizto said:


> examining hier(7), it appears that all(?) the log files are in /var/log. Is this correct?


Most applications will, yes. Notable exception is perhaps MySQL/MariaDB as that typically logs to /var/db/mysql/$(hostname).err. 


mefizto said:


> If so, how does on practically accomplish logging to a different location, _i.e.,_ a different drive on the same machine


You can mount a filesystem from a different drive on /var/log, that's the easiest way to do. 



mefizto said:


> or a specific location on a different machine?


Typically only works for syslog(8) messages (not everything in /var/log/ is from syslog(8)):

```
o   A hostname (preceded by an at ("@") sign).  Selected messages are
         forwarded to the syslogd(8) program on the named host.  If a port
         number is added after a colon (`:') then that port will be used as
         the destination port rather than the usual syslog port.  IPv6
         addresses can be used by surrounding the address portion with square
         brackets (`[' and `]').
```
See syslog.conf(5).


----------



## mefizto (Sep 12, 2018)

Hi SirDice,

thank you very much for the detailed answer.  I actually have been running a server with the OS on a USB flash drive with all unnecessary writing - except logs - disabled for a few years without problems and storing data on hard drive(s).  However, the logs writing has been still worrying me.

What would be the advantages/disadvantages to mounting filesystem from a different drive on /var/log _vs._ moving the /var/log onto a different drive?

Kinds regards,

M


----------



## SirDice (Sep 12, 2018)

mefizto said:


> What would be the advantages/disadvantages to mounting filesystem from a different drive on /var/log _vs._ moving the /var/log onto a different drive?


Both are the same? I mean, if you mount a filesystem from a different drive on /var/log/ you've effectively moved /var/log to another drive.

Advantages, spinning rust disks typically have a lot more capacity than thumb drives. They're probably also a bit faster compared to the relatively slow write speeds of thumb drives (depends on the thumb drive though). 

Disadvantage, the only thing I could think of is more complexity. It takes a little bit more effort to set up.


----------



## mefizto (Sep 12, 2018)

Hi SirDice,

thank you. All clear now.

Kindest regard,

M


----------

