我们有一个带有2个磁盘(sda
和sdb
)的RHEL 7服务器。我们/
,/var/log
和swap
是上sda
,/var
是sdb
。我们使用LVM和XFS。
sda
太大(160 GB),我们希望将其缩小到40 GB。然后,我们可以使用120 GB的免费扩展空间sdb
。
[root@foo ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 rhel lvm2 a-- 134.77g 9.77g
/dev/sdb1 vg_var lvm2 a-- 200.00g 0
[root@foo ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root rhel -wi-ao---- 117.19g
swap rhel -wi-ao---- 3.91g
var_log rhel -wi-ao---- 3.91g
lv_var vg_var -wi-ao---- 200.00g
[root@foo ~]# fdisk -l
Disk /dev/sdb: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x3235298e
Device Boot Start End Blocks Id System
/dev/sdb1 2048 419430399 209714176 8e Linux LVM
Disk /dev/sda: 161.1 GB, 161061273600 bytes, 314572800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x0009b153
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 283656191 141315072 8e Linux LVM
Disk /dev/mapper/rhel-root: 125.8 GB, 125829120000 bytes, 245760000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/rhel-swap: 4194 MB, 4194304000 bytes, 8192000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/vg_var-lv_var: 214.7 GB, 214744170496 bytes, 419422208 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/rhel-var_log: 4194 MB, 4194304000 bytes, 8192000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
我们如何安全地实现这一目标?我已经在测试机上尝试过,但是失败了:
- 添加新磁盘
- 创建一个LVM分区,pvcreate并在其上添加一个新的LV。
- 使用应急磁盘启动
- 安装
sda
到/mnt/sysimage
新磁盘的LV并将其安装到/mnt/sdb
cp -ax /mnt/sysimage/* /mnt/sdb
- 更新
/mnt/sysimage/etc/fstab
使用/dev/mapper/rhel-lv_root
- 最终由于以下原因重启失败
INT18 boot failure
2
问题没有道理。/ dev / sda和/ dev / sdb是硬盘。它们的大小取决于它们的制造方式,并且不能更改。
—
psusi
@psusi从理论上讲,您可以拥有一个没有分区表的硬盘,然后像单个分区一样使用它,但是我怀疑这是OP在这里所做的。
—
phk