Online Resize

J

Jarret W. Buse

Guest
Online Resize

Before we go on too far, let’s look at the difference between a partition and the file system. A partition is a part, or all, of a hard disk that is to be used to store files. Once a partition is created, it is not usable. The partition must be formatted and prepared for use by setting up a file system. The file system is a set of rules used to manage the file storage. Some file systems have more benefits than others.

Once a file system is in place and used, it cannot normally have its capacity changed, but some file systems allow the size to be changed.

NOTE: Changing partition sizes, even under good circumstances, can cause a possible loss of data. Always create a backup before performing a resize.

For example, if a PC has a 500 GB drive installed that is split into two equal partitions, which contains the OS and data files, and the space is running low, the user needs to increase data space. So /dev/sda1 is running out of space, and /dev/sda2 is empty, or slightly used.

Data on /dev/sda2 should be removed (backed up first). Then the first partition (/dev/sda1) can be extended to use the second partition (/dev/sda2). The process can be done without taking the file system offline, or unmounting it.

It is best to extend a partition rather than moving it. On a hard disk, the partitions have a starting and ending point. If the starting point is moved, then the data must be moved to be within the new start and end point. Moving a partition requires a lot more time and resources to perform.

Be aware that some OS’s in a dual-boot system can have issues if a partition is moved. For instance, a file system which uses a Master Boot Record (MBR), can have four primary partitions. One of these partitions can be made up of extended partitions (as many as you want). More specifically, each hard disk can have one or more partitions set up on it. If a dual-boot system also loads Windows, then moving the Windows partition (where it is installed), can cause Windows to be inoperable.

Rather than an MBR, a disk can use Logical Volume Management (LVM) to manage the partitions. With LVM, partitions can be increased, reduced or moved not only within a hard disk, but across hard disks.

If on a Linux system a partition is moved or changed, it may cause the partition numbers to change.

On most file systems, the partitions can be increased in size while online, but not reduced. Be aware that once a file system has been increased, you can sometimes only regain the space by backing up the data, re-partition the area (losing all data), format the space and restore the data.

In most cases when increasing the file system size, the amount of increase can be specified. When the amount is given, the system determines that the size is greater than the current size and the size is less than or equal to the disk size. If no size is given, it usually means resize to the maximum amount of drive space.

NOTE: When reducing the file system’s size, the amount specified must be greater than the amount of data. The new size should be less than the existing partition size.

For example, to increase the size of a ReiserFS file system, the following command is used to expand it to the maximum size of the disk:

Code:
resize_reiserfs /dev/sda1

If we want to increase a file system by a specific size, we can set the required size growth as follows:

Code:
resize_reiserfs -s +1G /dev/sda1

Here we would be increasing the /dev/sda1 partition by 1 GB. The following units can be used:

  • K Kilobytes
  • M Megabytes
  • G Gigabytes
In either case that you use, be sure to allow the resizing to finish before you attempt to perform any other tasks.

For reducing the file system size, you can perform the following:

  1. Unmount the volume
  2. Resize the volume
  3. Mount the volume
To unmount a volume, do the following:

Code:
umount /dev/sda1

NOTE: If the drive contains the boot files, you must boot from another source.

The decrease can be done with the following command:

Code:
resize_reiserfs -s -1G /dev/sda1

Here we reduce the size by 1 GB for device SDA1. Now, we need to remount the volume:

Code:
mount -t reiserfs /dev/sda1 /mnt/point
 

Attachments

  • slide.jpg
    slide.jpg
    18.9 KB · Views: 31,936

Members online


Latest posts

Top