服务端:
首先拿出一块分区/dev/sda5
# yum search target
# yum install scsi-target-utils.x86_64 -y //服务端的包
# vim /etc/tgt/targets.conf //编辑服务端的配置
<target redhat:1> //共享出这块分区的名字为redhat:1
backing-store /dev/sda5
</target>
/etc/init.d/tgtd restart //重启服务
客户端的安装:
# yum search iscsi 查找到iscsi软件包并安装
[root@redhat conf.d]# iscsiadm -m discovery -t st -p 192.168.3.60 //首先发现服务端的这块分区
Starting iscsid: [ OK ]
192.168.3.60:3260,1 redhat:1
[root@redhat conf.d]#
[root@redhat conf.d]# iscsiadm -m node -T redhat:1 -p 192.168.3.60 -l //使用进入这块分区
Logging in to [iface: default, target: redhat:1, portal: 192.168.3.60,3260] (multiple)
Login to [iface: default, target: redhat:1, portal: 192.168.3.60,3260] successful.
Disk /dev/sda: 209 MB, 209715200 bytes
# fdisk -cu /dev/sda
[root@redhat conf.d]# partx -d /dev/sda
error deleting partitions 2-256: BLKPG: No such device or address
[root@redhat conf.d]# partx -a /dev/sda
# mkfs.ext4 /dev/sda1
[root@redhat conf.d]# mount /dev/sda1 /mnt/
[root@redhat conf.d]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root 6926264 1557096 5017324 24% /
tmpfs 244988 0 244988 0% /dev/shm
/dev/vda1 495844 33487 436757 8% /boot
/dev/sda1 197338 5646 181504 4% /mnt
# umount /mnt/
# iscsiadm -m node -T redhat:1 -p 192.168.3.60 -u
# fdisk -l //sda1 是没有了
# /etc/init.d/iscsi restart
# fdisk -l //重启后发现又恢复出来了
Disk /dev/sda: 209 MB, 209715200 bytes
# iscsiadm -m node -T redhat:1 -p 192.168.3.60 -u
# iscsiadm -m node -T redhat:1 -p 192.168.3.60 -o delete
# /etc/init.d/iscsi restart
# fdisk -l
没有了不会再恢复出来。
CentOS 6.4系统存储服务器之iSCSI:http://www.linuxdiyf.com/linux/11389.html
关于文件的存储-Windows和Linux比较:http://www.linuxdiyf.com/linux/4286.html