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

***info***
-server ip: 192.168.202.23
     device to share: /dev/sdc1
-client ip: 192.168.202.1

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

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

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


3- edit /etc/nbd-server/allow to allow our client
127.0.0.1
192.168.202.1
192.168.1.0/24


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

***client***
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  192.168.202.23  /dev/nbd0 -N sdc1
or if you change default  server port to 10810
$ sudo nbd-client  192.168.202.23 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