💾 Archived View for thebackupbox.net › ~epoch › blog › nbd captured on 2024-12-17 at 10:12:49. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-07-09)

-=-=-=-=-=-=-

network block device

https://nbd.sourceforge.io/

used nbd to add swapspace to my pi over a network

on desktop with lots of space:

xnbd-server --target --lport 12345 one_gig.swap

on raspi:

modprobe nbd
xnbd-client --connect /dev/nbd0 21.41.41.5 12345
swapon /dev/nbd0

update 2022-08-05

A while ago I made a partition on my file server server encrypted.

Since I didn't want anyone that could get into the NFS server to see what the data was, I export the partition using nbd instead of over nfs.

so, on my server I have nbd-server installed, and this config file in /etc/nbd-server/config

[generic]
	user = nbd
	group = disk
	includedir = /etc/nbd-server/conf.d
[crypto]
	exportname = /dev/sdb1

I have it using group disk instead of the group nbd so that it has read access to disks

without me having to change the group owner of the device file.

You may want to change exportname to be a device based on uuid like:

/dev/disk/by-uuid/90fb27b2-c33e-4389-9abe-a2698e778479

You can ls -l that dir to see what each uuid points to.

I don't remember exactly how I did this, but I'm pretty sure it was something like:

cryptsetup luksFormat /dev/nbd0
cryptsetup open /dev/nbd0 derp
mkfs -t ext4 /dev/mapper/derp

on desktop computer to mount:

#!/usr/bin/env bash
set -e
modprobe nbd
nbd-client -name crypto 21.41.41.5
cryptsetup open /dev/nbd0 derp
mount /dev/mapper/derp /mnt/net/derp/
echo "MOUNTED TO /mnt/net/derp"

and to dismount:

#!/usr/bin/env bash
set -e
umount /dev/mapper/derp
cryptsetup close derp
nbd-client -d /dev/nbd0
echo "UMOUNTED /mnt/net/derp"