Resize ext3 partition using resize2fs which support ext3.
root@deb:/disk# ls -la
total 664228
drwxr-xr-x 3 root root 4096 Dec 19 18:29 .
drwxr-xr-x 22 root root 4096 Dec 19 17:19 ..
-rwxrwxrwx 1 nobody nogroup 679477248 Nov 26 11:31 debian-6.0.3-i386-CD-1.iso
drwx------ 2 root root 16384 Dec 19 17:18 lost+found
root@deb:/disk#
There is an ISO of Debian system. I don’t want loose it 🙂
root# df -h
/dev/sdg1 5.0G 779M 4.0G 17% /disk
root# umount /disk
root@deb:~# e2fsck -f /dev/sdg1
e2fsck 1.41.12 (17-May-2010)
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/sdg1: 13/326400 files (0.0% non-contiguous), 219859/1309289 blocks
root@deb:~#
#delete the partition and create new one
root# cfdisk /dev/sdg
root# e2fsck -f /dev/sdg1
#checking inodes, blocks, sizes, dir, reference
e2fsck 1.41.12 (17-May-2010)
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/sdg1: 13/326400 files (0.0% non-contiguous), 219859/1309289 blocks
root# resize2fs /dev/sdg1
Resizing the filesystem on /dev/sdg1 to 1572354 (4k) blocks.
The filesystem on /dev/sdg1 is now 1572354 blocks long.
root# mount -a
root# df -h
/dev/sdg1 6.0G 779M 4.9G 14% /disk
Done 😀
Resize ext3 partition using resize2fs which does NOT support ext3.
root@deb:/disk# ls -la
total 664228
drwxr-xr-x 3 root root 4096 Dec 19 18:29 .
drwxr-xr-x 22 root root 4096 Dec 19 17:19 ..
-rwxrwxrwx 1 nobody nogroup 679477248 Nov 26 11:31 debian-6.0.3-i386-CD-1.iso
drwx------ 2 root root 16384 Dec 19 17:18 lost+found
root@deb:/disk#
There is an ISO of Debian system. I don’t want loose it 🙂
root# df -h
/dev/sdg1 3.0G 667M 2.2G 24% /disk
root# umount /disk
Use tune2fs to remove the journal from the ext3 partiton. Now the partition is effectively an ext2 file system.
root# tune2fs -O ^has_journal /dev/sdg1
tune2fs 1.41.12 (17-May-2010)
Use cfdisk or fdisk to resize the partition, actually we will delete the old partition (no data will be lost)
and create a new one of the desired size.
# delete the partition and create new one
root# cfdisk /dev/sdg
root# e2fsck -f /dev/sdg1
# checking inodes, blocks, sizes, dir, reference
e2fsck 1.41.12 (17-May-2010)
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/sdg1: 12/195840 files (0.0% non-contiguous), 178735/785169 blocks
Use the resize2fs /dev/sdg1 to resize the partition to the maximum available.
root# resize2fs /dev/sdg1
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/sdg1 to 1048233 (4k) blocks.
The filesystem on /dev/sdg1 is now 1048233 blocks long.
Use tune2fs to add the journal again.
root# tune2fs -j /dev/sdg1
tune2fs 1.41.12 (17-May-2010)
Creating journal inode: done
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
root# mount -a
root# df -h
/dev/sdg1 4.0G 715M 3.1G 19% /disk
Done 😀