调整GPT多路径磁盘的大小,并在CentOS 6上进行分区
时间:2020-03-21 11:46:49 来源:igfitidea点击:
具有GPT分区的iSCSI多路径设备的在线调整大小。
不需要重新启动服务器,但是需要卸载该分区并且不使用该分区。
在SAN上调整LUN大小之前
抓取一些数据。
我们的多路径设备是mpatham,大小为20GB。
我们会将其扩展10GB到30GB。
# multipath -ll mpatham mpatham (36000eb3959dd493f000000000001c3db) dm-77 LEFTHAND,iSCSIDisk size=20G features='0' hwhandler='0' wp=rw `-+- policy='round-robin 0' prio=1 status=active |- 93:0:0:0 sdbt 68:112 active ready running `- 94:0:0:0 sdbu 68:128 active ready running
# parted /dev/mapper/mpatham print Model: Linux device-mapper (multipath) (dm) Disk /dev/mapper/mpatham: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 1049kB 21.5GB 21.5GB ext4 primary
# blockdev --getsz /dev/mapper/mpatham 41943040 # blockdev --getsz /dev/mapper/mpathamp1 41940959
# blockdev --getsz /dev/sdbt 41943040 # blockdev --getsz /dev/sdbt1 41940959
# blockdev --getsz /dev/sdbu 41943040 # blockdev --getsz /dev/sdbu1 41940959
# df -h|egrep "File|mpathamp1|data" Filesystem Size Used Avail Use% Mounted on /dev/mapper/mpathamp1 20G 142M 20G 1% /data
在SAN上调整LUN的大小之后
Parted
我们应该已经在CentOS 6系统上安装了parted。
如果不是这种情况,请运行以下命令:
# yum install parted
重新扫描设备
我们可以重新扫描sdbt和sdbu设备,也可以重新扫描所有正在运行的会话。
重新扫描设备:
# echo 1 > /sys/block/sdbt/device/rescan # echo 1 > /sys/block/sdbu/device/rescan
或者,重新扫描所有正在运行的会话:
# iscsiadm -m session --rescan
请注意,如果要创建新设备而不是扩展现有设备,则可能需要扫描SAN并登录到所有发现的目标:
# iscsiadm -m discovery -t sendtargets -p netappsan.local:3260 # iscsiadm -m node -L automatic
重新加载多路径服务以获取新的大小:
# /etc/init.d/multipathd reload
多路径设备大小为30GB。
# multipath -ll mpatham mpatham (36000eb3959dd493f000000000001c3db) dm-77 LEFTHAND,iSCSIDisk size=30G features='0' hwhandler='0' wp=rw `-+- policy='round-robin 0' prio=1 status=active |- 93:0:0:0 sdbt 68:112 active ready running `- 94:0:0:0 sdbu 68:128 active ready running
# blockdev --getsz /dev/mapper/mpatham 62914560 # blockdev --getsz /dev/mapper/mpathamp1 41940959
# blockdev --getsz /dev/sdbt 62914560 # blockdev --getsz /dev/sdbt1 41940959
# blockdev --getsz /dev/sdbu 62914560 # blockdev --getsz /dev/sdbu1 41940959
重新创建GPT分区
确保未安装多路径设备:
# umount /dev/mapper/mpathamp1
在多路径设备上分开运行:
# parted /dev/mapper/mpatham GNU Parted 2.1 Using /dev/mapper/mpatham Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) p Error: The backup GPT table is not at the end of the disk, as it should be. This might mean that another operating system believes the disk is smaller. Fix, by moving the backup to the end (and removing the old backup)? Fix/Ignore/Cancel? Fix Warning: Not all of the space available to /dev/mapper/mpatham appears to be used, you can fix the GPT to use all of the space (an extra 20971520 blocks) or continue with the current setting? Fix/Ignore? Fix Model: Linux device-mapper (multipath) (dm) Disk /dev/mapper/mpatham: 32.2GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 1049kB 21.5GB 21.5GB ext4 primary (parted) rm 1 (parted) unit Kb (parted) mkpart primary ext4 1049 -1 Warning: You requested a partition from 1049kB to 32212254kB. The closest location we can manage is 1049kB to 32212237kB. Is this still acceptable to you? Yes/No? Yes (parted) p Model: Linux device-mapper (multipath) (dm) Disk /dev/mapper/mpatham: 32212255kB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 1049kB 32212238kB 32211189kB ext4 primary (parted) q
重新加载分区表并调整文件系统大小
告诉内核重新加载分区表。
请注意,在RHEL 6中,partprobe仅会触发操作系统更新磁盘上未使用任何分区的分区。
如果正在使用磁盘上的任何分区,则partprobe不会触发OS更新系统中的分区,因为在某些情况下它被认为是不安全的。
# partprobe
调整大小之前,请检查文件系统:
# e2fsck -f /dev/mapper/mpathamp1 e2fsck 1.41.12 (17-May-2010) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/mapper/mpathamp1: 11/1310720 files (0.0% non-contiguous), 118545/5242619 blocks
调整文件系统大小:
# resize2fs /dev/mapper/mpathamp1 resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/mapper/mpathamp1 to 7864059 (4k) blocks. The filesystem on /dev/mapper/mpathamp1 is now 7864059 blocks long.
抓取一些数据:
# blockdev --getsz /dev/mapper/mpatham 62914560 # blockdev --getsz /dev/mapper/mpathamp1 62912479
# blockdev --getsz /dev/sdbt 62914560 # blockdev --getsz /dev/sdbt1 62912479
# blockdev --getsz /dev/sdbu 62914560 # blockdev --getsz /dev/sdbu1 62912479
最后,安装分区:
# mount /dev/mapper/mpathamp1 /data/
# df -h|egrep "File|mpathamp1|data" Filesystem Size Used Avail Use% Mounted on /dev/mapper/mpathamp1 30G 142M 30G 1% /data