Resizing ext3 Drives

From KoshWiki

Jump to: navigation, search

Contents

Before Picture

debian:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda1              79G  350M   78G   2% /
tmpfs                 237M     0  237M   0% /dev/shm

Trying Parted

I tried Parted first, as this is what the LVM-HOWTO[1] says to do, but I kept getting the following error, which lead me to google and to troubleshooters.com[2] ....

root@1[~]# parted /dev/hda
GNU Parted 1.6.25.1
Copyright (C) 1998 - 2005 Free Software Foundation, Inc.
This program is free software, covered by the GNU General Public License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Using /UNIONFS/dev/hda
(parted) p
Disk geometry for /UNIONFS/dev/hda: 0kB - 80GB
Disk label type: msdos
Number  Start   End     Size    Type      File system  Flags
1       32kB    79GB    79GB    primary   ext2         boot
2       79GB    80GB    1448MB  extended               lba
5       79GB    80GB    1448MB  logical   linux-swap
(parted) resize
Partition number? 1
Start?  [32kB]?
End?  [79GB]? 10gb
No Implementation: This ext2 file system has a rather strange layout!  Parted
can't resize this (yet).
(parted) q
Information: Don't forget to update /etc/fstab, if necessary.

NOTE: I converted from ext3 to ext2 at this point to try and fix the Parted error

Trying Resize2fs

Running resize2fs with just the device shows the total blocks, so ...

root@1[~]# resize2fs /dev/hda1
resize2fs 1.38 (30-Jun-2005)
The filesystem is already 19183610 blocks long.  Nothing to do!

I can just take 10000000 blocks off ....

root@1[~]# resize2fs /dev/hda1 9183610
resize2fs 1.38 (30-Jun-2005)
Please run 'e2fsck -f /dev/hda1' first.

Oh no !!!, Needs an FSCK first.

e2fsck First !

I ran e2fsck (-f for force checking even if the drive is marked clean)

root@1[~]# e2fsck -f /dev/hda1
e2fsck 1.38 (30-Jun-2005)
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
/: 26574/19202048 files (0.1% non-contiguous), 690651/19183610 blocks

Retry Parted

Maybe the problem was the unclean filesystem, since I converted from ext3 to ext2 before I did this.

root@1[~]# parted /dev/hda
GNU Parted 1.6.25.1
Copyright (C) 1998 - 2005 Free Software Foundation, Inc.
This program is free software, covered by the GNU General Public License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Using /UNIONFS/dev/hda
(parted) resize
Partition number? 1
Start?  [32kB]?
End?  [79GB]? 10gb
No Implementation: This ext2 file system has a rather strange layout!  Parted
can't resize this (yet).
(parted) q
Information: Don't forget to update /etc/fstab, if necessary.

Guess not.

Back to resize2fs

This took a while to run, approx 15 minutes (about as long as the e2fsck).

root@1[~]# resize2fs /dev/hda1 9183610
resize2fs 1.38 (30-Jun-2005)
Resizing the filesystem on /dev/hda1 to 9183610 (4k) blocks.
The filesystem on /dev/hda1 is now 9183610 blocks long.

A quick "sync" (since I was running knoppix) and then a shutdown -h now (to remove the CDROM drive)

After Picture

and after a reboot

debian:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda1              34G  350M   33G   2% /
tmpfs                 237M     0  237M   0% /dev/shm

Resizing the Partition

Main articles: Resizing Linux Partitions, and [[]], and [[]], and [[]], and [[]]

Example

Check out my Real World Example

References

  1. LVM-HOWTO: Run Parted
  2. Converting Ext2 Filesystems to Ext3
Personal tools