|
|
(135 intermediate revisions by 15 users not shown) |
Line 1: |
Line 1: |
| =Native ZFS for Linux on Proxmox 2.0=
| | <!--PVE_IMPORT_START_MARKER--> |
| *2012-02-25. check http://zfsonlinux.org/ See the Documentation and Community Resources for more information and help.
| | <!-- Do not edit - this is autogenerated content --> |
|
| | {{#pvedocs:pve-storage-zfspool-plain.html}} |
| I had tried 3 other operating systems including Debian/kFreebsd and for each was able to recover all the zfs file systems from previous installs. Even with disk name changes [bsd uses ad11, linux sdb ] no data was lost. Today I set up zfsonlinux using the following info on 2 prox 2.0 systems
| | [[Category:Reference Documentation]] |
| | | <pvehide> |
| == using dkms ==
| | Storage pool type: zfspool |
| <pre> | | This backend allows you to access local ZFS pools (or ZFS file systems |
| # apt key
| | inside such pools). |
| apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F6B0FC61
| | Configuration |
| | | The backend supports the common storage properties content, nodes, |
| #sources:
| | disable, and the following ZFS specific properties: |
| echo "deb http://ppa.launchpad.net/zfs-native/stable/ubuntu lucid main" > /etc/apt/sources.list.d/zfs.list
| | pool |
| | | Select the ZFS pool/filesystem. All allocations are done within that |
| aptitude update
| | pool. |
| | | blocksize |
| aptitude install dkms pve-headers-$(uname -r)
| | Set ZFS blocksize parameter. |
| </pre>
| | sparse |
| | | Use ZFS thin-provisioning. A sparse volume is a volume whose |
| *this is needed for dkms to work:
| | reservation is not equal to the volume size. |
| <pre>
| | mountpoint |
| ln -s /lib/modules/2.6.32-10-pve/build /lib/modules/2.6.32-10-pve/source
| | The mount point of the ZFS pool/filesystem. Changing this does not |
| </pre>
| | affect the mountpoint property of the dataset seen by zfs. |
| '''Maybe someone who knows how to write a patch could submit one and suggest this be done when kernel is upgraded?''' Otherwise I think when the Proxmox kernel upgrades, dkms build may fail if this is not done [ using new pve-headers ).
| | Defaults to /<pool>. |
| | | Configuration Example (/etc/pve/storage.cfg) |
| | | zfspool: vmdata |
| then install zfs
| | pool tank/vmdata |
| <pre> | | content rootdir,images |
| aptitude install ubuntu-zfs
| | sparse |
| </pre>
| | File naming conventions |
| | | The backend uses the following naming scheme for VM images: |
| === kernel upgrade ===
| | vm-<VMID>-<NAME> // normal VM images |
| currently this needs to be done when a kernel upgrade occurs.
| | base-<VMID>-<NAME> // template VM image (read-only) |
| *'''before reboot''':
| | subvol-<VMID>-<NAME> // subvolumes (ZFS filesystem for containers) |
| :2.6.32.11 upgrade from 2.6.32.10 did before reboot [ for you would need to change 2.6.32-11-pve if different version.
| | <VMID> |
| aptitude install pve-headers-2.6.32-11-pve
| | This specifies the owner VM. |
| ln -s /lib/modules/2.6.32-11-pve/build /lib/modules/2.6.32-11-pve/source
| | <NAME> |
| | | This can be an arbitrary name (ascii) without white space. The |
| *this will force modules to be built ( there is probably a better way to do this , so correct this if you know how to make dkms do the build ).
| | backend uses disk[N] as default, where [N] is replaced by an |
| aptitude reinstall spl-dkms zfs-dkms
| | integer to make the name unique. |
| | | Storage Features |
| == using git ==
| | ZFS is probably the most advanced storage type regarding snapshot and |
| *install these
| | cloning. The backend uses ZFS datasets for both VM images (format |
| aptitude install build-essential gawk alien fakeroot zlib1g-dev uuid uuid-dev libssl-dev parted pve-headers-$(uname -r)
| | raw) and container data (format subvol). ZFS properties are |
| *get make and install spl
| | inherited from the parent dataset, so you can simply set defaults |
| <pre>
| | on the parent dataset. |
| cd /usr/src
| | Table 1. Storage features for backend zfs |
| git clone https://github.com/zfsonlinux/spl.git
| | Content types |
| cd spl
| | Image formats |
| ./configure
| | Shared |
| make deb
| | Snapshots |
| dpkg -i *.deb
| | Clones |
| modprobe spl
| | images rootdir |
| </pre>
| | raw subvol |
| *get make and install zfs
| | no |
| <pre>
| | yes |
| cd /usr/src
| | yes |
| git clone https://github.com/zfsonlinux/zfs.git
| | Examples |
| cd zfs
| | It is recommended to create an extra ZFS file system to store your VM images: |
| ./configure | | # zfs create tank/vmdata |
| make deb
| | To enable compression on that newly allocated file system: |
| dpkg -i *.deb
| | # zfs set compression=on tank/vmdata |
| </pre>
| | You can get a list of available ZFS filesystems with: |
| | | # pvesm zfsscan |
| * make sure module can load
| | See Also |
| modprobe zfs
| | Storage |
| | | ZFS on Linux |
| * install debs does not do this:
| | </pvehide> |
| update-rc.d zfs defaults
| | <!--PVE_IMPORT_END_MARKER--> |
| | |
| *'''note , the deb files made above can be used to install zfs on another system'''.
| |
| | |
| *if there is a pre existing zfs pool then simply use the next line to recover it. this can happen if you re-install proxmox and have zfs disks from before.
| |
| zpoo </cman>
| |
| | |
| | |
| *If there is a need or want I could set up a repository with pre build debs. Just send an email .
| |
| | |
| =Creating Pools and Filesystems=
| |
| '''use raidz2 or mirror in main data systems.'''
| |
| | |
| ==Create a raidz pool named “tank”==
| |
| zpool create -f -o ashift=12 tank raidz /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh
| |
| | |
| *note this happened to 2 or 3 disks the 1-st time. these were disks from a 3-ware raid.
| |
| <pre>
| |
| zpool create -f -o ashift=12 tank raidz2 /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh
| |
| invalid vdev specification
| |
| the following errors must be manually repaired: | |
| cannot stat /dev/sdg2: No such file or directory
| |
| </pre>
| |
| had to use fdisk to add partitions 1 , 2 etc to those disks . I forget if I left the partitions there or not. but had to add to get this fixed.
| |
| <blockquote>
| |
| '''''NOTE''': This is quite risky if you intend to deploy ZFS on a server. Any changes to the operating system's devices layout will break your pool. Don't create a pool using device names like ''<code>/dev/sda</code>''. For persistence, use devices under ''<code>/dev/disk/by-id</code>''.'' - [[User:Bryan Baldwin|Bryan Baldwin]]
| |
| </blockquote>
| |
| | |
| ==Create directories and mount points==
| |
| <pre>
| |
| zfs create tank/data
| |
| zfs set mountpoint=/data tank/data
| |
| </pre>
| |
| | |
| *mount all
| |
| zfs mount -a
| |
| | |
| ==destroy==
| |
| to start over
| |
| zpool destroy zfs-pool
| |
| | |
| ==Setting Properties==
| |
| *Automatically NFS-export all home directories [ I do not know how to use zfs nfs yet , or if it works yet in linux...].
| |
| zfs set sharenfs=rw tank/home
| |
| *check sharenfs
| |
| <pre>
| |
| zfs get sharenfs tank/home
| |
| NAME PROPERTY VALUE SOURCE
| |
| tank/home sharenfs rw local
| |
| </pre>
| |
| *Turn on compression for everything in the pool
| |
| zfs set compression=on tank
| |
| | |
| == kvm tuning==
| |
| see thread on prox forum , per user Nemesiz :
| |
| *pool:
| |
| zfs set primarycache=all tank
| |
| *kvm config:
| |
| * change cache to Write Back
| |
| :You can do it using web GUI or manually. Example:
| |
| ide0: data_zfs:100/vm-100-disk-1.raw,cache=writeback
| |
| if not set this happened:
| |
| <pre>
| |
| qm start 4016
| |
| kvm: -drive file=/data/pve-storage/images/4016/vm-4016-disk-1.raw,if=none,id=drive-virtio1,aio=native,cache=none: could not open disk image /data/pve-storage/images/4016/vm-4016-disk-1.raw: Invalid argument
| |
| </pre>
| |
| | |
| =zfs links and docs=
| |
| *http://zfsonlinux.org/faq.html
| |
| | |
| *http://hub.opensolaris.org/bin/download/Community+Group+zfs/docs/zfslast.pdf
| |
| | |
| and this has some very important information to know before implementing zfs on a production system.
| |
| *http://www.solarisinternals.com/wiki/index.php/ZFS_Best_Practices_Guide
| |
| | |
| check these well written manual pages:
| |
| man zfs
| |
|
| |
| man zpool
| |
| | |
| = How to install ZFS-fuse under Proxmox =
| |
| | |
| (Tested with Kernel 2.6.32) | |
| | |
| apt-get install build-essential libaio-dev libattr1-dev libacl1-dev libz-dev libz-dev libfuse-dev libfuse2 scons libssl-dev
| |
| wget -nd http://zfs-fuse.net/releases/0.6.0/zfs-fuse-0.6.0.tar.bz2
| |
| tar jxvf zfs-fuse-0.6.0.tar.bz2
| |
| cd zfs-fuse-0.6.0
| |
| cd src
| |
| scons
| |
| scond install
| |
| | |
| '''Note:''' zfs-fuse-0.6.0 is now (Dec 2012) deprecated. Use [http://zfs-fuse.net/releases/0.7.0/zfs-fuse-0.7.0.tar.bz2 zfs-fuse-0.7.0.tar.bz2] instead.
| |
| | |
| 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
| |
| | |
| *http://wiki.debian.org/Debian_GNU/kFreeBSD
| |