cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

middleware:container:lxd:zfs.html



LXD CLI Commands Cheet Sheat

Using LXD with ZFS pool on Ubuntu

What is ZFS?


Installation

$ sudo apt install zfsutils-linux

check the ZFS pool

$ sudo zpool list
NAME   SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
lxd   29.8G   253M  29.5G         -     0%     0%  1.00x  ONLINE  -
$ sudo zpool status
  pool: lxd
 state: ONLINE
  scan: none requested
config:

        NAME                    STATE     READ WRITE CKSUM
        lxd                     ONLINE       0     0     0
          /var/lib/lxd/zfs.img  ONLINE       0     0     0

errors: No known data errors


Operation

How to create zfs pool

$ sudo zpool create POOL mirror DEVICE1 DEVICE2
$ sudo zpool create POOL raidz  DEVICE1 DEVICE2
$ sudo zpool create POOL raidz1  DEVICE1 DEVICE2
$ sudo zpool create POOL raidz2  DEVICE1 DEVICE2
$ sudo zpool create POOL raidz3  DEVICE1 DEVICE2
$ sudo zpool create POOL raidz3  DEVICE1 DEVICE2  cache DEVICE3
Example
$ sudo mke2fs -t ext4 /dev/sdb1
$ sudo mke2fs -t ext4 /dev/sdc1

$ sudo zpool create tank  mirror /dev/sdb1 /dev/sdc1

$ ## After making the pool, it will be mounted automatically.
$ mount    <- check mount

How to umount zfs pool

$ sudo zfs unmount rpool

How to delete zfs pool

$ sudo zpool destroy rpool

How to change mount point

$ sudo zfs umount tank
$ sudo mkdir /mnt/sub
$ sudo zfs set mountpoint=/mnt/sub tank
$ sudo zfs mount tank

How to enable duplicate

$ zfs set dedup=on tank

How to resize

sudo truncate -s 50G /var/lib/lxd/zfs.img


ZFS Configuration

How to check ZFS Configuration

$ sudo zfs get all rpool

How to enable autoexpand

zfs autoexpand is enabled (only needed once)

root@lxd-host:~# zfs list
NAME   USED  AVAIL  REFER  MOUNTPOINT
lxd    244K  14.4G    19K  none
root@lxd-host:~# 
root@lxd-host:~# 
root@lxd-host:~# zpool get autoexpand lxd
NAME  PROPERTY    VALUE   SOURCE
lxd   autoexpand  off     default
root@lxd-host:~# 
root@lxd-host:~# 
root@lxd-host:~# zpool set autoexpand=on lxd
root@lxd-host:~# 
root@lxd-host:~# zpool get autoexpand lxd
NAME  PROPERTY    VALUE   SOURCE
lxd   autoexpand  on      local
root@lxd-host:~# 

mountpoint

root@lxd-host:~# zfs get mountpoint
NAME                                                                                  PROPERTY    VALUE                                                                                     SOURCE
lxd                                                                                   mountpoint  none                                                                                      local
lxd/containers                                                                        mountpoint  none                                                                                      inherited from lxd
lxd/containers/centos7-1                                                              mountpoint  /var/lib/lxd/containers/centos7-1.zfs                                                     local
lxd/images                                                                            mountpoint  none                                                                                      inherited from lxd
lxd/images/41c7bb494bbdf71c2aee471bb44a2318fd3424a0cd22091fb896a7614ae545eb           mountpoint  /var/lib/lxd/images/41c7bb494bbdf71c2aee471bb44a2318fd3424a0cd22091fb896a7614ae545eb.zfs  local
lxd/images/41c7bb494bbdf71c2aee471bb44a2318fd3424a0cd22091fb896a7614ae545eb@readonly  mountpoint  -                                                                                         -
root@lxd-host:~# ls -l /var/lib/lxd/containers/centos7-1.zfs
root@lxd-host:~# ls -l /var/lib/lxd/containers/centos7-1.zfs
total 3
-rw-r--r--  1 root   root   676 Jan  1  1970 metadata.yaml
dr-xr-xr-x 18 100000 100000  23 Jun 28 10:59 rootfs
drwxr-xr-x  2 root   root     4 Jun 28 10:58 templates
root@lxd-host:~# 

root@lxd-host:/var/lib/lxd# df -h |grep lxd
lxd/images/41c7bb494bbdf71c2aee471bb44a2318fd3424a0cd22091fb896a7614ae545eb   15G  210M   15G   2% /var/lib/lxd/images/41c7bb494bbdf71c2aee471bb44a2318fd3424a0cd22091fb896a7614ae545eb.zfs
lxd/containers/centos7-1                                                      15G  209M   15G   2% /var/lib/lxd/containers/centos7-1.zfs
root@lxd-host:/var/lib/lxd# 


LXD CLI Commands Cheet Sheat





LXD CLI Commands Cheet Sheat




middleware/container/lxd/zfs.html.txt · Last modified: 2020/03/25 by admin

Page Tools