Wednesday, March 23, 2016

Network Block Device protocol, share block device over network

we can Network Block Device protocol to share block device such as harddisk, partition, cdrom over network.

for server part we use nbd-server and for client part we use nbd-client

-server ip:
     device to share: /dev/sdc1
-client ip:

1- installation
$ sudo apt-get install nbd-server

2- change the configuration file(/etc/nbd-server/config) like below
    user = root
    group = root
    includedir = /etc/nbd-server/conf.d

    exportname = /dev/sdc1
    authfile = /etc/nbd-server/allow

3- edit /etc/nbd-server/allow to allow our client

4- restart nbd-server service
$ sudo service nbd-server restart

1- installation
$ sudo apt-get install nbd-client

2- connect to server and map our local device /dev/nbd0 to remote block device sdc1
$ sudo nbd-client  /dev/nbd0 -N sdc1
or if you change default  server port to 10810
$ sudo nbd-client 10810 /dev/nbd0 -N sdc1

3- if on server you already format filesystem on sdc1 with ext4, or ntfs, we can mount directly and ready to use, if not just format the filesytem.
$ sudo mount /dev/nbd0 /mnt
$ df -h | grep nbd
/dev/nbd0       4.8G   10M  4.6G   1% /mnt

No comments:

Post a Comment