Thicket data repository for the EEG
1{
2 "id": "https://www.tunbury.org/2021/06/22/syncthing-on-openbsd",
3 "title": "Syncthing on OpenBSD",
4 "link": "https://www.tunbury.org/2021/06/22/syncthing-on-openbsd/",
5 "updated": "2021-06-22T19:41:29",
6 "published": "2021-06-22T19:41:29",
7 "summary": "Network Installation of OpenBSD",
8 "content": "<h2>Network Installation of OpenBSD</h2>\n\n<p>Setup a machine to facilitate network installation of OpenBSD. Download the 6.9 installation ISO from the <a href=\"https://www.openbsd.org/faq/faq4.html#Download\">OpenBSD website</a> and install it in a virtual machine. I’m using VMware Fusion and have a dedicated LAN port connected to the remote machine.</p>\n\n<p>Create <code>hostname.vic0</code> containing the following and not <code>dhcp</code>:</p>\n\n<div><div><pre><code>inet 192.168.2.1 255.255.255.0 NONE\n</code></pre></div></div>\n\n<h3>DHCPD</h3>\n\n<p>Create <code>/etc/dhcpd.conf</code> with the key attributes:</p>\n\n<ul>\n <li><code>filename</code> for the boot image name, and</li>\n <li><code>next-server</code> for the TFTP server address.</li>\n</ul>\n\n<p>I have added a host section for the specific MAC of my machine but for this one-time build process it could be a global option.</p>\n\n<div><div><pre><code>subnet 192.168.2.0 netmask 255.255.255.0 {\n option routers 192.168.2.1;\n range 192.168.2.32 192.168.2.127;\n \n host mini-itx {\n hardware ethernet 00:40:63:d5:6f:4f;\n filename \"auto_install\";\n next-server 192.168.2.1;\n option host-name \"mini-itx\"\n }\n}\n</code></pre></div></div>\n\n<h3>TFTPD</h3>\n\n<p>Create the default TFTP root folder and configuration folder</p>\n\n<div><div><pre><code>mkdir -p /tftpboot/etc\n</code></pre></div></div>\n\n<p>Download <a href=\"http://ftp.openbsd.org/pub/OpenBSD/6.9/i386/pxeboot\">pxeboot</a> and <a href=\"http://ftp.openbsd.org/pub/OpenBSD/6.9/i386/bsd.rd\">bsd.rd</a> and put them in <code>/tftpboot</code>.</p>\n\n<p>Create a symbolic link for <code>auto_install</code></p>\n\n<div><div><pre><code>ln -s pxeboot /tftpboot/auto_install\n</code></pre></div></div>\n\n<p>Create <code>/tftpboot/etc/boot.conf</code> containing the following</p>\n\n<div><div><pre><code>boot tftp:/bsd.rd\n</code></pre></div></div>\n\n<h3>HTTPD</h3>\n\n<p>Create <code>/etc/httpd.conf</code> to share the folder <code>/var/www/htdocs</code></p>\n\n<div><div><pre><code>#[ MACROS ]\next_ip = \"*\"\n\n# [ GLOBAL CONFIGURATION ]\n# none\n\n# [ SERVERS ]\nserver \"default\" {\n listen on $ext_ip port 80\n root \"/htdocs\"\n}\n\n# [ TYPES ]\ntypes {\n include \"/usr/share/misc/mime.types\"\n}\n</code></pre></div></div>\n\n<p>Stage the installation files on a local web server by copying them from the boot ISO downloaded at the start:</p>\n\n<div><div><pre><code>mount /dev/cd0a /mnt/\nmkdir -p /var/www/htdocs/pub/OpenBSD\ncp -rv /mnt/6.9/ /var/www/htdocs/pub/OpenBSD/6.9\nls -l /var/www/htdocs/pub/OpenBSD/6.9 > /var/www/htdocs/pub/OpenBSD/6.9/index.txt\n</code></pre></div></div>\n\n<p>Create <code>/var/www/htdocs/install.conf</code> containing the following automatic confgiuration answer file</p>\n\n<div><div><pre><code>Password for root = Password\nSetup a user = user\nPassword for user = Password\nPublic ssh key for user = ssh-rsa AAAA...ZV user@Marks-Mac-mini.local\nWhich disk is the root disk = wd0\nWhat timezone are you in = Europe/London\nUnable to connect using https. Use http instead = yes\nLocation of sets = http\nHTTP Server = 192.168.2.1\nSet name(s) = -all bsd* base* etc* man* site* comp*\nContinue without verification = yes\n</code></pre></div></div>\n\n<p>Enable the services using <code>rcctl</code> which edits configuration file <code>rc.conf.local</code> add the appropriate <code>service_flags=\"\"</code> lines</p>\n\n<div><div><pre><code>rcctl enable dhcpd\nrcctl enable tftpd\nrcctl enable httpd\n</code></pre></div></div>\n\n<p>The remote system should now boot from the network and install OpenBSD hands free!</p>\n\n<p>After the new system boots <code>su</code> and then overwrite <code>/etc/installurl</code> with a standard value</p>\n\n<div><div><pre><code>echo https://ftp.openbsd.org/pub/OpenBSD > /etc/installurl\n</code></pre></div></div>\n\n<h2>RAID5 Volume</h2>\n\n<p>Create a RAID5 volume over the four attached disks</p>\n\n<div><div><pre><code>for a in sd0 sd1 sd2 sd3 ; do fdisk -iy $a ; done\nfor a in sd0 sd1 sd2 sd3 ; do printf \"a\\n\\n\\n\\nRAID\\nw\\nq\\n\" | disklabel -E $a ; done\nbioctl -c 5 -l /dev/sd0a,/dev/sd1a,/dev/sd2a,/dev/sd3a softraid0\n</code></pre></div></div>\n\n<p>Partition and format the volume</p>\n\n<div><div><pre><code>fdisk -iy sd4\nprintf \"a\\n\\n\\n\\n4.2BSD\\nw\\nq\\n\" | disklabel -E sd4\nnewfs /dev/rsd4a \n</code></pre></div></div>\n\n<h2>Syncthing</h2>\n\n<p>Install <code>syncthing</code> using</p>\n\n<div><div><pre><code>pkg_add syncthing\n</code></pre></div></div>\n\n<p>Edit <code>/etc/login.conf</code> and append:</p>\n\n<div><div><pre><code>syncthing:\\\n :openfiles-max=60000:\\ \n :tc=daemon:\n</code></pre></div></div>\n\n<p>Rebuild the file</p>\n\n<div><div><pre><code>cap_mkdb /etc/login.conf\necho \"kern.maxfiles=80000\" >> /etc/sysctl.conf\n</code></pre></div></div>\n\n<p>Edit <code>/etc/rc.d/syncthing</code> and update the <code>daemon_flags</code>:</p>\n\n<div><div><pre><code>daemon_flags=\"-no-browser -gui-address=0.0.0.0:8384\"\n</code></pre></div></div>\n\n<p>Edit <code>/etc/fstab</code> to mount the drive</p>\n\n<div><div><pre><code>/dev/sd4a /var/syncthing ffs rw,softdep 0 0\nchown -R _syncthing:_syncthing /var/syncthing\n</code></pre></div></div>\n\n<p>Enable and start syncthing:</p>\n\n<div><div><pre><code>rcctl enable syncthing\nrcctl start syncthing\n</code></pre></div></div>",
9 "content_type": "html",
10 "author": {
11 "name": "Mark Elvers",
12 "email": "mark.elvers@tunbury.org",
13 "uri": null
14 },
15 "categories": [
16 "Syncthing",
17 "OpenBSD"
18 ],
19 "source": "https://www.tunbury.org/atom.xml"
20}