Attaching NBD and iSCSI in Ubuntu

Source: Internet
Author: User

The following is a test in ubuntu12.04.4.

NBDUse of network Block devices

I. NBD Introduction

NBD (network block device) allows you to use the disk space of a remote host as a block device. just like a hard disk. you can easily add the hard disk space of another server to the local server.

Ii. NBD Installation Method

In turbolinux version 10 or later, NBD has been compiled into a module and saved in

/Lib/modules/$ version/kernel/driver/block. you also need to install the NBD-server and NBD-client tools on the server and client. you can download the source code package from the official website and install it on the server and client server respectively:

Http://sourceforge.net/projects/nbd

Here we download nbd-2.8.8.tar.bz2

After the download, perform the following steps to install:

# Tar jxf nbd-2.8.8.tar.bz2

# Cd nbd-2.8.8

#./Configure

# Make

# Make install

Or use the command line to install:

Sudoapt-Get install NBD-Client

Sudoapt-Get install NBD-Server

Iii. NBD usage

View the NBD process.

# Ps-Ef | grep NBD

Root11292 1 0 :02? 00:00:00 NBD-server 1234/dev/nbd0

2. Client configuration method

Sudoapt-Get install NBD-Client

Load the NBD module.

# Modprobe NBD

# Lsmod | grep NBD

Nbd26400 0

Check whether the NBD device is created.

# Ls/dev/NBD *-Hl

BRW-r ----- 1 root disk 43, 0 Jul 27 :40/dev/nbd0

BRW-r ----- 1 root disk 43, 1 Jul 27 :40/dev/nbd1

BRW-r ----- 1 root disk 43, 2 Jul 27 :40/dev/nbd2

BRW-r ----- 1 root disk 43, 3 Jul 27 :40/dev/nbd3

BRW-r ----- 1 root disk 43, 4 Jul 27 :40/dev/nbd4

BRW-r ----- 1 root disk 43, 5 Jul 27 :40/dev/nbd5

BRW-r ----- 1 root disk 43, 6 Jul 27 :40/dev/nbd6

BRW-r ----- 1 root disk 43, 7 Jul 27/dev/nbd7

BRW-r ----- 1 root disk 43, 8 Jul 27/dev/nbd8

BRW-r ----- 1 root disk 43, 9 Jul 27/dev/nbd9

Connect the/dev/nbd0 device to the host.

# NBD-Client: 192.168.1.1 1234/dev/nbd0

Negotiation: .. size = 307200kb

BS = 1024, SZ = 307200

NBD-client usage:

NBD-Client [BS = blocksize] host port nbd_device [-swap]

BS is used to set the block size. The default value is 1024, which can be 512,102 4.2048, 4096

Host server host name or IP address

Port server listening port

Which NBD device is mapped to the local device (for example,/dev/nbd0)

-Swap: The NBD device is used as the swap space.

NBD-client-D nbd_device is used to disconnect

After the connection is successful, you can view the NBD-client process.

# Ps-Ef | grep NBD

Root3156 1 0 00:00:00 pts/0 NBD-client 192.168.1.1 1234/dev/nbd0

You need to format the device before use.

# Mkfs. ext3/dev/nbd0

Mount this block device.

# Mkdir/mnt/nbd0

# Mount/dev/nbd0/mnt/nbd0

Reference link:

Http://blog.csdn.net/gui694278452/article/details/7652450

Mounting iSCSI Devices

I. iSCSI target end

(1) install software related to iSCSI target

$ Sudo apt-Get install iscsitarget-source iscsitarget-dkms TGT

(2) modify the configuration file of the iSCSI target

$ Sudo VI/etc/default/iscsitarget

Iscsitarget_enable = true # Change false to true

(3) prepare storage for target

A. Create a target, id = 1, iqn = iqn.2013-02. node2

Tgtadm -- LLD iSCSI -- op new -- Mode target -- TID 1-T iqn.2013-02. node2

B. view the currently created target and Lun.

Tgtadm -- LLD iSCSI -- op show -- Mode target

C. To enable a target to be accessed by initiator, you must first execute the following command:

Tgtadm -- LLD iSCSI -- op bind -- Mode target -- TID 1-I all

D. Configure iSCSI target in Ubuntu

# Vi/etc/Iet/ietd. conf

Add the following information at the end of the file:

Target iqn.2012-12. Local. mynet: storage. lun1 // iqn.2012-12. Local. mynet: storage. lun1 is iqn

E. Restart the iscsitarget service.

Service iscsitarget restart

2. iSCSI initiator

(1) install Open-SCSI

Sudo apt-Get install Open-iSCSI open-iSCSI-utils

(2) iSCSI target discovered

Sudo iscsiadm-M discovery-T sendtargets-P 192.168.35.17

The following information is displayed:

192.168.35.17: 3260,1 iqn.2013-02. node2

(3) Use target

Sudo iscsiadm-M node -- targetname iqn.2013-02. node2-P 192.168.35.17 -- Login

After performing the preceding operations, you can add one more/dev/sdx on the local host.

# Delete a target:

Sudo iscsiadm-M node -- targetname iqn.2013-02. node2-P 192.168.35.17-u

(5) Format

Mkfs. ext3/dev/sdx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.