ubuntu nbd-server nbd-client使用

1 Install nbd-server

sudo apt-get install nbd-server

2 Create a file content

dd if=/dev/zero of=/mnt/dhini bs=1024 count=36000

Use mke2fs to make the /mnt/dhini as a filesystem.

mke2fs /mnt/dhini

3 config nbd-server

cat /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.

[export]
    exportname = /home/pandx/sdbdisk/dhini

4 run nbd-server

sudo nbd-server 1043  
                            
➜  sdbdisk netstat -tln|grep 1043
tcp6       0      0 :::1043                 :::*                    LISTEN

 

5 Install nbd-client

apt-get install nbd-client
modprobe nbd

6 connect nbd-server

sudo nbd-client -N export 10.0.1.57 1043 /dev/nbd0

 

done.

posted @ 2020-01-08 11:59  kissrule  阅读(1526)  评论(0编辑  收藏  举报