Změna velikosti oddílu ext3 (rozšíření) – Resize large ext3 partition

This article is about resizing ext3 partitions without losing data. It shows how to enlarge
existing ext3 partition. This can be quite useful if you do not use LVM and you realize that your existing partitioning does not meet your actual needs anymore.
I do not issue any guarantee that this will work for you! So, better to make your testing on a VM before going into the live system.I run all the commands in this tutorial as the root user, so make sure you’re logged in as root.

As one of the requirements in my company, i had to resize a Linux drive which is not a system drive and containing all Mails data for our Lotus server, this is a SAN drive which is formatted in Linux EXT3 file system and is not an LVM partition, so the size increase was a big challenge without loosing Data.

1) Testing On VM
As a testing on a VMware VM having Linux, with a secondary virtual hard disk /dev/sdb of 5 GB,having copied some data and I wished to increase the size to 8 GB, the steps are as follows,
a) Increase the size of the drive from VMWare settings
c)  Go to the Linux Shell inside VM and follow the follow steps

1. First, we collect some details again about our current partitioning:
# fdisk -l /dev/sdb
# df -h
Notice the difference, the fdisk command will show new modified size i.e. 8 GB,
while the df -h will only show the 5 GB, the already formated and usable space,
as the new assigned space is RAW space, while the existing space is ext3 formatted, so
to merge this RAW space, do the following,

2. Make sure the drive to resize is not accessible in the OS , by stopping any service using it
and un-mounting the drive
# umount /dev/sdb1 
                    # fsck -n /dev/sdb1

3. Next we remove the journal from /dev/sdb1, thus turning it into an ext2 partition:
# tune2fs -O ^has_journal /dev/sdb1

4. Now we use fdisk to delete our current /dev/sdb1 partition and create a bigger one
(don’t be  afraid, no data will be lost):
# fdisk /dev/sdb
                 Now we delete partition , (/dev/sdb1):
Next we create a new /dev/sdb1 partition. Assign it all the available space
                 Let’s print out our new partition table:
Command (m for help): p

                 Now let’s write our new partition table and exit fdisk:
Command (m for help): w
The partition table has been altered!

         5) Then run
# e2fsck -f /dev/sdb1

6) Now we must resize the file system in our /dev/sdb1 partition. If we don’t specify a size
for the resize2fs command, it will assume the biggest possible size so we don’t have to
calculate. So we run
# resize2fs /dev/sdb1

7) Next we run
# fsck -n /dev/sdb1
        8) Create the journal on /dev/sdb1, thus turning it into an ext3 partition again:
# tune2fs -j /dev/sdb1 

Now we are done 😉
9) You can now check the size of your new partition and remount it with the new modified size without loosing your data,
# fdisk -l /dev/sdb
          # mount /dev/sdb1 /mydrive
# df -h

Now after successful testing on my VM, the same activity was performed on my Lotus server,
But Remember, as now dealing with Live setup, first take a backup of your data before any modification, then perform the following steps,
1) check the current size and mount point of your drive
2) Make sure the drive is not accessible by any user or application,
By stopping the Lotus server which is accessing this mail drive and umounting the drive
3) Increase the space for the drive from the SAN, which will take some time in synchronizing
4) after step 3 completed, go to the Linux shell, and perform activites from above example in Step C.

Enjoy, Have a Nice time.

I am thankful to the tutorial provide by Falko Timme from the below website,
which contains more in depth and detailed procedure for resizing and shrinking an ext3 partition without loosing data.