Memory Drive

반응형

개요

  • 국내에서 제법 저렴한 호스팅 서비스인 iwinv에서 제공하는 서비스 활용법중에 하나...
  • 기본적으로 iwinv 에서 제공하는 blockstorage를 이용하여 zfs 파일 시스템을 생성할수 있다. 기본 가이드는 lvm을 이용하는것으로 가이드 하지만 zfs도 생성 가능
  • cpu를 조금 더 사용하여 파일시스템 사용 효율을 극대화 할수 있다.
    zfs활용예시
  • 설치는 openzfs 가 아닌 apt로 간단히 설치

기본으로 vm-lite (ubuntu 20버전) 과 blockstorage(예제로50GB) 생성

기본 파일시스템 확인

root@helloworld-139867:~# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  223M     0  223M   0% /dev
tmpfs          tmpfs      48M  992K   47M   3% /run
/dev/vda1      ext4       25G  2.0G   23G   8% /
tmpfs          tmpfs     239M     0  239M   0% /dev/shm
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs     239M     0  239M   0% /sys/fs/cgroup
/dev/vda15     vfat      105M  6.6M   98M   7% /boot/efi
/dev/loop0     squashfs   55M   55M     0 100% /snap/core18/1705
/dev/loop1     squashfs   69M   69M     0 100% /snap/lxd/14804
/dev/loop2     squashfs   28M   28M     0 100% /snap/snapd/7264
/dev/loop3     squashfs   33M   33M     0 100% /snap/snapd/12704
/dev/loop4     squashfs   56M   56M     0 100% /snap/core18/2074
tmpfs          tmpfs      48M     0   48M   0% /run/user/0
/dev/loop5     squashfs   62M   62M     0 100% /snap/core20/1081
/dev/loop6     squashfs   69M   69M     0 100% /snap/lxd/21260

vm접속후 확인

root@helloworld-139867:~# fdisk -l
...
...
...
Device      Start      End  Sectors  Size Type
/dev/vda1  227328 52428766 52201439 24.9G Linux filesystem
/dev/vda14   2048    10239     8192    4M BIOS boot
/dev/vda15  10240   227327   217088  106M EFI System

Partition table entries are not in disk order.


Disk /dev/vdb: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

zfs 패키지 설치

root@helloworld-139867:~# apt install zfsutils-linux

...
...
...

설치확인

root@helloworld-139867:~# which zfs
/usr/sbin/zfs
root@helloworld-139867:~# whereis zfs
zfs: /usr/sbin/zfs /etc/zfs /usr/share/man/man8/zfs.8.gz

blockstorage를 pool로 생성

root@helloworld-139867:~# lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0     7:0    0   55M  1 loop /snap/core18/1705
loop1     7:1    0   69M  1 loop /snap/lxd/14804
loop2     7:2    0 27.1M  1 loop /snap/snapd/7264
loop3     7:3    0 32.3M  1 loop /snap/snapd/12704
loop4     7:4    0 55.5M  1 loop /snap/core18/2074
loop5     7:5    0 61.8M  1 loop /snap/core20/1081
loop6     7:6    0 68.3M  1 loop /snap/lxd/21260
vda     252:0    0   25G  0 disk 
vda1  252:1    0 24.9G  0 part /
vda14 252:14   0    4M  0 part 
vda15 252:15   0  106M  0 part /boot/efi
vdb     252:16   0   50G  0 disk

-- ( vdb 가 block storage disk )


-- 생성
root@helloworld-139867:~# zpool create zfspool vdb

zfs pool 생성 확인

root@helloworld-139867:~# zpool list
NAME      SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
zfspool  49.5G   110K  49.5G        -         -     0%     0%  1.00x    ONLINE  -

생성된 pool 에 기본적으로 압축 설정

root@helloworld-139867:~# zfs get compression
zfspool  compression  off       local
root@helloworld-139867:~# zfs set compression=lz4 zfspool
root@helloworld-139867:~# zfs get compression
NAME     PROPERTY     VALUE     SOURCE
zfspool  compression  lz4       local

pool로 부터 파일시스템 생성

root@helloworld-139867:~#  zfs create -o mountpoint=/data01 -o compression=lz4 zfspool/data01
root@helloworld-139867:~# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  223M     0  223M   0% /dev
tmpfs          tmpfs      48M 1004K   47M   3% /run
/dev/vda1      ext4       25G  2.0G   23G   8% /
tmpfs          tmpfs     239M     0  239M   0% /dev/shm
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs     239M     0  239M   0% /sys/fs/cgroup
/dev/vda15     vfat      105M  6.6M   98M   7% /boot/efi
/dev/loop0     squashfs   55M   55M     0 100% /snap/core18/1705
/dev/loop1     squashfs   69M   69M     0 100% /snap/lxd/14804
/dev/loop2     squashfs   28M   28M     0 100% /snap/snapd/7264
/dev/loop3     squashfs   33M   33M     0 100% /snap/snapd/12704
/dev/loop4     squashfs   56M   56M     0 100% /snap/core18/2074
tmpfs          tmpfs      48M     0   48M   0% /run/user/0
/dev/loop5     squashfs   62M   62M     0 100% /snap/core20/1081
/dev/loop6     squashfs   69M   69M     0 100% /snap/lxd/21260
zfspool        zfs        48G  128K   48G   1% /zfspool
zfspool/data01 zfs        48G  128K   48G   1% /data01
  • /data01 파일시스템이 zfs로 생성된것 확인

압축 테스트

  • 50G 스토리지,파일시스템에 100G Dummy파일 생성 테스트
cd /data01
root@helloworld-139867:/data01# dd if=/dev/zero of=./100Gfile bs=1 count=0 seek=100G
0+0 records in
0+0 records out
0 bytes copied, 0.00013683 s, 0.0 kB/s

root@helloworld-139867:/data01# ls -alrth
total 5.0K
drwxr-xr-x 21 root root 4.0K Aug 10 15:07 ..
-rw-r--r--  1 root root 100G Aug 10 15:19 100Gfile
drwxr-xr-x  2 root root    3 Aug 10 15:19 .

root@helloworld-139867:/data01# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
....
zfspool/data01 zfs        48G  128K   48G   1% /data01
반응형