#格式化完成检查
[root@localhost data]# fdisk -l
Disk/dev/sda: 214.7 GB, 214748364800 bytes, 419430400sectors
Units= sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk label type: dos
Disk identifier:0x000a43f1Device Boot Start End Blocks Id System/dev/sda1 * 2048 1026047 512000 83Linux/dev/sda2 1026048 419430399 2092021768e Linux LVM
Disk/dev/mapper/centos-root: 205.8 GB, 205759971328 bytes, 401874944sectors
Units= sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk/dev/mapper/centos-swap: 8455 MB, 8455716864 bytes, 16515072sectors
Units= sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk/dev/sdb: 107.4 GB, 107374182400 bytes, 209715200sectors
Units= sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 4096 bytes / 1048576bytes
Disk label type: dos
Disk identifier:0xd96b07f4Device Boot Start End Blocks Id System/dev/sdb1 2048 209715199 104856576 83 Linux
#指定分区格式
[root@localhost data]# mkfs.ext4 /dev/sdb1
mke2fs1.42.9 (28-Dec-2013)
Filesystem label=OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=256blocks6553600 inodes, 26214144blocks1310707 blocks (5.00%) reserved forthe super user
First data block=0Maximum filesystem blocks=2174746624
800 block groups
32768 blocks per group, 32768fragments per group8192inodes per group
Superblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,4096000, 7962624, 11239424, 20480000, 23887872Allocating group tables:doneWriting inode tables:doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information:done
#挂载并写入文件
[root@localhost ~]# mkdir /data/iscsi
[root@localhost ~]# mount -t ext4 /dev/sdb1 /data/iscsi/
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 192G 1.4G 191G 1% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 8.7M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 497M 108M 390M 22% /boot
tmpfs 797M 0 797M 0% /run/user/0
/dev/sdb1 99G 61M 94G 1% /data/iscsi
#设置开机自动挂载
echo "/dev/sdb1 /data/iscsi/ ext4 defaults 0 0" >> /etc/fstab
#检查
[root@localhost mnt]# cat /etc/fstab
#
#/etc/fstab
# Created by anaconda on Fri Nov10 19:40:13 2017#
# Accessible filesystems, by reference, are maintained under'/dev/disk'# Seeman pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#/dev/mapper/centos-root / xfs defaults 0 0UUID=115aec57-6962-443e-9878-943f3e207a84 /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
/dev/sdb1 /data/iscsi/ ext4 defaults 0 0
#查看并创建文件
[root@localhost ~]# df -h
Filesystem Size Used Avail Use%Mounted on/dev/mapper/centos-root 192G 1.4G 191G 1% /devtmpfs3.9G 0 3.9G 0% /dev
tmpfs3.9G 0 3.9G 0% /dev/shm
tmpfs3.9G 8.6M 3.9G 1% /run
tmpfs3.9G 0 3.9G 0% /sys/fs/cgroup/dev/sda1 497M 108M 390M 22% /boot
tmpfs 797M0 797M 0% /run/user/0
/dev/sdb1 99G 61M 94G 1% /data/iscsi
[root@localhost~]# cd /data/iscsi/[root@localhost iscsi]#touchtest2
[root@localhost iscsi]# ll
total16drwx------ 2 root root 16384 Nov 22 11:30 lost+found-rw-r--r-- 1 root root 0 Nov 22 11:59 test2
#卸载挂载的分区
[root@localhost ~]# umount /dev/sdb1
[root@localhost~]# df -h
Filesystem Size Used Avail Use%Mounted on/dev/mapper/centos-root 192G 1.4G 191G 1% /devtmpfs3.9G 0 3.9G 0% /dev
tmpfs3.9G 0 3.9G 0% /dev/shm
tmpfs3.9G 8.6M 3.9G 1% /run
tmpfs3.9G 0 3.9G 0% /sys/fs/cgroup/dev/sda1 497M 108M 390M 22% /boot
tmpfs 797M0 797M 0% /run/user/0
FreeNas11.04 配置iscsi
1、全局配置
2、采用不认证的方式
3、配置后的效果
4、配置认证网络
5、ALL 或192.168.1.1/24 (某一网段)
6、配置共享账号
配置共享账号效果如下:
7、配置Targent不认证方式访问
8、配置共享目录名称,位置,大小,硬盘RPM.
9、Extents配置完成效果图
10、设置Associated Targets
11、点发现(Discovery)---->Discover Portal:输入IP和端口号--->ok。(其它地方直接用默认设置,即可)
12、Targets(查看连接状态)
13、点磁盘管理,会弹出(检测到了新硬盘),指定GPT格式,再分区格式化,即可使用。
、
如果之前挂载过相同的iscsi磁盘,再挂载时会报错,只需点再Rescan Disks即可,修复。
14、linux下Targets连接方法
#注意他们的端口号是不一样的(备注:默认3260时,可以不指定端口号 )
[root@template ~]# iscsiadm -m discovery -t sendtargets -p 192.168.1.140
#如果改了端口号,在后面要指定端口号
[root@template ~]# iscsiadm -m discovery -t sendtargets -p 192.168.1.140:3261
192.168.1.140:3261,2 iqn.gitlab.11.0
15、登录到共享存储(备注:这里测试登录不同端口的共享盘)
[root@template ~]# iscsiadm -m node -T iqn.gitlab.11.0 -p 192.168.1.140:3261 -l
Logging in to [iface: default, target: iqn.gitlab.11.0, portal: 192.168.1.140,3261] (multiple)
Login to [iface: default, target: iqn.gitlab.11.0, portal: 192.168.1.140,3261] successful.
16、卸载iscsi
[root@next-cloud-server ~]# iscsiadm -m node -T iqn.netcloud.11.0 -u
Logging out of session [sid: 1, target: iqn.netcloud.11.0, portal: 10.0.101.6,3261]
Logout of [sid: 1, target: iqn.netcloud.11.0, portal: 10.0.101.6,3261] successful.
17、实现iscsi自动挂载磁盘
Fedora25设置开机自动挂载
#配置iscsi自动发现
cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.netcloud.11.0
#重新启动服务
systemctl restart iscsid
systemctl status iscsid
systemctl enable iscsid
#设置开机自动挂载
[root@next-cloud-server ~]# vi /etc/rc.d/rc.local
#!/bin/sh
#mount iscsi disk 5TB
sleep 10
mount -t xfs /dev/sda /data
#授权
chmod +x /etc/rc.d/rc.local
#添加服务
[root@next-cloud-server ~]# vim /usr/lib/systemd/system/rc-local.service
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.d/rc.local is executable.
[Unit]
Description=/etc/rc.d/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.d/rc.local
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.d/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
#添加下面两行代码,实现rc-local作为服务启动
[Install]
WantedBy=multi-user.target
#启动服务
systemctl daemon-reload
systemctl start rc-local.service (备注:去掉这行)
systemctl enable rc-local.service
参考:http://blog.csdn.net/u013372441/article/details/77414471
18、挂载分区5T
分区
fdisk /dev/sda
g #大于5tb
再回车分区到完成
partprobe
mkfs.xfs -f /dev/sda
mount -t xfs /dev/sda /data/