Extend XFS parititon ( xfs_growfs )
You want to resize your home partition but the swap partition is in the way. Rough outline follows.
First, check the current size of your home partition:
blockdev --getsize64 /dev/sda3
Disable swap:
swapoff -a
Delete swap partition:
parted /dev/sda rm 4
Resize home partition but leave 1GiB
for a new swap partition at the end.
parted /dev/sda -- resizepart 3 -1GiB
Re-create swap partition:
parted /dev/sda -- mkpart swap -1GiB -1
Now verify whether the kernel was able to re-read partition table:
blockdev --getsize64 /dev/sda3
If that prints the old size you have reboot first. Note that reboot now might complain about swap missing; adapt your /etc/fstab
and update initramfs
accordingly.
Finally, grow:
xfs_growfs /dev/sda3
And re-create swap:
mkswap /dev/sda4
swapon /dev/sda4
Don't forget to re-add a new swap entry to your /etc/fstab
.
Related videos on Youtube
Zorba
Updated on September 18, 2022Comments
-
Zorba over 1 year
Here are the partitions of my server :
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 54.6T 0 disk ├─sda1 8:1 0 1004.5K 0 part ├─sda2 8:2 0 19.5G 0 part / ├─sda3 8:3 0 16T 0 part /home └─sda4 8:4 0 511M 0 part [SWAP]
And here is the print table :
Disk /dev/sda: 60.0TB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 20.5kB 1049kB 1029kB primary bios_grub 2 2097kB 21.0GB 21.0GB ext4 primary 3 21.0GB 17.6TB 17.6TB xfs primary 4 17.6TB 17.6TB 536MB linux-swap(v1) primary
I need to grow the partition
/home
to the total disk space ( 54.6T ).I've tried with
xfs_growfs
and gave the command :xfs_growfs /home -d
although tried with
xfs_growfs /dev/sda3 /home -d
But it always says
data size unchanged, skipping
and instead growing/home
to the total disk space ofsda
it tries to grow it to the total space ofsda3
which is already grew totally :Filesystem Size Used Avail Use% Mounted on /dev/sda3 16T 33M 16T 1% /home
So how can I solve that problem?
-
frostschutz about 8 yearsYou have to resize your partition first?
parted /dev/sda unit mib print free
. Might have to delete swap partition first since it seems to be in the way. -
Zorba about 8 yearsWell
parted
means alternative method I think, and there will beresize
instead ofxfs_growfs
... anyways I deleted swap partition and now i can see the free space how can I create swap partition again to include the total free space in it, then resize partition 3 to include this free space ? . I tried withmkpartfs
but doesn't work !
-
-
frostschutz about 8 yearsHence I said rough outline, I'll leave the minor details to you... :p
-
Zorba about 8 years
resizepart
doesn't work at all so I'm still stuck at the step :parted /dev/sda -- resizepart 3 -1GiB
. maybe because the filesystem in partition 3 is XFS, and as I know XFS partitions cannot be reduced but only extended ? -
Zorba about 8 yearsI never found
resizepart
orresize
in commands list of ( GNU Parted 3.1 ) which included in my OS. maybe it's why that command doesn't work with me ? -
frostschutz about 8 yearsSorry, in that case, try parted 3.2, it's well over a year (closer 2 years) old by now ... also the second one will give you alignment trouble since the "end" does unfortunately not back off by a sector. But if you're managing a 60TB machine you should be able to handle these.
-
frostschutz about 8 yearsAlternatively you can
unit s
,print
, note down the start sector, thenrm
,mkpart
with exactly that start sector. -
Zorba about 8 yearsIt works and the partition 3 size was really changed, but when I try to
xfs_growfs
it doesn't grow ! -
frostschutz about 8 yearsDoes blockdev report the new size?
-
Zorba about 8 yearsYes
blockdev
reported a new size ... Maybe I have to adapt/etc/fstab
and updateinitramfs
beforexfs_growfs
? .. how to do both of that ? -
frostschutz about 8 yearsNo, it should just grow; what's the error message / output of the grow command?
-
Zorba about 8 yearswell here is the message : s14.postimg.org/lf36a8ee9/2016_03_07_20_50_18.jpg
-
frostschutz about 8 yearsAnd
blockdev --getsize64
says which number? Also can you show/proc/mounts
, which mount options is it using? -
Zorba about 8 yearsWell
blockdev --getsize64 /dev/sda3
gives the number17592168220160
... do you meancat /proc/mounts
? , it shows a very big list : s18.postimg.org/8ycs32tft/2016_03_07_21_01_40.jpg -
frostschutz about 8 yearsWell, according to blockdev the partition is only 16TB. You might have to reboot (or otherwise umount everything on the disk and tell kernel to re-read partition table)
-
Zorba about 8 yearsWell actually the partition table didn't change after kernel command . I still cannot resize through
xfs_growfs
-
Zorba about 8 yearsthanks for your time... I solved it by deleting both partitions 3 and 4, then
mkpart
for partition 3 .. and now the total disk space54.6T
included in partition 3/home/
, so there was no need to usexfs_growfs
.. and aboutswap
should I make a new swap partition or no problem without swap ? ... what do you recommend ? -
Zorba about 8 yearsActually I'm not sure the current situation is fine because
lsblk
table andblockdev
shows that the total disk space included in/home
, but indf -h
nothing changed, the size of/home
still 16 TB ! ... how can that occurs !? s16.postimg.org/d2jhfroh1/2016_03_07_23_43_43.jpg -
frostschutz about 8 yearsI wrote step by step in my answer, is it really that hard to follow? You write there was no need to use growfs, but without growfs it's no wonder it's still at 16T...
-
Zorba about 8 yearsWell that means
lsblk
andblockdev
are not necessarily giving always the right values ! .... of course I prefer to grow the partition throughgrowfs
to don't have any problem with the new size later , but as you saw the command didn't work with me ... Anyways I'm gonna re-installed the OS and repeating the process again. -
frostschutz about 8 yearsnot sure what to tell you. xfs_growfs grows the filesystem, not partitions. you have to grow the partition first, then the filesystem. it's two separate things.
-
Zorba about 8 yearsI got it ... that's what I just did now, growing the partition then growing the filesystem and I think it works now as long as the data blocks increased after performing
xfs_growfs
... s14.postimg.org/4m05g8ov5/2016_03_08_1_20_12.jpg ... thank you