Score:0

RHEL 7 extend xfs partition/filesystem size without affecting data?

cn flag

Excuse me, I'm trying to enlarge space for a directory in a RHEL 7.5 host and the partition is not managed by LVM.

This host is virtual machine and I would like to increase size for /home/ext to use, which is located on device sdc. Device sdc is an independent VM disk and I'm planning to increase size for it directly, and eventually assign all the partition space sdc1 to directory /home/ext without reboot.

The output from "lsblk" and "df -Th /dev/sdc1" are shown below:

NAME                   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                      8:0    0  201G  0 disk
├─sda1                   8:1    0    1G  0 part /boot
└─sda2                   8:2    0  200G  0 part
  ├─host-root          253:0    0  168G  0 lvm  /
  └─host-swap          253:1    0   32G  0 lvm  [SWAP]
sdb                      8:16   0 1000G  0 disk
└─sdb1                   8:17   0 1000G  0 part /home
sdc                      8:32   0    2T  0 disk
└─sdc1                   8:33   0    2T  0 part /home/ext
sdd                      8:48   0    2T  0 disk
└─sdd1                   8:49   0    2T  0 part /home/ext2
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/sdc1      xfs   2.0T  1.8T  206G  90% /home/ext

I did googling and found a quick answer here, which uses gdisk/growpart.

However, not sure whether this size-increasing behavior will affect the current data read/write on this directory(partition).

Does anyone know whether such kind of task will impact on data and filesystem, such as crash?

forgive me, I know only a little to linux..

Score:0
sx flag
Raf

First and foremost:

  • Always take backups before doing potential risky or destructive operations

As far as I'm aware, grow operations rely on removing the partition entry from the partition table, and then creating a new partition entry, essentially first destroying the partition (without formatting the data blocks).

If power would be shut down, or an application crash occurred before the partition has been recreated, the partition could be missing and would need to be recreated manually. The data should still be there.
My recommendation is to not only back up your data but also your partition table.

As for the resizing operation it is performed in two steps:

  1. Resize the physical partition
  2. Perform filesystem tasks to enable use of the extra (or less) space

The first step is the step listed as growpart /dev/sda 3 in your link. The second step will allow the filesystem (just like NTFS on Windows) to become 'aware' of the space (so that fragmentation algorithms can work, node lists can be of the correct size, etc): sudo xfs_growfs /.

Enlarging a partition should not have any negative effects on the operation of a Linux system.

As for your situation specific output, I suppose the partition is already 100% of the size of the disk, which means no enlarging is possible (unless one uses something to span a partition across multiple disks, but this quickly leads to LVM being needed to use). If this is a VM then the disk file must be 'grown' first. That is a separate step that must be performed before the growing steps in a guest OS, please refer to your VM software manual for that. I doubt this is possible without a reboot, but maybe newer advances that I have missed might allow for that.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.