centostricks

Just another WordPress.com site

Disk increase with parted in CentOS 5.5 (Physical Disk)


Steps to Increase Disk Size with Parted with Sectors as an unit

 

Here we are starting to increase the partition size with parted Tools ( BE CAUTIOUS, CHANGES TAKES PLACE IMMEDIATELY)

 

In this case, we have a physical disk capacity of 177GB. But we have used only 80GB of space, which are further managed via LVM. Now, below steps shows how to allocate (Increase) the remaining 96 GB to /var partition.

 

[root@system~]# parted /dev/sda

GNU Parted 1.8.1

Using /dev/sda

Welcome to GNU Parted! Type ‘help’ to view a list of commands.

(parted) print

 

Disk /dev/sda: 177GB

Sector size (logical/physical): 512B/512B

Partition Table: msdos

 

Number  Start   End     Size    Type     File system  Flags

1      32.8kB  107MB   107MB   primary  ext3

2      107MB   80.5GB  80.4GB  primary               lvm

 

(parted) u s                                                        ( Changing the Default Unit to Sectors)

(parted) print

 

Disk /dev/sda: 346030079s

Sector size (logical/physical): 512B/512B

Partition Table: msdos

 

Number  Start    End         Size        Type     File system  Flags

1      64s      208895s     208832s     primary  ext3

2      208896s  157276349s  157067454s  primary               lvm

 

(parted) rm 2                                     ( Here we are deleting the partition and recreating with new size, In this we are requested to increase the second partition to the new size. So we are deleting it)

(parted) print

 

Disk /dev/sda: 346030079s

Sector size (logical/physical): 512B/512B

Partition Table: msdos

 

Number  Start  End         Size          Type       File system  Flags

1                64s    208895s 208832s  primary  ext3

 

(parted) mkpart primary 208896s 346030079s      ( Here we are recreating the second partition which was deleted in the previous step, We are passing the Partition type, Starting sector(Starting sector will be next sector of the last partition i.e., if the sector of last partition ends at  208895s and the starting sector of the new partition should be 208896s) and ending sector. Here the Ending sector is the max sectors available on this respective disk which can found from line Disk in the print command, changed to color )

 

(parted) print

 

Disk /dev/sda: 346030079s

Sector size (logical/physical): 512B/512B

Partition Table: msdos

 

Number  Start    End         Size        Type     File system  Flags

1      64s      208895s     208832s     primary  ext3

2      208896s  346030079s  345821184s  primary

 

(parted) toggle 2 lvm                                     ( This commands set this partition to be of LVM Type)

(parted) print

 

Disk /dev/sda: 346030079s

Sector size (logical/physical): 512B/512B

Partition Table: msdos

 

Number  Start    End         Size        Type     File system  Flags

1      64s      208895s     208832s     primary  ext3

2      208896s  346030079s  345821184s  primary               lvm

 

(parted) quit                                      ( Exit from Parted)

Information: Don’t forget to update /etc/fstab, if necessary.

 

[root@system~]# fdisk -l

 

Disk /dev/sda: 177.1 GB, 177167400960 bytes

255 heads, 63 sectors/track, 21539 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot      Start         End      Blocks   Id  System

/dev/sda1               1          14      104416   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              14       21540   172910592   8e  Linux LVM

 

[root@system~]# echo 1 > /sys/block/sda/device/rescan   ( To rescan the changes done on block device)

[root@system~]# reboot             (Please reboot the box to make changes take effect)

 

[root@system~]# fdisk -l

 

Disk /dev/sda: 177.1 GB, 177167400960 bytes

255 heads, 63 sectors/track, 21539 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1               1          14      104416   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              14       21540   172910592   8e  Linux LVM

 

[root@system~]# pvscan

  PV /dev/sda2   VG VG_00   lvm2 [74.88 GB / 0    free]

  Total: 1 [74.88 GB] / in use: 1 [74.88 GB] / in no VG: 0 [0   ]

 

[root@system~]# pvresize /dev/sda2   ( Increase the Physical Volume. Prior to this step we need to reboot the OS)

  Physical volume “/dev/sda2” changed

  1 physical volume(s) resized / 0 physical volume(s) not resized

 

[root@system~]# pvscan

  PV /dev/sda2   VG VG_00   lvm2 [164.88 GB / 90.00 GB free]

  Total: 1 [164.88 GB] / in use: 1 [164.88 GB] / in no VG: 0 [0   ]

 

[root@system~]# lvscan

  ACTIVE            ‘/dev/VG_00/LV_root’ [10.00 GB] inherit

  ACTIVE            ‘/dev/VG_00/LV_opt’ [28.03 GB] inherit

  ACTIVE            ‘/dev/VG_00/LV_tmp’ [2.00 GB] inherit

  ACTIVE            ‘/dev/VG_00/LV_var’ [29.03 GB] inherit

  ACTIVE            ‘/dev/VG_00/LV_swap’ [5.81 GB] inherit

 

[root@system~]# lvextend -l +100%FREE /dev/VG_00/LV_var    (Extend the requested partition with the new size. In this case it is /var)

  Extending logical volume LV_var to 119.03 GB

  Logical volume LV_var successfully resized

 

[root@system~]# lvscan

  ACTIVE            ‘/dev/VG_00/LV_root’ [10.00 GB] inherit

  ACTIVE            ‘/dev/VG_00/LV_opt’ [28.03 GB] inherit

  ACTIVE            ‘/dev/VG_00/LV_tmp’ [2.00 GB] inherit

  ACTIVE            ‘/dev/VG_00/LV_var’ [119.03 GB] inherit

  ACTIVE            ‘/dev/VG_00/LV_swap’ [5.81 GB] inherit

 

[root@system~]# resize2fs /dev/VG_00/LV_var                   (Resize the filesystem)

resize2fs 1.39 (29-May-2006)

Filesystem at /dev/VG_00/LV_var is mounted on /var; on-line resizing required

Performing an on-line resize of /dev/VG_00/LV_var to 31203328 (4k) blocks.

The filesystem on /dev/VG_00/LV_var is now 31203328 blocks long.

 

 [root@system~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VG_00-LV_root

                      9.7G  3.6G  5.7G  39% /

/dev/mapper/VG_00-LV_opt

                       28G 1008M   25G   4% /opt

/dev/mapper/VG_00-LV_tmp

                      2.0G  418M  1.5G  23% /tmp

/dev/mapper/VG_00-LV_var

                      116G   23G   88G  21% /var

/dev/sda1              99M   26M   69M  28% /boot

tmpfs                 2.0G     0  2.0G   0% /dev/shm

 

 You should be ALL SET🙂

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: