本文主要是介绍大于2T磁盘划分并挂接,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
需要挂接9T多的磁盘做数据磁盘,记录下操作过程
1、使用fdisk -l识别到磁盘
# fdisk -l|grep '9.5 TiB'
Disk /dev/sdd: 9.5 TiB, 10453950398464 bytes, 20417871872 sectors
Disk /dev/sdf: 9.5 TiB, 10453950398464 bytes, 20417871872 sectors
Disk /dev/sdh: 9.5 TiB, 10453950398464 bytes, 20417871872 sectors
Disk /dev/sdj: 9.5 TiB, 10453950398464 bytes, 20417871872 sectors
2、找到wwid
# for i in `cat /proc/partitions |awk {'print $4'} |grep sd`; do echo "Device: $i WWID: `/usr/lib/udev/scsi_id --page=0x83 --whitelisted --device=/dev/$i` "; done |sort -k4
Device: sdd WWID: 3600b3420895596a656d4185f1e000055
Device: sdf WWID: 3600b3420895596a656d4185f1e000055
Device: sdh WWID: 3600b3420895596a656d4185f1e000055
Device: sdj WWID: 3600b3420895596a656d4185f1e000055
3、编辑/etc/multipath.conf,添加如下内容
multipaths {
multipath {
wwid 3600b3420895596a656d4185f1e000055
alias oradata
}
}
添加后重启服务并查看到磁盘
# systemctl restart multipathd
# multipath -ll
oradata (3600b3420895596a656d4185f1e000055) dm-4 MacroSAN,LU
size=9.5T features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
|-+- policy='service-time 0' prio=50 status=enabled
| |- 15:0:2:1 sdd 8:48 active ready running
| `- 16:0:2:1 sdh 8:112 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
|- 15:0:3:1 sdf 8:80 active ready running
`- 16:0:4:1 sdj 8:144 active ready running
4、parted分区
# parted /dev/mapper/oradata
GNU Parted 3.2
Using /dev/mapper/oradata
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Error: /dev/mapper/oradata: unrecognised disk label
Model: Linux device-mapper (multipath) (dm)
Disk /dev/mapper/oradata: 10.5TB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
(parted) mklabel gpt
(parted) p
Model: Linux device-mapper (multipath) (dm)
Disk /dev/mapper/oradata: 10.5TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted) mkpart oradata
File system type? [ext2]? xfs
Start? 0
End? 100%
Warning: The resulting partition is not properly aligned for best performance: 34s % 2048s != 0s
Ignore/Cancel? I
(parted) p
Model: Linux device-mapper (multipath) (dm)
Disk /dev/mapper/oradata: 10.5TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 10.5TB 10.5TB xfs oradata
(parted) q
Information: You may need to update /etc/fstab.
5、格式化并挂接
mkfs.xfs /dev/mapper/oradata1
meta-data=/dev/mapper/oradata1 isize=512 agcount=10, agsize=268435455 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=0 inobtcount=0
data = bsize=4096 blocks=2552233975, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=521728, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
# blkid |grep oradata1
/dev/mapper/oradata1: UUID="0b1a2a41-02d3-4fed-8009-bcd6c4661116" BLOCK_SIZE="512" TYPE="xfs" PARTLABEL="oradata" PARTUUID="7ba8582f-ca5f-4478-9666-246c48b7c258"
在/etc/fstab中添加一行
UUID=0b1a2a41-02d3-4fed-8009-bcd6c4661116 /oradata xfs defaults 0 0
# mkdir /oradata
# mount -a
# df -h|grep oradata1
/dev/mapper/oradata1 9.6T 68G 9.5T 1% /oradata
附:fdisk -l报错(Partition 1 does not start on physical sector boundary.)处理--未验证
获得磁盘的alignment参数-本例是聚合后的磁盘dm-4,根据实际调整
cat /sys/block/dm-4/queue/optimal_io_size
cat /sys/block/dm-4/alignment_offset
cat /sys/block/dm-4/queue/physical_block_size
把optimal_io_size的值与alignment_offset的值相加,之后除以 physical_block_size 的值。
在我的例子中是:(0 + 0) / 512 = 0。
这个数值是分区起始的扇区。新的parted命令应该写成类似下面这样:mkpart 0s 100%
0s中的字母s是很有意义的:它告诉parted,你的输入是0扇区,而不是0字节,也不是0兆字节。
这篇关于大于2T磁盘划分并挂接的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!