diff options
author | mms <michal@sapka.me> | 2024-10-01 20:44:28 +0200 |
---|---|---|
committer | mms <michal@sapka.me> | 2024-10-01 20:44:28 +0200 |
commit | 3a8a9e80bd6991f2281dfd5a50e6234efb0ab289 (patch) | |
tree | 048428c7819f7f9ae59da3a8299af153980a22e1 /content/blog | |
parent | 8897329715d0357c293d710158a4473ef7bc30c0 (diff) |
feat: star trek extracted
Diffstat (limited to 'content/blog')
-rw-r--r-- | content/blog/2024/Crys-Vm.md | 124 | ||||
-rw-r--r-- | content/blog/2024/notes-on-star-trek.md | 23 |
2 files changed, 147 insertions, 0 deletions
diff --git a/content/blog/2024/Crys-Vm.md b/content/blog/2024/Crys-Vm.md new file mode 100644 index 0000000..2c4d250 --- /dev/null +++ b/content/blog/2024/Crys-Vm.md @@ -0,0 +1,124 @@ ++++ +title = "My server is now a virtual machine" +author = ["Michał Sapka"] +date = 2024-09-26T21:29:00+02:00 +categories = ["blog"] +draft = false +weight = 2002 +image_dir = "blog/images" +image_max_width = 600 +Abstract = "Memoir From A Forced Migation" +Listening = "Steve Kirk - Thimbleweed Park (Original Soundtrack)" +Listening_url = "https://Thimbleweedpark.Bandcamp.Com/Album/Thimbleweed-Park-Original-Soundtrack" +Listening_img = "Steve-Kirk-Thimbleweed-Park.Jpg" ++++ + +The unthinkable has happened - and by that, I mean it was a matter of time, but I wasn't expecting a week. +The SD card used in Raspberry Pi behind [crys.site](https://crys.site) got corrupted beyond fixing. +I tried, tried (I gave it good 30 mins) and failed. +Super block was borked, fixing the filesystem was impossible. + +But I will not let go of my FreeBSD server! +_Beastie or Bust!_. +I have this quite modern Synology, so why not use it? +The UI is not for me, but I can set up a virtual machine there and boom - everything will be all right with the world. +On the host FreeBSD all I had to do was: + +- enable sshd(8) +- install doas(1) + +And add a bridge to the network, which will be used by the jails: + +```shell +# /etc/rc.conf + +cloned_interfaces="bridge0" +ifconfig_bridge0="addm em0 up" +kld_list="if_bridge if_epair" +``` + +The SD card used UFS (default image for FreeBSD on Raspberry), so I lost it. +But all my data, the sites and jails were stored on external thumb drive in a ZFS pool. +This made the transition incredibly fast. +First, I had to create a recursive (`-r`) snapshot of the root dataset. +I found naming it `fun` funny. + +```shell +zfs snapsot -r extdata@fin +``` + +And I was able to transfer all descendant datasets to to the new machine + +```shell +zfs send -R extdata/jail@fin | ssh 10.0.7.0 zfs recv zroot/jail +``` + +Oh ZFS, we don't deserve you. + +Then I recreated my jail.conf[^fn:1] with DHCP VNET: + +```shell +# STARTUP/LOGGING +exec.clean; +exec.start = "/bin/sh /etc/rc"; +exec.stop = "/bin/sh /etc/rc.shutdown"; +exec.consolelog = "/var/log/jail_console_${name}.log"; + +# PERMISSIONS +allow.raw_sockets; +exec.clean; +mount.devfs; +devfs_ruleset = 5; +vnet; +allow.raw_sockets = 1; + +host.hostname = "${name}.dune.local"; +path = "/usr/local/jails/containers/${name}"; +$epair = "epair${id}"; +$bridge = "bridge0"; +vnet.interface = "${epair}b"; + +exec.start += "dhclient ${epair}b"; +exec.prestart = "/sbin/ifconfig ${epair} create up"; +exec.prestart += "/sbin/ifconfig ${epair}a up descr jail:${name}"; +exec.prestart += "/sbin/ifconfig ${bridge} addm ${epair}a up"; + +exec.poststop = "/sbin/ifconfig ${bridge} deletem ${epair}a"; +exec.poststop += "/sbin/ifconfig ${epair}a destroy"; + +nginx { + $id=1; +} + +sites { + $id=10; +} +``` + +and... nothing. +Nada. +The jails won't start. + +Raspberry Pi is ARM, my VM is x86. +I had to create new jails - which is a breeze thanks to, again, ZFS. +Since jails are normal directories, I was able to simply copy configs to new jails. +In all, this forced migration took 2 hours. +And that includes downloading data. + +Emacs made it very easy, since I can use `tramp` with `doas` to edit remote files as root: + +```shell +/sshx:mms@10.0.7.0|doas:: +``` + +The last missing puzzle was strange change from RPI, as jail's Mac addresses started changing after each start. +Luckily, BSD is a community so [meka](https://bsd.network/@meka) provided me with config to force Mac address for jail, and I've added: + +```shell +exec.prestart += "/sbin/ifconfig ${epair}b ether ${mac}"; +``` + +Truly, FreeBSD is a gift that keeps on giving. + +[^fn:1]: This config is a combination of what [Ruben](https://rubenerd.com/starting-with-freebsd-jails/), [FreeBSD Guides](https://docs.freebsd.org/en/books/handbook/jails/), and [FreeBSD Wiki](https://wiki.freebsd.org/Jails) has thought me. + I'll need to step up and buy [Jail Mastery](https://mwl.io/nonfiction/os#fmjail) book from MWL sometime in the near future. diff --git a/content/blog/2024/notes-on-star-trek.md b/content/blog/2024/notes-on-star-trek.md new file mode 100644 index 0000000..5080dcf --- /dev/null +++ b/content/blog/2024/notes-on-star-trek.md @@ -0,0 +1,23 @@ ++++ +title = "Notes on Star Trek" +author = ["Michał Sapka"] +date = 2024-10-01T20:39:00+02:00 +categories = ["blog"] +draft = false +weight = 2001 +image_dir = "blog/images" +image_max_width = 600 +Abstract = "Star Trek now on crys!" +Listening = "Jazz Sabbath - Jazz Sabbath" +Listening_url = "https://jazzsabbath.bandcamp.com/album/jazz-sabbath" +Listening_img = "Steve-Kirk-Thimbleweed-Park.Jpg" ++++ + +And another one bites the... well, nope. +My Star Trek site is became a [site with notes on Star Trek](https://startrek.crys.site/voy/index.html). +It's amazing what you can do with HTML and CSS alone. +A single evening and a complete, nice looking site is born. +Having simplicity as a goal didn't make it any harder, but it made it much more fun! +Just to think, that the initial version of my blog was a NextJS monstrosity. + +This leaves me with this blog alone left to migrate. |