我们有一个带有 Perc H710 Mini 的戴尔 R420,它在 RAID 5 中配置了 3 个 1TB 驱动器。我添加了另一个 1TB 驱动器,感谢戴尔讨论板的一些帮助,RAID 5 重新配置正确,现在有 2.47 TiB。我使用了众所周知的策略,即简单地打开 Gparted 并将现有分区滑到 1.9TB 并使用lvextend -r -l +100%FREE
命令将其移至那里。但是我们想将剩余的未分配磁盘空间用于我们的 /home 分区。
首先我遇到了这个错误:
parted ---pretend-input-tty /dev/sda resizepart 2 100%
Error: partition length of 5266759680 sectors exceeds the msdos-partition-table-imposed maximum of 4294967295
我在 SO 上找到了这个提示,它说要为未分配的磁盘空间创建一个新分区
我对此进行了测试,但一直在此错误中运行:
lvextend -L1844.1G /dev/mapper/fedora_newserver-home
Rounding size to boundary between physical extents: 1.80 TiB.
Insufficient free space: 214489 extents needed, but only 0 available
从教程:
注意,
-L
参数lvextend
表示的是Logical Volume的总大小,而不是Logical Volume的扩展量
我误解了这里的语法吗?您可以从fdisk
整个逻辑卷中看到 2.47 TB。我正在尝试将新的可用空间添加到主分区。
fdisk -l
Disk /dev/sda: 2.47 TiB, 2698581639168 bytes, 5270667264 sectors
Disk model: PERC H710
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa23c34a0
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 3907583 3905536 1.9G 83 Linux
/dev/sda2 3907584 4006645759 4002738176 1.9T 8e Linux LVM
另一个SF 建议有一个单行命令示例来实现我想要做的,但想看看是否有更首选的方式。
我在 Gparted 中删除了上面那个额外的分区,所以我可以再试一次。
按要求:
pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 fedora_newserver lvm2 a-- 1.86t 0
vgs
VG #PV #LV #SN Attr VSize VFree
fedora_newserver 1 5 0 wz--n- 1.86t 0
谢谢@NasirRiley!我不得不稍微修改你的指示。
pvcreate /dev/sda3
WARNING: ext4 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/sda3.
Physical volume "/dev/sda3" successfully created.
然后:
vgextend fedora_newserver /dev/sda3
Volume group "fedora_newserver" successfully extended
接下来,并没有完全得到我们整个未分配的空间:
lvextend -l +100%FREE /dev/mapper/fedora_newserver-home
Size of logical volume fedora_newserver/home changed from 1.21 TiB (317766 extents) to 1.80 TiB (472065 extents).
Logical volume fedora_newserver/home successfully resized.
下一条命令出错:
xfs_growfs /dev/mapper/fedora_newserver-home xfs_growfs: /dev/mapper/fedora_newserver-home is not a mounted XFS filesystem
然后:
lvdisplay | sed -n '/home/,/Size/p'
LV Path /dev/fedora_newserver/home
LV Name home
VG Name fedora_newserver
LV UUID j94360-O22L-
LV Write Access read/write
LV Creation host, time ourserver.edu, 2018-03-03 13:55:06 -0500
LV Status available
# open 1
LV Size 1.80 TiB
我们并不完全在那里:
df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 24G 4.0K 24G 1% /dev
tmpfs 24G 23M 24G 1% /dev/shm
tmpfs 24G 3.1M 24G 1% /run
/dev/mapper/fedora_newserver-root 280G 41G 240G 15% /
tmpfs 24G 4.2M 24G 1% /tmp
/dev/mapper/fedora_newserver-home 1.3T 859G 383G 70% /u/newserver
/dev/sda1 1.9G 256M 1.5G 15% /boot
/dev/mapper/fedora_newserver-var 187G 73G 114G 39% /var
/dev/mapper/fedora_newserver-usr_local 187G 58G 129G 32% /usr/local
这是最终奏效的方法:
lvextend -r -l +100%FREE /dev/mapper/fedora_neweserver-home
Size of logical volume fedora_newserver/home unchanged from 1.80 TiB (472065 extents).
Logical volume fedora_newserver/home successfully resized.
meta-data=/dev/mapper/fedora_newserver-home isize=512 agcount=7, agsize=48828160 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=0, rmapbt=0
= reflink=0
data = bsize=4096 blocks=325392384, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=95367, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 325392384 to 483394560
现在我们在那里:
df -h|grep home
/dev/mapper/fedora_newserver-home 1.9T 860G 985G 47% /u/newserver
不知道为什么 xfs 命令失败,我们显然在使用 XFS,也许它在 LVM 中?
来自blkid
:
/dev/mapper/fedora_newserver-home: LABEL="home" UUID="5aab1b3f-5cb5" TYPE="xfs"
好的,修改后的 XFS 命令不起作用:
xfs_growfs /home
xfs_growfs: /home is not a mounted XFS filesystem
呃,不得不使用实际的挂载点:
xfs_growfs /u/newserver
meta-data=/dev/mapper/fedora_newserver-home isize=512 agcount=10, agsize=48828160 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=0, rmapbt=0
= reflink=0
data = bsize=4096 blocks=483394560, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=95367, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0