Resizing volumes: Difference between revisions

From Newroco Tech Docs
Jump to navigationJump to search
No edit summary
Line 8: Line 8:


See also page on [[Using lvm]].
See also page on [[Using lvm]].
If the volume is served from an ISCSI SAN or similar you will need to disconnect and reconnect (or restart the service, but that's less elegant and interrupts other ISCSI sessions unnecessarily)


==GPT method (increasing volume size)==
==GPT method (increasing volume size)==

Revision as of 10:36, 26 January 2019

This assumes a volume/label type of GPT. The instructions assume there is available space on the disk i.e. you've already made the disk bigger in the storage device.

All the following should be done with the volume dismounted.

If the filesystem is being grown to greater than 16TB it needs to be converted to EXT4 or BTRFS first. If the conversion is necessary you must check the fstab entry correctly specifies the new filesystem used.

This page assumes EXT filesystems. See BTRFS for instructions on use of that filesystem.

See also page on Using lvm.

If the volume is served from an ISCSI SAN or similar you will need to disconnect and reconnect (or restart the service, but that's less elegant and interrupts other ISCSI sessions unnecessarily)

GPT method (increasing volume size)

Run parted on your device as root or with sudo:

parted /dev/sdX

The method diverges here depending on version of parted.

Modern parted

In parted, do

p

parted should return

Warning: Not all of the space available to /dev/sdb appears to be used, you can fix the GPT to use all of the space (an extra 20971520 blocks) or continue with the current setting? 
Fix/Ignore?

Enter

Fix

Then

resizepart 1

(changing partition number as needed). Parted should return

End [current size]?

Assuming you want all the additional space enter

100%

Then to check

p
  • If results are not as expected, check you've completed the resize at the storage level (reload SAN, logged out/in of the iscsi target etc.)

Finally exit parted

quit

Now skip to #Last resize step

Older parted

Inside parted change display unit to sectors:

unit s

Print current partition table and note the start sector for your partition:

p

Delete your partition (this won't delete the data or filesystem!):

rm <number>

Recreate the partition with the starting sector from above:

mkpart primary <start> <end> (if you want a partition that fills the available disk, it's the number of maximum sectors shown when you print the table except -1)

Exit parted:

quit

Last resize step

Check the filesystem:

e2fsck -f /dev/sdXX

Resize filesystem to desired size:

resize2fs /dev/sdXX xxG

Or just

resize2fs /dev/sdXX

to use all available free space.

GPT method (decreasing)

Use

df -h

to determine available free space.

Then umount the volume.

umount /dev/sdXX

And check the filesystem is healthy.

e2fsck -f -C 0 /dev/sdXX

If you get errors from above, remount the volume and start again (it may effect reported size).

Next resize the volume as required, noting that if you request it is made smaller than the available space it will abort, but if you make it very close to making the remaining volume full, it can take a long time to complete, especially if the space being recovered was previously used i.e. you've deleted lot of files.

resize2fs /dev/sdXX x000G

Mount the volume to check the reported size and then unmount it again.

Start parted

parted /dev/sdX

Delete your partition (this won't delete the data or filesystem!):

rm <number>

Recreate the partition with the starting sector from above:

mkpart primary <start> <end>

(if you want a partition that fills the available disk, it's the number of maximum sectors shown when you print the table except -1)

Exit parted:

quit

If you get an error when mounting it and dmesg has an error about geometry, run parted again and choose an "End" larger than previously. Once it mounts successfully, unmount it and run e2fsck again as above.