The systemd service for NBD Client doesn't come up on boot
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
nbd (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
The `systemd` service for starting the NBD Clients on boot isn't working.
### Steps to Reproduce:
0. Install NBD
-
apt install nbd-server nbd-client
-
1. Prepare an NBD server with a disk image to share. For instance:
-
truncate -s 1T /vol-0.img
-
2. Configure the NBD server by adding the following to `/etc/nbd-
-
[vol0]
exportname = /vol-0.img
-
3. Configuring the client connection in `/etc/nbdtab`:
Contents of `/etc/nbdtab`:
-
nbd0 localhost vol0
-
4. Enable it on `systemd`:
-
systemctl enable nbd@nbd0
-
Here's what I see:
-
# systemctl enable nbd@nbd0
Created symlink /<email address hidden> → /lib/systemd/
Unit /lib/systemd/
-
5. Add `nbd` auto-load to system'd boot:
echo nbd > /etc/modules-
6. Reboot
-
sudo reboot
-
7. The service not coming up on the system's boot. Look:
After rebooting the system, the NBD clien for `nbd0` isn't running (but it's enabled on systemd).
-
root@demo-
○ <email address hidden> - NBD client connection for nbd0
Loaded: loaded (/lib/systemd/
Active: inactive (dead)
Docs: man:nbd-client
Feb 21 22:54:22 demo-nbd-test systemd[1]: <email address hidden>: Dependency Before=
-
But if you try to start it again. It'll work:
-
root@demo-
root@demo-
● <email address hidden> - NBD client connection for nbd0
Loaded: loaded (/lib/systemd/
Active: active (exited) since Wed 2024-02-21 22:57:37 UTC; 2s ago
Docs: man:nbd-client
Process: 1096 ExecStart=
Main PID: 1096 (code=exited, status=0/SUCCESS)
CPU: 4ms
Feb 21 22:57:37 demo-nbd-test systemd[1]: Starting NBD client connection for nbd0...
Feb 21 22:57:37 demo-nbd-test nbd-client[1096]: Negotiation: ..size = 3145728MB
Feb 21 22:57:37 demo-nbd-test nbd-client[1096]: Connected /dev/nbd0
Feb 21 22:57:37 demo-nbd-test systemd[1]: Finished NBD client connection for nbd0.
-
So this forces me to have the following `/etc/rc.local` file as a workaround:
-
#!/bin/bash
sleep 6
systemctl start nbd@nbd0
-
Make it executable:
-
chmod +x /etc/rc.local
-
Reboot again, it'll be started on next boot!
I don't think that the `/etc/rc.local` should be part of this procedure... =P
NOTE: Don't need to run `update-initramfs -k all -u`.
Changed in nbd (Ubuntu): | |
status: | Incomplete → New |
summary: |
- The systemd service for NBD Server doesn't come up on boot + The systemd service for NBD Client doesn't come up on boot |
description: | updated |
description: | updated |
Hello and thanks for this bug report. I had a quick look at /lib/systemd/ system/ nbd@.service, and the [Install] section shows that the nbd@*.service units are not meant to just be started automatically, but when a dev-*.device is created:
[Install] dev-%i. device dev-%ip1. device
RequiredBy=
RequiredBy=
[...]
and I believe there are udev rules handling those devices. In other words, I believe we need a more complete picture of what issue to triage this as a bug and begin working on it. Could you please provide a minimal but complete set of steps to configure an Ubuntu system so that the problem reproduces? Using the same system as client and server should be enough, similar to what has been done in LP: #2054470.
Thanks