我已经设置了一个带有 debian buster 和 ZFS 的虚拟机。最初,机器从第一个硬盘启动,但添加了 x4 20Gb 硬盘并将系统转移到 zfs 以进行测试。
它有效,所以我添加了一些数据集来查看它如何增长。但是当查询已用/可用空间时,它没有显示实际数字。似乎什么也没发生。还测试了达到配额,结果是一样的,
我做错了什么?
谢谢。
磁盘布局
root@debzfs:~# fdisk -l | grep sd | sort
/dev/sda1 2048 40892415 40890368 19.5G Solaris /usr & Apple ZFS
/dev/sda9 40892416 41943006 1050591 513M BIOS boot
/dev/sdb1 2048 40892415 40890368 19.5G Solaris /usr & Apple ZFS
/dev/sdb9 40892416 41943006 1050591 513M BIOS boot
/dev/sdc1 2048 40892415 40890368 19.5G Solaris /usr & Apple ZFS
/dev/sdc9 40892416 41943006 1050591 513M BIOS boot
/dev/sdd1 2048 40892415 40890368 19.5G Solaris /usr & Apple ZFS
/dev/sdd9 40892416 41943006 1050591 513M BIOS boot
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk /dev/sdc: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk /dev/sdd: 20 GiB, 21474836480 bytes, 41943040 sectors
根池和数据集(原始系统已复制到此位置)
zpool create -d -o feature@async_destroy=enabled -o feature@empty_bpobj=enabled -o feature@lz4_compress=enabled -o ashift=12 -O compression=lz4 rpool raidz2 /dev/sd[a-d]1 -f
zfs create rpool/root
zfs set quota=10gb rpool/root
# The new datasets
zfs create rpool/smalldb
zfs set quota=5gb rpool/smalldb
zfs create rpool/greatdb
zfs set quota=20gb rpool/greatdb
创建数据集后的当前磁盘布局
root@debzfs:~# zpool status
pool: rpool
state: ONLINE
status: Some supported features are not enabled on the pool. The pool can
still be used, but some features are unavailable.
action: Enable all features using 'zpool upgrade'. Once this is done,
the pool may no longer be accessible by software that does not support
the features. See zpool-features(5) for details.
scan: none requested
config:
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
raidz2-0 ONLINE 0 0 0
sda1 ONLINE 0 0 0
sdb1 ONLINE 0 0 0
sdc1 ONLINE 0 0 0
sdd1 ONLINE 0 0 0
errors: No known data errors
root@debzfs:~# zpool list
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
rpool 77.5G 3.04G 74.5G - - 3% 1.00x ONLINE -
root@debzfs:~# zfs list
NAME USED AVAIL REFER MOUNTPOINT
rpool 1.47G 34.9G 244K /rpool
rpool/greatdb 198K 20.0G 198K /rpool/greatdb
rpool/root 1.47G 8.53G 1.47G /
rpool/smalldb 198K 5.00G 198K /rpool/smalldb
测试命令和输出(错误)。预期当前大小和可用空间。但似乎什么也没发生。
truncate -s 2G /rpool/smalldb/smalldb.log
truncate -s 8G /rpool/smalldb/limitdb.log #what ? if ls the file is there !!
truncate -s 10G /rpool/greatdb/greatdb.log
root@debzfs:~# zpool list
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
rpool 77.5G 3.03G 74.5G - - 3% 1.00x ONLINE -
root@debzfs:~# zfs list
NAME USED AVAIL REFER MOUNTPOINT
rpool 1.47G 34.9G 244K /rpool
rpool/greatdb 209K 20.0G 209K /rpool/greatdb
rpool/root 1.47G 8.53G 1.47G /
rpool/smalldb 209K 5.00G 209K /rpool/smalldb
root@debzfs:~# ls -lh /rpool/smalldb/ /rpool/greatdb/
/rpool/greatdb/:
total 512
-rw-r--r-- 1 root root 10G Nov 4 00:11 greatdb.log
/rpool/smalldb/:
total 1.0K
-rw-r--r-- 1 root root 8.0G Nov 4 00:14 limitdb.log
-rw-r--r-- 1 root root 2.0G Nov 4 00:09 smalldb.log
root@debzfs:~#
答案1
不要使用截断。这会创建一个充满空字节的文件。空字节不会占用任何磁盘空间,该文件是稀疏文件。當然/dev/zero
也。
使用任何其他方法。dd
或者head
您喜欢的 python 脚本。但不要创建稀疏文件。