This tutorial is out-of-date and will be updated when I get ZFS working again on the Pinebook Pro.

The Pinebook Pro comes with a small amount of internal disk space, only 64 GB. While this is upgradeable to 128 GB, that still isn’t enough for those with large media collections. The easiest solution is to use a microSD card. And now you’re just dying to use ZFS on that, right?

Tutorial

Following the previous post, Install ZFS on the Pinebook Pro, this tutorial describes the steps required to setup a microSD card for your music files with ZFS on the Pinebook Pro.

Create the Pool

The microSD card will need to be provisioned as its own pool using ZFS. Adding the disk to a pool places it under the control of ZFS, providing all of the necessary ZFS capabilities.

  1. First, determine which device is the microSD card.

    $ sudo fdisk -l
    Disk /dev/mmcblk2: 58.25 GiB, 62537072640 bytes, 122142720 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
    Disklabel type: dos
    Disk identifier: 0x33192aaf
    
    Device         Boot  Start       End   Sectors   Size Id Type
    /dev/mmcblk2p1       62500    500000    437501 213.6M  c W95 FAT32 (LBA)
    /dev/mmcblk2p2      500001 122142719 121642719    58G 83 Linux
    
    
    Disk /dev/mmcblk1: 238.51 GiB, 256087425024 bytes, 500170752 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
    Disklabel type: dos
    Disk identifier: 0x00000000
    
    Device         Boot Start       End   Sectors   Size Id Type
    /dev/mmcblk1p1      65536 500170751 500105216 238.5G  7 HPFS/NTFS/exFAT
    ...

    In this case, /dev/mmcblk1 is the 256GB microSD card.

  2. Next, determine the disk id to use when creating the zpool.[1]

    $ ls -lh /dev/disk/by-id/ | grep -w mmcblk1
    lrwxrwxrwx 1 root root 13 Jun 24 07:33 mmc-AB5CD_0x00000001 -> ../../mmcblk1
  3. Then, check the block size.

    $ sudo blockdev --getpbsz /dev/mmcblk1
    512

    The SD card’s block size is 512 MiB, which means ashift should be set to 12.[2]

  4. Create the pool.[3]

    $ sudo zpool create \
      -o ashift=12 \
      -O compression=on \ (1)
      ext_pool mmc-AB5CD_0x00000001
    1 Turn on compression by default.
  5. Configure the system to automatically import the pool on boot.[4]

    $ sudo zpool set cachefile=/etc/zfs/zpool.cache ext_pool

Create the Dataset

With the microSD card now managed by ZFS, it is now possible to create the ZFS dataset for storing your music.

  1. Create the ZFS dataset for your tunes.

    $ sudo zfs create \
      -o recordsize=1M \ (1)
      -o mountpoint=/home/jordan/Music \
      ext_pool/music
    1 A nifty trick here is to use a larger recordsize of 1 MiB which more accurately reflects the filesystem operations for large media files.[5]
  2. Set the appropriate ownership for the mounted ~/Music directory.

    $ sudo chown -R jordan:jordan /home/jordan/Music

Copy

Now, just copy the music files from wherever they happen to be to the dataset. The simplest way is to copy the files over the network. Since the pool is on an SD card, you might just want to pop it out and carry it between machines, so I describe that here.

  1. Export the pool from the Pinebook Pro.

    $ sudo zpool export ext_pool
  2. Pop-out the microSD card and pop it into the machine with all of the music.

  3. Import the pool.

    $ sudo zpool import ext_pool
    cannot mount '/home/jordan/Music': directory is not empty
  4. Change where the music dataset is mounted.

    I keep my music in ~/Music, so I have to mount the dataset somewhere else.

    $ sudo zfs set mountpoint=/media/jordan/Music ext_pool/music
  5. Mount the dataset to the updated location.

    $ sudo zfs mount ext_pool/music
  6. Set the appropriate ownership for the mounted directory.

    $ sudo chown jordan:jordan /media/jordan/Music
  7. Copy over the music.

    $ tar cfC - /home/jordan/Music . | tar xpfC - /media/jordan/Music
  8. Then change the mount location back to ~/Music.

    $ sudo zfs set mountpoint=/home/jordan/Music ext_pool/music
    cannot mount '/home/jordan/Music': directory is not empty
    property may be set but unable to remount filesystem
  9. Export the pool from the machine.

    $ sudo zpool export ext_pool
  10. Now place the SD card back into the Pinebook Pro, and import the pool again.

    $ sudo zpool import ext_pool

Verify

If everything is successful, your music should now be available in ~/Music.

You should also check that the pool and music dataset are automatically mounted at boot.

$ sudo reboot

Enjoy

You can now enjoy your vast music collection from the comfort of your Pinebook Pro.