Storage: ZFS: Difference between revisions

From Proxmox VE
Jump to navigation Jump to search
No edit summary
 
(213 intermediate revisions by 16 users not shown)
Line 1: Line 1:
=zfs notes=
<!--PVE_IMPORT_START_MARKER-->
 
<!-- Do not edit - this is autogenerated content -->
==Native ZFS for Linux on Proxmox 2.0==
{{#pvedocs:pve-storage-zfspool-plain.html}}
*2012-02-25.  check  http://zfsonlinux.org/ .  looks like a solid project.
[[Category:Reference Documentation]]
 
<pvehide>
I had tried 3 other operating systems and for each was able to recover all the zfs  file systems from previous installs.  today I set up zfsonlinux using the following info on 2 prox 2.0 systems
Storage pool type: zfspool
 
This backend allows you to access local ZFS pools (or ZFS file systems
* Proxmox 2.0 rc1 install 
inside such pools).
 
Configuration
*install these
The backend supports the common storage properties content, nodes,
aptitude install build-essential gawk alien fakeroot zlib1g-dev uuid uuid-dev libssl-dev parted  pve-headers-$(uname -r)
disable, and the following ZFS specific properties:
*get make and install spl
pool
<pre>
Select the ZFS pool/filesystem. All allocations are done within that
cd /usr/src
pool.
git clone https://github.com/zfsonlinux/spl.git
blocksize
cd spl
Set ZFS blocksize parameter.
./configure
sparse
make deb
Use ZFS thin-provisioning. A sparse volume is a volume whose
sudo dpkg -i *.deb
reservation is not equal to the volume size.
modprobe spl
mountpoint
</pre>
The mount point of the ZFS pool/filesystem. Changing this does not
*get make and install zfs
affect the mountpoint property of the dataset seen by zfs.
<pre>
Defaults to /&lt;pool&gt;.
cd /usr/src
Configuration Example (/etc/pve/storage.cfg)
git clone https://github.com/zfsonlinux/zfs.git
zfspool: vmdata
cd zfs
        pool tank/vmdata
./configure
        content rootdir,images
make deb
        sparse
dpkg -i *.deb
File naming conventions
</pre>
The backend uses the following naming scheme for VM images:
 
vm-&lt;VMID&gt;-&lt;NAME&gt;     // normal VM images
modprobe zfs
base-&lt;VMID&gt;-&lt;NAME&gt;   // template VM image (read-only)
 
subvol-&lt;VMID&gt;-&lt;NAME&gt;  // subvolumes (ZFS filesystem for containers)
reboot to make sure modules load at boot
&lt;VMID&gt;
 
This specifies the owner VM.
 
&lt;NAME&gt;
*then import preexisting pool
This can be an arbitrary name (ascii) without white space. The
zpool  import -f tank
backend uses disk[N] as default, where [N] is replaced by an
 
integer to make the name unique.
df
Storage Features
<pre>
ZFS is probably the most advanced storage type regarding snapshot and
Filesystem    Type    Size  Used Avail Use% Mounted on
cloning. The backend uses ZFS datasets for both VM images (format
/dev/mapper/pve-root
raw) and container data (format subvol). ZFS properties are
              ext3    92G  1.1G  86G  2% /
inherited from the parent dataset, so you can simply set defaults
tmpfs        tmpfs    2.0G    0  2.0G  0% /lib/init/rw
on the parent dataset.
udev        tmpfs    2.0G  284K  2.0G  1% /dev
Table 1. Storage features for backend zfs
tmpfs        tmpfs    2.0G  3.1M  2.0G  1% /dev/shm
Content types
/dev/mapper/pve-data
Image formats
              ext3    256G  188M  255G  1% /var/lib/vz
Shared
/dev/sda1    ext3    495M  34M  436M  8% /boot
Snapshots
/dev/fuse    fuse    30M  12K  30M  1% /etc/pve
Clones
tank/bkup      zfs    3.0T  237G  2.7T  8% /bkup
images rootdir
tank/home      zfs    2.7T    0  2.7T  0% /export/home
raw subvol
tank/ht        zfs    2.9T  216G  2.7T  8% /export/ht
no
tank/data/home-fbc
yes
              zfs    2.7T  3.5G  2.7T  1% /home-fbc
yes
tank          zfs    2.7T    0  2.7T  0% /tank
Examples
tank/data     zfs    2.7T    0  2.7T  0% /tank/data
It is recommended to create an extra ZFS file system to store your VM images:
tank/data/u    zfs   2.7T  801M  2.7T  1% /u
# zfs create tank/vmdata
</pre>
To enable compression on that newly allocated file system:
 
# zfs set compression=on tank/vmdata
== How to install ZFS-fuse under Proxmox ==
You can get a list of available ZFS filesystems with:
 
# pvesm zfsscan
(Tested with Kernel 2.6.32)
See Also
 
Storage
  apt-get install build-essential libaio-dev libattr1-dev libacl1-dev libz-dev libz-dev libfuse-dev libfuse2 scons libssl-dev
ZFS on Linux
  wget -nd http://zfs-fuse.net/releases/0.6.0/zfs-fuse-0.6.0.tar.bz2
</pvehide>
  tar jxvf zfs-fuse-0.6.0.tar.bz2
<!--PVE_IMPORT_END_MARKER-->
  cd zfs-fuse-0.6.0
  cd src
  scons
  scond install
 
Fire up ZFS-fuse daemon
  /usr/local/sbin/zfs-fuse
 
Create Zpool
  zpool create -m /var/lib/vz/images2 /dev/sdb
 
Create ZFS
  zfs create images2/109
 
ZFS clone a vm 109 to vm 110
  zfs snapshot images2/109@master
  zfs clone images2/109@master images2/110
 
== Debian GNU/kFreeBSD ==
'''As of 2012-02 the squeeze version does not have NFS, so AFAIK can not be used for Proxmox storage.''' When  Debsd has nfs support then I'd use this for storage of iso's and backups to start.  In the mean time this works as a samba server..
 
zfs works much better using  Debian/GNU kFreeBSD  then fuse.
 
after installing the system to kvm or hardware:
 
*add some disks .  in KVM i was only able to get ide to work.
 
*the scsi disks look like:
<pre>
ls /dev/ad*
/dev/ad10  /dev/ad10s1  /dev/ad10s2  /dev/ad11  /dev/ad12  /dev/ad13
</pre>
 
*  per http://www.solarisinternals.com/wiki/index.php/ZFS_Best_Practices_Guide  - if I read it right - use entire disk not slices for zfs (I assume slices = partitions).
 
*if the disks have partition tables, then clear them. just not the operating system disk!  I used fdisk to clear the tables. This may not be necessary , if it is not then please delete this part.
<pre>
fdisk /dev/ad11
o
w
</pre>
then same for ad12 and ad13
 
*install this
aptitude install zfsutils
 
*make a pool
zpool create -f  zfs-pool /dev/ad11 /dev/ad12  /dev/ad13
 
df | grep zfs-pool
zfs-pool      zfs    1.4T  18K  1.4T  1% /zfs-pool
 
===links===
*http://wiki.debian.org/Debian_GNU/kFreeBSD

Latest revision as of 08:08, 6 December 2019

Storage pool type: zfspool

This backend allows you to access local ZFS pools (or ZFS file systems inside such pools).

Configuration

The backend supports the common storage properties content, nodes, disable, and the following ZFS specific properties:

pool

Select the ZFS pool/filesystem. All allocations are done within that pool.

blocksize

Set ZFS blocksize parameter.

sparse

Use ZFS thin-provisioning. A sparse volume is a volume whose reservation is not equal to the volume size.

mountpoint

The mount point of the ZFS pool/filesystem. Changing this does not affect the mountpoint property of the dataset seen by zfs. Defaults to /<pool>.

Configuration Example (/etc/pve/storage.cfg)
zfspool: vmdata
        pool tank/vmdata
        content rootdir,images
        sparse

File naming conventions

The backend uses the following naming scheme for VM images:

vm-<VMID>-<NAME>      // normal VM images
base-<VMID>-<NAME>    // template VM image (read-only)
subvol-<VMID>-<NAME>  // subvolumes (ZFS filesystem for containers)
<VMID>

This specifies the owner VM.

<NAME>

This can be an arbitrary name (ascii) without white space. The backend uses disk[N] as default, where [N] is replaced by an integer to make the name unique.

Storage Features

ZFS is probably the most advanced storage type regarding snapshot and cloning. The backend uses ZFS datasets for both VM images (format raw) and container data (format subvol). ZFS properties are inherited from the parent dataset, so you can simply set defaults on the parent dataset.

Table 1. Storage features for backend zfs
Content types Image formats Shared Snapshots Clones

images rootdir

raw subvol

no

yes

yes

Examples

It is recommended to create an extra ZFS file system to store your VM images:

# zfs create tank/vmdata

To enable compression on that newly allocated file system:

# zfs set compression=on tank/vmdata

You can get a list of available ZFS filesystems with:

# pvesm zfsscan