我在内核 2.6.32-431.11.2.el6.x86_64 下的 Linux 上有一个 ZFS zpool,它有一个 vdev。vdev 是一个 SAN 设备。我扩展了 SAN 的大小,尽管 zpool 已autoexpand
设置为on
,即使在重新启动机器、导出/导入池并使用zpool online -e
之后,我也无法扩展池。我确信 vdev 更大,因为fdisk
它显示它已从 215GiB 增加到 250GiB。这是我所做的一个示例:
[root@timestandstill ~]# zpool list
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
dfbackup 214G 207G 7.49G 96% 1.00x ONLINE -
[root@timestandstill ~]# zpool import -d /dev/disk/by-id/
pool: dfbackup
id: 12129781223864362535
state: ONLINE
action: The pool can be imported using its name or numeric identifier.
config:
dfbackup ONLINE
virtio-sbs-XLPH83 ONLINE
[root@timestandstill ~]# zpool import -d /dev/disk/by-id/ dfbackup
[root@timestandstill ~]# zpool list
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
dfbackup 214G 207G 7.49G 96% 1.00x ONLINE -
venuebackup 248G 244G 3.87G 98% 1.00x ONLINE -
[root@timestandstill ~]# zpool get autoexpand dfbackup
NAME PROPERTY VALUE SOURCE
dfbackup autoexpand on local
[root@timestandstill ~]# zpool set autoexpand=off dfbackup
[root@timestandstill ~]# zpool set autoexpand=on dfbackup
[root@timestandstill ~]# zpool list
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
dfbackup 214G 207G 7.49G 96% 1.00x ONLINE -
venuebackup 248G 244G 3.87G 98% 1.00x ONLINE -
[root@timestandstill ~]# zpool status -v dfbackup
pool: dfbackup
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
dfbackup ONLINE 0 0 0
virtio-sbs-XLPH83 ONLINE 0 0 0
errors: No known data errors
[root@timestandstill ~]# fdisk /dev/disk/by-id/virtio-sbs-XLPH83
WARNING: GPT (GUID Partition Table) detected on '/dev/disk/by-id/virtio-sbs-XLPH83'! The util fdisk doesn't support GPT. Use GNU Parted.
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/disk/by-id/virtio-sbs-XLPH83: 268.4 GB, 268435456000 bytes
256 heads, 63 sectors/track, 32507 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/disk/by-id/virtio-sbs-XLPH83-part1 1 27957 225443839+ ee GPT
Command (m for help): q
[root@timestandstill ~]# zpool online -e dfbackup /dev/disk/by-id/virtio-sbs-XLPH83
[root@timestandstill ~]# zpool list
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
dfbackup 214G 207G 7.49G 96% 1.00x ONLINE -
venuebackup 248G 244G 3.87G 98% 1.00x ONLINE -
[root@timestandstill ~]# zpool status -v dfbackup
pool: dfbackup
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
dfbackup ONLINE 0 0 0
virtio-sbs-XLPH83 ONLINE 0 0 0
errors: No known data errors
如何扩展这个 zpool?
我在 Ubuntu 16.04 上运行 ZFS,经过多次试验和错误,这就是在不重新启动的情况下扩展磁盘和池大小的方法。我的系统托管在 Profitbricks 的云中,并使用 libvirt(不是 SCSI)驱动器。
获取池和设备详细信息:
激活自动扩展:
现在登录到 Profitbricks 控制面板并将磁盘大小从 40GB 增加到 50GB。
通知系统磁盘大小更改和扩展池:
我不确定为什么,但有时需要运行
partprobe
和/或zpool online -e pool vdb
两次才能使更改生效。我在freebsd 论坛上阅读了一篇建议使用的帖子
zpool online -e <pool> <vdev>
(无需先使 vdev 脱机)这最终是解决方案,但它要求首先禁用 ZFS 自动扩展:
在 Linux 上使用 ZFS(在内核中,不使用 FUSE)需要使用
zpool set autoexpand=off
后跟zpool online -e
来让 zpool 为我扩展