我正在尝试使用 nbd-server 和 nbd-client 将一台机器上的磁盘映像导出到另一台机器。在将运行 nbd-server 的服务器端(主机名 gpu)上,我使用 dd 命令制作了一个磁盘映像,并使用 mke2fs 命令在该映像文件上创建了一个文件系统。图像文件如下所示。
hadoop@gpu:~/nbd_test$ file disk_image
disk_image: Linux rev 1.0 ext2 filesystem data, UUID=058e181f-6461-46b1-ba7c-ead455ae83c9 (large files)
然后,我配置 /etc/nbd-server/config 如下。
[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
然后,我按如下方式运行 nbd-server
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
然后,在客户端机器(pcl-mr1)上,我在挂载块特殊文件 /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
即使我在服务器端配置了磁盘映像可读和可写的配置文件,磁盘映像在客户端显示为只读。我经历的上述步骤有什么问题?如何导出具有读写权限的磁盘映像?任何帮助将不胜感激。