Friday 14 March 2014

ReSize Disk Partition in Linux

I have been in a situation where /tmp partition of disk has to be resized. My disk was of 350 cylinder and partition was as follows.

start Cylinder| End Cylinder | Partition
0             | 10           | /dev/sda1
11            | 200          | /dev/sda2
201           | 299          | /dev/sdb3
300           | 330          | /dev/sda4

Here /tmp partition is /dev/sda4 (cylinder 300 to 330), so here cylinder 331 to 349 was unused and I had to allocate same to /dev/sda4.
To resize /dev/sda4, I rebooted system in single user mode and edited partition table with sfdisk command as follows
+++++++++++++++++++++++++++++
sfdisk /dev/sda -N4 <<EOF
300,50,L
EOF
+++++++++++++++++++++++++++++
Remember that here I changed end cylinder, Never think to change start cylinder (sector) as it will overwrite superblock and resulted in corruption of partition.
After resizing /dev/sda4, I resized file system using below command
++++++++++++++++++++
resize2fs /dev/sda4
++++++++++++++++++++++
Apply fsck
++++++++++++
fsck -y /dev/sda4
+++++++++++++++++++++++
Go for a  reboot now.

No comments:

Post a Comment