<style>
.reveal {
font-family: 'EB Garamond', serif;
}
</style>
# Lab #11: NFS #
## wp @ nasa2021 ##
---
## Updates after the recording ##
Q/A: <https://app.sli.do/event/5vdt0vwg/live/questions>
----
### 05-24 11:40 ###
Please get the basic image instead of the cloudimg one.
----
### 05-24 11:55 ###
If you are having trouble with VM IP addresses, please refer to <https://unix.stackexchange.com/a/419322>.
----
### 05-24 12:00 ###
virt-manager URI screenshot:

----
### 05-24 13:00 ###
If you have issues when starting the NFS server or mounting directories, you may want to reboot the VM. This is because `pacman -Syu nfs-utils` also updates the kernel, making some kernel modules unable to load before rebooting.
---
## tl;dr ##
Your task is simple: set up an NFS server.
---
## Before we start ##
- Grab an Arch Linux VM image from <https://mirror.pkgbuild.com/images/v20210515.22945/>! (user/pass: `arch`/`arch`)
- Set up libvirt (and perhaps virt-manager)
- We do not restrict the distro/hypervisor you use, but do so at your own risk ;)
---
## Install two VMs and make sure they can communicate ##
- With libvirt/virt-manager running locally, the two should already be under the same network by default
- Hopefully you're already familiar with this!
---
## NFS Server ##
----
### Installation ###
``` sh
pacman -Syu nfs-utils
```
----
### Setup Exports ###
``` sh
mkdir -p /srv/nfs/future_gadget_lab
cat >> /etc/exports << EOF
/srv/nfs 10.0.0.1(rw,sync,fsid=0)
/srv/nfs/future_gadget_lab 10.0.0.1(rw,sync)
EOF
exportfs -arv
```
(Replace `10.0.0.1` with client IP!)
----
### Start Server ###
``` sh
systemctl enable --now nfs-server
```
---
## NFS Client ##
----
### Installation ###
``` sh
pacman -Syu nfs-utils
```
----
### Mount! ###
``` sh
mount -t nfs 10.0.0.5:/srv/nfs/future_gadget_lab /mnt
```
(Replace `10.0.0.5` with server IP!)
---
## Submission ##
Screenshots of:
- Server: `cat /etc/exports`
- Server: `exportfs -v`
- Client: `mount`
- Client: `df -h`
---
## Appendix ##
If you want to run the VMs on the workstations...
----
### virt-manager ###
- Custom URI: `qemu+ssh://USER@linuxN.csie.org/session`
----
### Manually edit libvirt XML ###
``` xml
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<!-- Some content -->
<qemu:commandline>
<qemu:arg value='-netdev'/>
<qemu:arg value='user,id=mynet.0,net=10.0.10.0/24'/>
<qemu:arg value='-device'/>
<qemu:arg value='virtio-net-pci,netdev=mynet.0'/>
</qemu:commandline>
<qemu:commandline>
<qemu:arg value='-netdev'/>
<!-- Change the port to something you like -->
<qemu:arg value='socket,id=vlan,mcast=230.0.0.1:1234'/>
<qemu:arg value='-device'/>
<qemu:arg value='virtio-net-pci,netdev=vlan'/>
</qemu:commandline>
</domain>
```
----
### Set up IP ###
``` sh
ip addr add 10.0.0.1/24 dev eth1
ip link set eth1 up
```
---
## Resources ##
- <https://wiki.archlinux.org/title/NFS>
- `man exports`
{"metaMigratedAt":"2023-06-16T00:50:15.782Z","metaMigratedFrom":"YAML","title":"Lab #11: NFS","breaks":true,"slideOptions":"{\"theme\":\"solarized\"}","contributors":"[{\"id\":\"55597f68-6250-4693-98a8-f13d6edc7104\",\"add\":3845,\"del\":693}]"}