ZFS thin provisioning / sparse ZVOL

简介:
zfs支持在zpool基础上创建块设备或volume.
这个volume同样拥有快照等zfs的功能.
正常情况下创建zvol时, -V指定的空间会直接从zpool中取出, 确保这个zvol可以使用指定的空间, 而不会导致空间溢出的问题.
[root@db- zp1]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        32G  3.7G   27G  13% /
tmpfs            16G     0   16G   0% /dev/shm
/dev/sda3       236G  188M  223G   1% /opt
zp1              29T  128K   29T   1% /zp1
[root@db- zp1]# zfs create -V 10TB zp1/vol1
[root@db- zp1]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        32G  3.7G   27G  13% /
tmpfs            16G     0   16G   0% /dev/shm
/dev/sda3       236G  188M  223G   1% /opt
zp1              19T  128K   19T   1% /zp1
[root@db- zp1]# ll /dev/zvol/zp1/vol1 
lrwxrwxrwx 1 root root 9 Jun 17 14:06 /dev/zvol/zp1/vol1 -> ../../zd0
[root@db- zp1]# ll /dev/zd0
brw-rw---- 1 root disk 230, 0 Jun 17 14:06 /dev/zd0

使用thin zvol的话, 甚至可以创建超出zpool大小的zvol, 有点类似EMC存储的thin provisioning卷
例如
[root@db- zp1]# zfs create -s -V 30TB zp1/vol2
[root@db- zp1]# zfs create -s -V 300TB zp1/vol3
[root@db- zp1]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        32G  3.7G   27G  13% /
tmpfs            16G     0   16G   0% /dev/shm
/dev/sda3       236G  188M  223G   1% /opt
zp1              19T  128K   19T   1% /zp1
非thin zvol不允许空间超出zpool的剩余空间.
[root@db- zp1]# zfs create -V 300TB zp1/vol4
cannot create 'zp1/vol4': out of space
[root@db-192-168-173-219 zp1]# zfs create -V 20TB zp1/vol4
cannot create 'zp1/vol4': out of space

[root@db- zp1]# ll /dev/zd*
brw-rw---- 1 root disk 230,  0 Jun 17 14:06 /dev/zd0
brw-rw---- 1 root disk 230, 16 Jun 17 14:08 /dev/zd16
brw-rw---- 1 root disk 230, 32 Jun 17 14:08 /dev/zd32
[root@db- zp1]# ll /dev/zvol/zp1/vol*
lrwxrwxrwx 1 root root  9 Jun 17 14:06 /dev/zvol/zp1/vol1 -> ../../zd0
lrwxrwxrwx 1 root root 10 Jun 17 14:08 /dev/zvol/zp1/vol2 -> ../../zd16
lrwxrwxrwx 1 root root 10 Jun 17 14:08 /dev/zvol/zp1/vol3 -> ../../zd32

[参考]
1. man zfs
       zfs create [-ps] [-b blocksize] [-o property=value] ... -V size volume

           Creates  a volume of the given size. The volume is exported as a block device in /dev/zvol/path, where path
           is the name of the volume in the ZFS namespace. The size represents the logical size  as  exported  by  the
           device. By default, a reservation of equal size is created.

           size is automatically rounded up to the nearest 128 Kbytes to ensure that the volume has an integral number
           of blocks regardless of blocksize.

           -p

               Creates all the non-existing parent datasets. Datasets created in this manner are automatically mounted
               according to the mountpoint property inherited from their parent. Any property specified on the command
               line using the -o option is ignored. If the target filesystem already exists, the  operation  completes
               successfully.

           -s

               Creates  a  sparse  volume  with  no reservation. See volsize in the Native Properties section for more
               information about sparse volumes.

           -o property=value

               Sets the specified property as if the zfs set property=value command was invoked at the same  time  the
               dataset  was  created.  Any editable ZFS property can also be set at creation time. Multiple -o options
               can be specified. An error results if the same property is specified in multiple -o options.

           -b blocksize

               Equivalent to -o volblocksize=blocksize. If this option is specified in conjunction with  -o  volblock-
               size, the resulting behavior is undefined.

       volsize=size

           For volumes, specifies the logical size of the volume. By default, creating a volume establishes a reserva-
           tion of equal size. For storage pools with a version number  of  9  or  higher,  a  refreservation  is  set
           instead.  Any  changes  to volsize are reflected in an equivalent change to the reservation (or refreserva-
           tion). The volsize can only be set to a multiple of volblocksize, and cannot be zero.

           The reservation is kept equal to the volume’s logical size to prevent unexpected  behavior  for  consumers.
           Without the reservation, the volume could run out of space, resulting in undefined behavior or data corrup-
           tion, depending on how the volume is used. These effects can also occur when the  volume  size  is  changed
           while  it  is in use (particularly when shrinking the size). Extreme care should be used when adjusting the
           volume size.

           Though not recommended, a "sparse volume" (also known as "thin provisioning") can be created by  specifying
           the  -s  option to the zfs create -V command, or by changing the reservation after the volume has been cre-
           ated. A "sparse volume" is a volume where the reservation is  less  then  the  volume  size.  Consequently,
           writes  to a sparse volume can fail with ENOSPC when the pool is low on space. For a sparse volume, changes
           to volsize are not reflected in the reservation.
