Resizing disk of Fedora CoreOS

After provisioning Fedora CoreOS, resizing the disk might be necessary. This is a guide for you.

Situation at hand

The default disk size is 10GB, looks something like this:

[root@coreos ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda      8:0    0   10G  0 disk 
├─sda1   8:1    0    1M  0 part 
├─sda2   8:2    0  127M  0 part 
├─sda3   8:3    0  384M  0 part /boot
└─sda4   8:4    0  9.5G  0 part /var
                                /sysroot/ostree/deploy/fedora-coreos/var
                                /usr
                                /etc
                                /
                                /sysroot

You realise that you need more space, you grow the disk (i choose 100GB in this example) on underlying hardware.

[root@coreos ~]# echo 1 > /sys/block/sda/device/rescan
[root@coreos ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda      8:0    0  100G  0 disk 
├─sda1   8:1    0    1M  0 part 
├─sda2   8:2    0  127M  0 part 
├─sda3   8:3    0  384M  0 part /boot
└─sda4   8:4    0  9.5G  0 part /var
                                /sysroot/ostree/deploy/fedora-coreos/var
                                /usr
                                /etc
                                /
                                /sysroot

Note that partition /dev/sda4 does not resize anymore, as it would on the first boot.

The fix

Theese manual steps made it:

[root@coreos ~]# growpart /dev/sda 4
CHANGED: partition=4 start=1050624 old: size=19920863 end=20971487 new: size=208664543 end=209715167
[root@coreos ~]# unshare --mount
[root@coreos ~]# mount -o remount,rw /sysroot
[root@coreos ~]# xfs_growfs /sysroot
meta-data=/dev/sda4              isize=512    agcount=21, agsize=124416 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=1 inobtcount=1 nrext64=0
data     =                       bsize=4096   blocks=2490107, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=16384, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 2490107 to 26083067

Situation after:

[root@coreos ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda      8:0    0  100G  0 disk 
├─sda1   8:1    0    1M  0 part 
├─sda2   8:2    0  127M  0 part 
├─sda3   8:3    0  384M  0 part /boot
└─sda4   8:4    0 99.5G  0 part /var
                                /sysroot/ostree/deploy/fedora-coreos/var
                                /usr
                                /etc
                                /
                                /sysroot

…and we are happy.

The article is edited to add the block device rescan to avoid the need of reboot of the server.

Do you have better solution or improvement ideas? Please comment.

One thought on “Resizing disk of Fedora CoreOS

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.