0

I have /var file system part of /dev/sdc1 disk. I need to increase this disk size from 25GB to 60GB. I have increase the disk size. Now I am looking for the correct steps to increase the sdc1 partition table and extend the file system, while system is running.

# df -h /var
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdc1        25G   18G  7.8G  70% /var

# sgdisk -p /dev/sdc
Disk /dev/sdc: 125829120 sectors, 60.0 GiB
Model: Virtual disk
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): A7852C28-6258-451D-A2BD-9F5A7CB7DB40
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 52428766
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048        52426751   25.0 GiB    8300

Is this possible while system is running, if yes, May I know the step to increase?

/var is xfs filesystem, we can use xfs_grow to increase the file system. I need to know the correct step to increase partition size.

0
2

First step, do a full and adequate backup. Accidents happen, and for all you know your XFS system might be slightly corrupt and might crash completely when resized. Or I could be a royal a*hole and being giving you bad advice just to imagine your face when the file system throws the bucket. Or, quite possibly, I could be convinced in good faith that these instructions will work, while they actually don't. I will be devastated when you tell me you lost all your precious data, but I won't be able to undo the damage.

So: backup.

The second step, you need to grow the partition. To do this, just resize the partition (you can even delete it and recreate it with the same start sector, provided of course you do not save and reboot until you've finished!).

There are also tools that will grow automatically the partition, and lots of tutorials. Here's one. But just search for "grow root partition without rebooting" and you should be good (yes, this is not your root partition but /var - but this way you will select the "safer" tutorials. What works for / will work better with /var).

Once you have done this (no need to reboot, yes, but you do need to reread the partition - fdisk does this automatically, otherwise use partprobe), you will have a partition like this (the actual end sector may vary slightly, "GB" size is something of a matter of taste)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         125824202  60.0 GiB   8300

but on this 60 GB partition, you will only still have 25 GB in the file system. You can safely reboot and use the system normally, you just won't have any extra space.

But before continuing: you did a full backup, did you?

At this point I might mention that you could also have done this differently by adding a new partition and leaving /dev/sdc1 alone. For example, you have lots of data in /home (say, 15 GB out of the old 25)? Create a /dev/sdc2 with the extra 35 GB, move /home there and you have now 15 GB free on /dev/sdc1, 20 GB left on /sdc2, and your original partition is left untouched (you still should have done a backup)! No need to resize anything, if the extra space on /dev/sdc2 is enough for you.

But if it is not, and you want it all in a single chunk, okay, grow /dev/sdc1 you must.

# xfs_growfs -n /dev/sdc1

will give you info about the existing 25GB filesystem. Data block count is probably around six million and a half.

Do this without the -n option and - after a little while, which I usually spend whispering "at least I made a backup..." - you will see something like,

data blocks changed from 6553600 to 15728640

Just to be sure,

# xfs_info /dev/sdc1

should say among other things something like

data     = bsize=4096   blocks=15728640, imaxpct=25

If you now run df, it should display the new FS size of 60GB. Welcome to your larger disk!

0

This is not possible unless you kill all the applications using /var.

To perform this operation you'll need to use resize2fs which will read the partition data from the kernel, so the first step would be to resize /dev/sdc1 however the Linux kernel doesn't allow to alter disk partitions if any of them is mounted.

0

Thanks for every one input.

I used below command to resize the file system. growpart tool is really helped me.

based on this link followed below steps.

https://www.cyberciti.biz/faq/linux-extend-file-system-after-resize-disk-volume/

1.
   # dnf install cloud-utils-growpart -y
  
2.  
  #  growpart --dry-run /dev/sdc 1
  #  growpart /dev/sdc 1

# sgdisk -p /dev/sdc
Disk /dev/sdc: 125829120 sectors, 60.0 GiB
Model: Virtual disk
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): A7852C28-6258-451D-A2BD-9F5A7CB7DB40
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 125829086
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048       125829086   60.0 GiB    8300


3.

  #  xfs_growfs -n /dev/sdc1
  #  xfs_growfs  /dev/sdc1
 
4.   
    # df -h /var
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/sdc1        60G   17G   44G  27% /var

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.