One of partition on my database server got 100% occupied with data and no free space available on the disk. Now i am unable to start the database server. its on vmware server.
Here i am taking a sample partition to expand the disk from 5GB to 7GB with out lossing Data.
Before increasing the disk, i have taken the following details from linux vm
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 6.8G 2.1G 4.5G 32% /
/dev/sda1 99M 12M 83M 13% /boot
none 252M 0 252M 0% /dev/shm
/dev/sdb1 5.0G 39M 4.7G 1% /mnt/test
# fdisk -s /dev/sdb
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 652 5237158+ 83 Linux
Shutdown the vm now
Now i am going to increase the existing virtual disk ( /dev/sdb ) from vmware command prompt
go to the location of virtual disk location
Note: this task should be performed only when vm is powered off
# vmware-vdiskmanager -x 7Gb RedHatEnterprise_Linux_4-0.vmdk
Now it will grow the virtual disk to 7Gb
Now you need to power on the VM.
Log into vm using putty or console as root user
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 6.8G 2.1G 4.5G 32% /
/dev/sda1 99M 12M 83M 13% /boot
none 252M 0 252M 0% /dev/shm
/dev/sdb1 5.0G 39M 4.7G 1% /mnt/test
Still it shows the old size.
unmount the partition which you are going to increase.
#umount /dev/sdb1
Run the file system repair on the disk
#fsck -n /dev/sdb1
Now were are goig to remove the journel from the disk to make it into ext2 filesystem
#tune2fs -O ^has_journal /dev/sdb1
Now start partitioning the /dev/sdb to use the increased space to the /dev/sdb1
Note: Don’t Panic, You will not loss data here
I am removing the existing /dev/sdb1 and recreating along with available free space.
# fdisk /dev/sdb
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): p
Disk /dev/sdb: 7516 MB, 7516192768 bytes
255 heads, 63 sectors/track, 913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 652 5237158+ 83 Linux
Command (m for help): d
Selected partition 1
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-913, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-913, default 913):
Using default value 913
Command (m for help): p
Disk /dev/sdb: 7516 MB, 7516192768 bytes
255 heads, 63 sectors/track, 913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 913 7333641 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Now restart the linux machine to take effect of the partition ( we can also use partprobe, its strictly recommended to restart the machine
# shoutdown now -r
Now once again check the extended file system, if you skip this step, resize2fs command will recommends to run
# e2fsck -f /dev/sdb1
e2fsck 1.35 (28-Feb-2004)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdb1: 13/655360 files (7.7% non-contiguous), 22121/1309289 blocks
Now resize the file system.
# resize2fs /dev/sdb1
resize2fs 1.35 (28-Feb-2004)
Resizing the filesystem on /dev/sdb1 to 1833410 (4k) blocks.
The filesystem on /dev/sdb1 is now 1833410 blocks long.
Now check the file system
#fsck -n /dev/sdb1
fsck 1.35 (28-Feb-2004)
e2fsck 1.35 (28-Feb-2004)
/dev/sdb1: clean, 13/917504 files, 30538/1833410 blocks
Now recreate the partition with ext3 format
# tune2fs -j /dev/sdb1
tune2fs 1.35 (28-Feb-2004)
Creating journal inode: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Restart the Linux machine once to get effected with ext3 file system.
#shutdown -r now
Once again you login to Linux box using root previleges.
Now you can find the partition increased to 7 Gb
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 6.8G 2.1G 4.5G 32% /
/dev/sda1 99M 12M 83M 13% /boot
none 252M 0 252M 0% /dev/shm
/dev/sdb1 6.9G 39M 6.7G 1% /mnt/test