prettyprint

2022年5月9日 星期一

Raspberry Pi 3 + FreeBSD + ZFS + iSCSI (Part 1)

實驗在Raspberry pi 3 B+上安裝FreeBSD作業系統,啟用ZFS檔案系統,比較ZFS dataset有使用壓縮(Compression)與副本(copies)屬性使用磁碟空間比較。另外建立一個ZFS Volume(Block device)作為iSCSI Target使用。以Windows系統連線iSCSI Target並格式化為NTFS。測試ZFS snapshot, rollback 等功能。 

一、下載Raspberry Pi的FreeBSD OS Image:

從FreeBSD官網下載作業系統映像檔,如下圖所示:

下載檔案:FreeBSD-13.0-RELEASE-arm64-aarch64-RPI.img.xz


二、使用Raspberry Pi Imager安裝作業系統到SD Card上:
  1. 從https://www.raspberrypi.com/software/下載Raspberry Pi Imager:
  2. 安裝FreeBSD Image:
    選用use custom選項,安裝剛剛下載的OS映像檔。

三、設定FreeBSD Static IP, nameserver, 與sshd允許遠端連線:

  1. static IP: 查看網路面卡名稱(ue0),編輯/etc/rc.conf加入
    ipconfig_ue0="inet x.x.x.x netmask x.x.x.x"
    defaultrouter="x.x.x.x"

  2. nameserver:編輯/etc/resolv.conf加入nameserver ip:

  3. sshd:編輯/etc/ssh/sshd_config更改permitRootLogin成yes

四、把外接USB硬碟加入ZFS pool:

啟用ZFS服務:
  1. 編輯/etc/rc.conf加入zfs_enable="YES"

  2. 執行service zfs start啟用zfs service
  3. 查看外接USB硬碟設備代號(da0),
    執行zpool create storage da0建立名稱為storage的zfs pool。

五、比較zfs dataset具有compression與copies屬性儲存空間的差異

  1. 分別建立storage/normal, storage/compress與storage/data三個filesystem,

  2. 設定storage/compress具有compression屬性
  3. 設定storage/data具有copies=2屬性,可把資料儲存兩份,增加可靠性
  4. 複製相同的資料到這三個檔案系統,查看使用硬碟空間的差異。



    六、建立iSCSI Target,使用Windows iSCSI Initiator 連線成為自己的硬碟

  1. 建立zfs volume(block device)作為iSCSI Target設備 zfs create -V 25G storage/iscsi01
  2. 編輯/etc/ctl.conf
    更改etc.conf權限,chmod 644 /etc/ctl.conf
    編輯/etc/rc.conf加入ctld_enable="YES"
    啟用service ctld start

  3. 啟用Windows iSCSI Initiator 連線iSCSI Target

  4. 使用Windoes disk managment格式化iSCSI 硬碟

七、zfs snapshot與rollback展示:

沒有留言:

張貼留言