所以我必須安裝一個加密的 zfs 分割區來修復我的電腦。我到處都找過了,但無法用我找到的資訊安裝它。每次我sudo zfs set mountpoint=/mnt/k/ rpool
這樣做都不會失敗,但我無法存取文件。如果我將它安裝在磁碟中,我會得到error mounting /dev/sda4 to /media/ubuntu/rpool2: unknown filesystem type zfs_member (udisk-error-quark, 0)
.該分割區很可能未安裝,因為它已加密。我該如何安裝它?
答案1
您可以使用下列範例工作流程來執行下列操作:
- 安裝 ZFS 並驗證安裝
- 從磁碟分割區找到並匯入 ZFS 池
- 設定所需 ZFS 池和/或資料集的掛載點
- 解密它們的 ZFS 池金鑰庫
- 掛載金鑰並將其載入到 ZFS 中
- 將 ZFS 池和/或資料集安裝到所需的點
ZFS_DISK='/dev/sdX'
ZFS_POOL_PARTITION='/dev/sdXn'
ZFS_POOL='rpool'
ZFS_POOL_DATASET='DATA' # 'ROOT' or 'USERDATA' for Ubuntu
MOUNTPOINT='/mnt'
# install zfs (using apt-get, yum, dnf, pacman, etc)
sudo apt-get install zfsutils-linux
sudo zfs --version
# locate zfs disk and pool
sudo lsblk -af "$ZFS_DISK"
sudo fdisk -l "$ZFS_DISK"
# create mountpoint directories for zfs pool and cipher key
sudo mkdir -p "$MOUNTPOINT"
sudo mkdir -p /zfskey
# import pool from partition
sudo zpool import -d "$ZFS_POOL_PARTITION" "$ZFS_POOL"
sudo zpool list
sudo zpool status -P "$ZFS_POOL"
# get and set the mountpoint for our zfs pool/dataset
# NOTE: mountpoints may collide with current filesystem,
# as mountpoints inherit from higher-level mountpoints
sudo zfs get mounted "$ZFS_POOL" -t filesystem -r
sudo zfs get mountpoint "$ZFS_POOL" -t filesystem -r
sudo zfs get mountpoint "$ZFS_POOL/$ZFS_POOL_DATASET" # BACKUP THIS VALUE
sudo zfs set mountpoint="$MOUNTPOINT" "$ZFS_POOL/$ZFS_POOL_DATASET"
# decrypt zfs keystore and load cipher key
sudo cryptsetup open "/dev/zvol/$ZFS_POOL/keystore" zfskey # creates /dev/dm-0 dm-1 dm-2
ls -l /dev/mapper/zfskey # /dev/mapper/zfskey -> /dev/dm-n
sudo cryptsetup -v status zfskey
sudo mount /dev/mapper/zfskey /zfskey
df -H
ls -l /zfskey
sudo cat /zfskey/system.key | sudo zfs load-key -L prompt "$ZFS_POOL"
# mount the decrypted pool and/or dataset
sudo zfs mount "$ZFS_POOL/$ZFS_POOL_DATASET"
sudo zfs list
ls -la "$MOUNTPOINT"
您的目錄現在應該已安裝並且可見。