4.客户端是Linux系统
[root@RedHat ~]# yum install iscsi-target-utils --安装客户端软件
[root@redhat ~]# /etc/init.d/iscsid start --启动服务
[root@redhat ~]# /etc/init.d/iscsi start --启动服务
[root@redhat ~]# iscsiadm -m discovery -t sendtargets -p 2.2.2.27:3260 --查找服务器的共享磁盘
2.2.2.27:3260,1 iqn.2014-01.node1:server.target4
[root@redhat ~]# iscsiadm -m node -T iqn.2014-01.node1:server.target4 --login --登陆服务器
Logging in to [iface: default, target: iqn.2014-01.node1:server.target4, portal: 2.2.2.27,3260] (multiple)
Login to [iface: default, target: iqn.2014-01.node1:server.target4, portal: 2.2.2.27,3260] successful.
[root@redhat ~]# fdisk -l /dev/sdb --查看磁盘
Disk /dev/sdb: 546 MB, 546308096 bytes
255 heads, 63 sectors/track, 66 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5ce268ef
Device Boot Start End Blocks Id System
/dev/sdb1 2 66 522112+ 5 Extended
/dev/sdb5 2 66 522081 7 HPFS/NTFS
[root@redhat ~]# mkfs.ext4 /dev/sdb --格式化磁盘
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
33360 inodes, 133376 blocks
6668 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=138412032
5 block groups
32768 blocks per group, 32768 fragments per group
6672 inodes per group
Superblock backups stored on blocks:
32768, 98304
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@redhat ~]# mount /dev/sdb /mnt/ --挂载目录
[root@redhat ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
ext4 20G 833M 19G 5% /
tmpfs tmpfs 262M 0 262M 0% /dev/shm
/dev/sda1 ext4 508M 32M 451M 7% /boot
/dev/sr0 iso9660 538M 18M 494M 4% /mnt
/dev/sdb ext4 538M 18M 494M 4% /mnt
[root@redhat ~]# ll /mnt/ --查看文件
total 16
drwx------. 2 root root 16384 Jan 16 13:55 lost+found
[root@redhat ~]#
5.注销iscsi连接和退出
[root@redhat ~]# iscsiadm -m node -o delete -T iqn.2014-01.node1:server.target4 --注销连接
iscsiadm: This command will remove the record [iface: default, target: iqn.2014-01.node1:server.target4, portal: 2.2.2.27,3260], but a session is using it. Logout session then rerun command to remove record.
iscsiadm: Could not execute operation on all records: session exists
[root@redhat ~]# iscsiadm -m node -U all --断开所有连接
Logging out of session [sid: 1, target: iqn.2014-01.node1:server.target4, portal: 2.2.2.27,3260]
Logout of [sid: 1, target: iqn.2014-01.node1:server.target4, portal: 2.2.2.27,3260] successful.
[root@redhat ~]# sfdisk -l --没有那个磁盘了
Disk /dev/sda: 2652 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 0+ 63- 64- 512000 83 Linux
/dev/sda2 63+ 2652- 2589- 20794368 8e Linux LVM
/dev/sda3 0 - 0 0 0 Empty
/dev/sda4 0 - 0 0 0 Empty
Disk /dev/mapper/VolGroup-lv_root: 2457 cylinders, 255 heads, 63 sectors/track
Disk /dev/mapper/VolGroup-lv_swap: 130 cylinders, 255 heads, 63 sectors/track
[root@redhat ~]#
更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14
