This is an old revision of the document!

Mount RAW Pool Image with ZFS on Linux

Suppose you have backed up a ZFS pool with dd so you want to get some data from rpool.img now. Look at disk-image-mount-partition for more ways to mount patitions.


  1. Mount image as loop device
    # losetup /dev/loop0 rpool.img
  2. List partitions in loop
    # kpartx -l /dev/loop0
    loop0p1 : 0 44019712 /dev/loop0 2048
    loop0p9 : 0 16384 /dev/loop0 44021760
  3. Create device mappings of partitions
    # kpartx -av /dev/loop0
    add map loop0p1 (252:0): 0 44019712 linear 7:0 2048
    add map loop0p9 (252:1): 0 16384 linear 7:0 44021760
  4. Create mount point
    # mkdir /mnt/misa
  5. Try import the ZFS pool, but it will definitely fail because 1) my rpool.img is readonly 2) rpool is already used on my system
    # zpool import -R /mnt/misa -d /dev/mapper
       pool: rpool
         id: 3090542417815288870
      state: ONLINE
     status: Some supported features are not enabled on the pool.
     action: The pool can be imported using its name or numeric identifier, though
            some features will not be available without an explicit 'zpool upgrade'.
            rpool       ONLINE
              loop0     ONLINE
  6. With the id from previous result, we can import this pool with a new name misa
    # zpool import -o readonly=on -f -d /dev/mapper 3090542417815288870 misa -R /mnt/misa
  7. Done
    # zpool status
      pool: misa
     state: ONLINE
    status: Some supported features are not enabled on the pool. The pool can
            still be used, but some features are unavailable.
    action: Enable all features using 'zpool upgrade'. Once this is done,
            the pool may no longer be accessible by software that does not support
            the features. See zpool-features(5) for details.
      scan: none requested
            NAME        STATE     READ WRITE CKSUM
            misa        ONLINE       0     0     0
              loop0     ONLINE       0     0     0
    errors: No known data errors
    # zpool list
    misa   20.9G   716M  20.2G         -     0%     3%  1.00x  ONLINE  /mnt/misa
    # zfs list misa -r
    misa                 716M  19.5G    96K  /mnt/misa
    misa/ROOT            533M  19.5G    96K  none
    misa/ROOT/ubuntu     533M  19.5G   533M  /mnt/misa
    misa/home            996K  19.5G    96K  /mnt/misa/home
    misa/home/root       900K  19.5G   900K  /mnt/misa/root
    misa/srv              96K  19.5G    96K  /mnt/misa/srv
    misa/var             179M  19.5G    96K  /mnt/misa/var
    misa/var/cache       174M  19.5G   174M  /mnt/misa/var/cache
    misa/var/lib        3.81M  19.5G    96K  /mnt/misa/var/lib
    misa/var/lib/mysql  3.72M  19.5G  3.72M  /mnt/misa/var/lib/mysql
    misa/var/log        1.09M  19.5G  1.09M  /mnt/misa/var/log
    misa/var/spool        96K  19.5G    96K  /mnt/misa/var/spool
    misa/var/tmp         120K  19.5G   120K  /mnt/misa/var/tmp


  1. Export the pool
    # zpool export misa
  2. Disconnect the device map files using kpartx
    # kpartx -dv /dev/loop0
    del devmap : loop0p9
    del devmap : loop0p1
  3. Unload loop device
    # losetup -d /dev/loop0

See Alsos