I'm trying to export disk image on one machine to another machine using nbd-server and nbd-client. On the sever side (hostname gpu) where nbd-server will run, I made an disk image using the dd command and created a file system on the image file using the mke2fs command. The image file looks like this.
hadoop@gpu:~/nbd_test$ file disk_image
disk_image: Linux rev 1.0 ext2 filesystem data, UUID=058e181f-6461-46b1-ba7c-ead455ae83c9 (large files)
Then, I configured /etc/nbd-server/config as follows.
[generic]
# If you want to run everything as root rather than the nbd user, you
# may either say "root" in the two following lines, or remove them
# altogether. Do not remove the [generic] section, however.
user = nbd
group = nbd
includedir = /etc/nbd-server/conf.d
# What follows are export definitions. You may create as much of them as
# you want, but the section header has to be unique.
[nbd-test]
exportname = /home/hadoop/nbd_test/disk_image
# The following line will be ignored unless the
# "oldstyle = true" line in the generic section above is
# enabled.
port = 12345
#authfile = /export/nbd/export1-authfile
#timeout = 30
#filesize = 10000000
readonly = false
multifile = false
copyonwrite = false
#prerun = dd if=/dev/zero of=%s bs=1k count=500
#postrun = rm -f %s
Then, I ran nbd-server as follows
hadoop@gpu:~/nbd_test$ sudo nbd-server -C /etc/nbd-server/config
** (process:17264): WARNING **: A port was specified, but oldstyle exports were not requested. This may not do what you expect.
** (process:17264): WARNING **: Please read 'man 5 nbd-server' and search for oldstyle for more info
Then, on the client machine (pcl-mr1), I got the following resulting after mounting the block special file /dev/nbd0.
hadoop@pcl-mr1:~$ sudo nbd-client gpu -N nbd-test /dev/nbd0
Negotiation: ..size = 1953MB
bs=1024, sz=2048000000 bytes
hadoop@pcl-mr1:~$ sudo mount /dev/nbd0 nbd_disk/
mount: block device /dev/nbd0 is write-protected, mounting read-only
Even though I configured the configuration file on the server side with the disk image both readable and writable, the disk image appeared as read-only on the client side. What's wrong in the steps above I went through? How can I export the disk image with read-write permission? Any help would be greatly appreciated.
Little late for the answer here but posting it for the benefit of other people who run into this issue -
Option#1: Change ownership of the backing file -
Option#2: Change permissions on the backing file -
Option#3: Change /etc/nbd-server/config to run nbd-server as suitable user (say hadoop) -