Ask Your Question

Revision history [back]

Ok this is my way to expand rootfs on a Fedora Server:

-------I am just setting up my Raspi 3b+ now. You are lucky------

[root@pi ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0         179:0    0 59.5G  0 disk
├─mmcblk0p1     179:1    0  200M  0 part /boot/efi
├─mmcblk0p2     179:2    0    1G  0 part /boot
└─mmcblk0p3     179:3    0  5.8G  0 part
  └─fedora-root 253:0    0  5.8G  0 lvm  /
zram0           252:0    0  453M  0 disk [SWAP]

that shows the rootfs did't take up the whole the sd-card

[root@pi ~]# growpart /dev/mmcblk0 3
CHANGED: partition=3 start=2508800 old: size=12171264 end=14680064 new: size=122226655,end=124735455
[root@pi ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0         179:0    0 59.5G  0 disk
├─mmcblk0p1     179:1    0  200M  0 part /boot/efi
├─mmcblk0p2     179:2    0    1G  0 part /boot
└─mmcblk0p3     179:3    0 58.3G  0 part
  └─fedora-root 253:0    0  5.8G  0 lvm  /
zram0           252:0    0  453M  0 disk [SWAP]
[root@pi ~]# partprobe

Then check PV

  [root@pi ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/mmcblk0p3
  VG Name               fedora
  PV Size               5.80 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              1485
  Free PE               0
  Allocated PE          1485
  PV UUID               mrQIYi-AixY-ckDg-dvMF-eGTC-3u0o-Y4WJwC

Resize it:

[root@pi ~]# pvresize /dev/mmcblk0p3
  Physical volume "/dev/mmcblk0p3" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized
[root@pi ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/mmcblk0p3
  VG Name               fedora
  PV Size               58.28 GiB / not usable 3.98 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              14919
  Free PE               13434
  Allocated PE          1485
  PV UUID               mrQIYi-AixY-ckDg-dvMF-eGTC-3u0o-Y4WJwC

Check and resize LV

[root@pi ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/fedora/root
  LV Name                root
  VG Name                fedora
  LV UUID                O8wP2r-jTdL-ZUHF-NB0A-aujF-C4aN-Wxi1eO
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2018-10-25 07:51:39 +0800
  LV Status              available
  # open                 1
  LV Size                5.80 GiB
  Current LE             1485
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
[root@pi ~]# lvresize -l +100%FREE /dev/fedora/root
  Size of logical volume fedora/root changed from 5.80 GiB (1485 extents) to <58.28 GiB (14919 extents).
  Logical volume fedora/root successfully resized.

Finally resize filesystem.

[root@pi ~]# xfs_growfs /
meta-data=/dev/mapper/fedora-root isize=512    agcount=4, agsize=380160 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=0
data     =                       bsize=4096   blocks=1520640, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 1520640 to 15277056

If you are using EXT4, use resize2fs instead