From 0ebc6fe7b14a7e03f75cc6e3290609a65c2fa283 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Tue, 21 Mar 2023 06:34:21 +0200 Subject: [PATCH] nfs --- README.md | 2 +- docs/msd.md | 83 +++++++++++++++++++++++++++++++++++------------------ 2 files changed, 56 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index ff3e2452..c58f6d78 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The website: [pikvm.org](https://pikvm.org). Also check out [the documentation]( * Supported **Raspberry Pi 2**, **3**, **4** and **Zero2W**; * **FullHD video** using advanced **HDMI-to-CSI bridge** or **USB dongle**; * Extra low **video latency** with **MJPEG** or **H.264 / WebRTC** (for CSI bridge); -* Bootable **Virtual CD-ROM** and **Flash Drive**; +* Bootable **Virtual CD-ROM** and **Flash Drive**, ability to store images on **NFS**; * USB **Keyboard** and **mouse** (with leds and the wheel), PS/2 keyboard, Bluetooth HID; * **Control the server power** using ATX functions; * Access via **Web UI** or **VNC**; diff --git a/docs/msd.md b/docs/msd.md index c83db10b..79f8c22f 100644 --- a/docs/msd.md +++ b/docs/msd.md @@ -17,23 +17,10 @@ There are some subtleties that you should know: The switch affects the settings of the future connection. For non-v3 devices, you need to either reboot your server or otherwise reinitialize the connection. -!!! warning "Advanced Linux knowledge is necessary for some advanced aspects that are not part of the normal use case. IE: making larger flash files will need a different file location and those instructions will need to be modified. The following instructions are for you to have something to start with." - ----- -## Disable MSD - -To disable mass storage emulation altogether, you can place the following piece of configuration into `/etc/kvmd/override.yaml`: - -``` yaml -kvmd: - msd: - type: disabled -``` - - ## Upload images manually (without Web UI) -!!! warning "This instruction is relevant for KVM >= 3.203. If you are using a previous version, then update OS." +!!! info "This instruction is relevant for KVM >= 3.203. If you are using a previous version, then update OS." 1. Remount internal storage to rw (read-write): @@ -57,6 +44,34 @@ kvmd: ``` +----- +## NFS storage + +!!! info "This instruction is relevant for KVM >= 3.206. If you are using a previous version, then update OS." + +It is possible to create a shared image storage for an entire fleet of PiKVMs using [NFS](https://en.wikipedia.org/wiki/Network_File_System). + +If you have some shares, you can easily connect them to PiKVM by creating mount points and adding relevant records to `/etc/fstab`. +At the same time, you will be able to upload images via PiKVM Web UI to NFS, and still use local storage. + +``` +# kvmd-helper-otgmsd-remount rw +# mkdir -p /var/lib/kvmd/msd/NFS_Primary +# mkdir -p /var/lib/kvmd/msd/NFS_Secondary +# kvmd-helper-otgmsd-remount ro +``` + +```fstab +server:/srv/nfs/NFS_Primary /var/lib/kvmd/msd/NFS_Primary nfs vers=3,timeo=1,retrans=1,soft 0 0 +server:/srv/nfs/NFS_Secondary /var/lib/kvmd/msd/NFS_Secondary nfs vers=3,timeo=1,retrans=1,soft 0 0 +``` + +Make sure that the `kvmd` user has read access rights from these directories. You can also give write access if needed. +For the best performance, it is required to ensure reliable connectivity with NFS server and use minimum `timeo` and `retrans` values. + +Configuring an NFS server is beyond the scope of this guide. + + ----- ## Multiple and writable drives @@ -91,7 +106,7 @@ to the server and download some files from to PiKVM from it. 3. Perform `reboot`. -### How to create RW flash drive +### How to create a second RW flash drive 1. Switch the root filesystem to `rw` mode: @@ -139,6 +154,18 @@ to the server and download some files from to PiKVM from it. 7. You can download the resulting image via SCP or mount it as a loop device on the PiKVM. +----- +## Disable MSD + +To disable mass storage emulation altogether, you can place the following piece of configuration into `/etc/kvmd/override.yaml`: + +``` yaml +kvmd: + msd: + type: disabled +``` + + ----- ## Create a Windows based Flash disk image @@ -236,7 +263,7 @@ You should be able to then mount it locally on the server, or reboot the device * There is an assumption that you know basic linux to understand that not all dev devices are named exactly like the below ``` -dd if=/dev/zero of=ventoy.img bs=1M count=4700 status=progress +# dd if=/dev/zero of=ventoy.img bs=1M count=4700 status=progress ``` * This makes a ventoy.img file, I would name this what it is EG: `ventoy_win10.img` @@ -246,14 +273,14 @@ dd if=/dev/zero of=ventoy.img bs=1M count=4700 status=progress * At the time of this, it was 1.0.51, change to latest version ``` -wget https://github.com/ventoy/Ventoy/releases/download/v1.0.51/ventoy-1.0.51-linux.tar.gz -tar zxvf ventoy-1.0.51-linux.tar.gz -sudo losetup -f ventoy.img -sudo losetup -l | grep ventoy (To locate which loop device was used) -sudo sh ~/ventoy-1.0.51/Ventoy2Disk.sh -i /dev/loopXX (This will make a loopXXp1 and a loopXXp2 and will format both partitions -cd /media/XXX (Usually your login) -mkdir ventoy -sudo mount /dev/loopXXp1 /media/XXX/ventoy +# wget https://github.com/ventoy/Ventoy/releases/download/v1.0.51/ventoy-1.0.51-linux.tar.gz +# tar zxvf ventoy-1.0.51-linux.tar.gz +# sudo losetup -f ventoy.img +# sudo losetup -l | grep ventoy (To locate which loop device was used) +# sudo sh ~/ventoy-1.0.51/Ventoy2Disk.sh -i /dev/loopXX (This will make a loopXXp1 and a loopXXp2 and will format both partitions +# cd /media/XXX (Usually your login) +# mkdir ventoy +# sudo mount /dev/loopXXp1 /media/XXX/ventoy ``` * Either cp/scp over the .iso you downloaded from the Media tool or use a NFS mount @@ -271,20 +298,20 @@ ssh into the Ubuntu system (Or whatever OS you are using) * On PiKVM ``` -cd /var/lib/kvmd/msd -mount -o remount,rw . +# cd /var/lib/kvmd/msd +# mount -o remount,rw . ``` * On Ubuntu ``` -scp ventoy.img root@pikvm:/var/lib/kvmd/msd +# scp ventoy.img root@pikvm:/var/lib/kvmd/msd ``` * On PiKVM ``` -touch /var/lib/kvmd/msd/.__ventoy.img.complete +# touch /var/lib/kvmd/msd/.__ventoy.img.complete ``` * Mount `ventoy.img` as normal flash and select the PiKVM boot device, it should popup with the VenToy logo with the window.iso as a selection