目录
相关文章
|
人工智能 数据挖掘 机器人
【python】python智能停车场数据分析(代码+数据集)【独一无二】
【python】python智能停车场数据分析(代码+数据集)【独一无二】
|
Linux
【linux】find、xargs、grep 联合查找文件内容
【linux】find、xargs、grep 联合查找文件内容
671 1
|
存储 缓存 安全
virtiofs per-inode DAX 介绍
## 背景信息 1. 什么是 virtiofs? virtiofs 是一种用于在 host/guest 之间共享文件的文件系统,由 Redhat 开源,它使得不同 guest 之间能够以快速、一致、安全的方式共享同一个 host 目录树结构,目前广泛应用于 Kata Container 作为容器的 rootfs。 2. 什么是 DAX? DAX (Direct Access) 最初是针对于
3683 0
virtiofs per-inode DAX 介绍
|
6月前
|
机器学习/深度学习 人工智能 开发框架
智能体来了:零基础学习智能体,从入门到就业的系统路径
智能体来了,国内专注AI智能体教育与落地的品牌,为零基础者、转型者及企业提供系统化学习方案。涵盖认知入门、实操训练到项目实战,八大核心模块助力就业。赋能个人掌握AI技能,助力企业降本增效,推动智能体技术产业化应用。(238字)
629 1
|
4月前
|
机器学习/深度学习 人工智能 算法
Geo优化方法论评测:两大核心+四轮驱动的效能与价值评估
在AI主导的信息时代,于磊老师首创“两大核心+四轮驱动”Geo优化体系,以人性化内容与交叉验证构建数字信任,通过E-E-A-T、结构化表达、精准关键词及权威引用,实现AI友好、可持续的高效获客,已在金融、教育等多个行业验证显著成效。
212 2
|
安全 Linux 数据安全/隐私保护
docker运行报错docker: Error response from daemon: AppArmor enabled on system but the docker-default prof
docker运行报错docker: Error response from daemon: AppArmor enabled on system but the docker-default prof
1325 0
|
网络协议 Linux
在Linux中,如何分析网络连接和端口占用情况?
在Linux中,如何分析网络连接和端口占用情况?
|
安全 网络安全 数据安全/隐私保护
非对称加密的日常实践应用:以RSA加密为例
**RSA加密简介与Python实现** RSA,一种非对称加密技术,基于大数因子分解,用于数据加密和完整性保护。本文介绍了RSA基本原理,包括密钥生成(选取大质数p和q,计算n和φ(n),选择公钥指数e和私钥指数d),并展示了使用Python `cryptography` 库生成密钥对、加密和解密消息的代码示例。通过这些步骤,读者可理解RSA在网络安全中的应用,如HTTPS和数字签名。
1321 3
|
JSON JavaScript 前端开发
死磕Node模块兼容性,ESM和CJS我全都要!
死磕Node模块兼容性,ESM和CJS我全都要!
811 0