是否可以在 Centos 机器上扩展 /DEV/SDB1 而不会造成停机/数据丢失?

是否可以在 Centos 机器上扩展 /DEV/SDB1 而不会造成停机/数据丢失?

在 CentOS6 上我想扩展 /dev/sdb1 以获得更多可用空间:

df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_www-lv_root 18G 2.9G 14G 18% / tmpfs 3.9G 0 3.9G 0% /dev/shm /dev/sda1 477M 105M 347M 24% /boot /dev/sdb1 296G 233G 48G 84% /sqldata

VMWare 中物理硬盘 SDB 已经扩展到 600GB,fdisk /dev/sdb1 如下:

Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 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: 0x000021cd

Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 2611 20458496 8e Linux LVM

Disk /dev/sdb: 644.2 GB, 644245094400 bytes 255 heads, 63 sectors/track, 78325 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: 0x07acc91f

Device Boot Start End Blocks Id System /dev/sdb1 1 39162 314568733+ 83 Linux /dev/sdb2 39163 78325 314576797+ 8e Linux LVM

Disk /dev/mapper/vg_www-lv_root: 18.9 GB, 18865979392 bytes 255 heads, 63 sectors/track, 2293 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: 0x00000000

Disk /dev/mapper/vg_www-lv_swap: 2080 MB, 2080374784 bytes 255 heads, 63 sectors/track, 252 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: 0x00000000

您可能已经看到,/dev/sdb1 不是卷组的一部分。因此我不确定该如何继续。

我已经创建了一个新的分区:/dev/sdb2 作为 linux LVM: fdisk /dev/sdb

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u').

Command (m for help): p

Disk /dev/sdb: 644.2 GB, 644245094400 bytes 255 heads, 63 sectors/track, 78325 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: 0x07acc91f

Device Boot Start End Blocks Id System /dev/sdb1 1 39162 314568733+ 83 Linux /dev/sdb2 39163 78325 314576797+ 8e Linux LVM

/dev/sdb2 是一个新的(空)分区,包含新的 300gb 磁盘空间。由于我真的无法忍受任何停机时间,所以我想知道如何“合并”sdb1 和 sdb2,这样我最终会得到大约 600gb 的 /sqldata。

谢谢!

答案1

在这个环境中,很可能需要停机,单个分区。

EL6 文档警告你不要尝试在使用中的设备上调整大小. 停止使用该文件系统的所有内容,卸载它,并修改其分区表。

EL7 使得可以在线调整分区大小,通过删除、重新创建,以及partx --update告诉内核的技巧。您需要先升级,可能升级到 EL8。


使用 LVM 而不是分区,这会更容易。完全跳过分区。在整个设备上创建物理卷,例如/dev/sdb。调整磁盘大小,然后使用 调整 PV 的大小pvresize。由于您没有使用 LVM,因此这将是迁移到新的 LVM 存储。

相关内容