Skip to content

Zfs on linux resize rpool

wordpress meta

title: 'ZFS on Linux resize rpool'
date: '2013-05-14T16:57:17-05:00'
status: publish
permalink: /zfs-on-linux-resize-rpool
author: admin
excerpt: ''
type: post
id: 304
category:
    - ZFS
tag: []
post_format: []

In a previous article I setup Ubuntu 13.04 to run off a ZFS root pool. During my setup I used 4G out of an 8G disk for rpool only and mentioned we can just resize later. Turns out ZFS on linux have a bug and to get autoextend to work you need to do an extra step.

Note: Since I could not find a tool (including parted) to resize a ZFS physical partition; and my parition layout on the main disk was simple enough; I just ended up booting a livecd and deleting sda2 and creating it bigger.

Partitions before I started:

# fdisk -l
...
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63       96389       48163+  be  Solaris boot
/dev/sda2           96390     7903979     <span style="color: #ff0000;">3903795</span>   bf  Solaris

Partitions after I deleted and recreated sda2:

# fdisk -l
Disk /dev/sda: 8589 MB, 8589934592 bytes
...
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63       96389       48163+  be  Solaris boot
/dev/sda2           96390    16777215     <span style="color: #ff0000;">8340413</span>   bf  Solaris

First boot after partition change:

# df -h
Filesystem           Size  Used Avail Use% Mounted on
rootfs               3.7G  3.1G  580M  85% /

# zpool list
NAME    SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
rpool  3.69G  3.06G   638M    83%  1.00x  ONLINE  -

# zfs list
NAME                  USED  AVAIL  REFER  MOUNTPOINT
rpool                3.06G   580M    31K  /rpool
rpool/ROOT           3.06G   580M    31K  /rpool/ROOT
rpool/ROOT/ubuntu-1  3.06G   580M  3.06G  /

Try a normal autoexpand:

# zpool get autoexpand rpool
NAME   PROPERTY    VALUE   SOURCE
rpool  autoexpand  off     default

# zpool set autoexpand=on rpool

# zpool get autoexpand rpool
NAME   PROPERTY    VALUE   SOURCE
rpool  autoexpand  on      local

Then I tried a reboot to see if zfs will pickup the autoexpand change. That did not work and rebooting is most likely not necessary at all.

I found a bug on ZFS on linux list:
http://rainemu.swishparty.co.uk/cgi-bin/gitweb.cgi?p=zfs;a=commitdiff;h=3b2e400c94eb488cff53cf701554c26d5ebe52e4

Then tried onlining the rpool and it worked.

# zpool online -e rpool /dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VBb59e0ffb-68fb0252-part2

# zpool list
NAME    SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
rpool  7.94G  3.07G  4.87G    38%  1.00x  ONLINE  -

# df -h | grep rpool
rpool/ROOT/ubuntu-1  7.9G  3.1G  4.8G  40% /
rpool                4.8G     0  4.8G   0% /rpool
rpool/ROOT           4.8G     0  4.8G   0% /rpool/ROOT

# df -h | grep rootfs
rootfs               7.9G  3.1G  4.8G  40% /