Resizing ext3 partitions with parted

A while ago I wanted to enlarge my /home partition (hda6), as it was getting full. After that partition I had another (unused) one, which I intended to merge with hda6 and thereby increase the amount of free disk space on /home.

Here's parts of the disk layout:

hda6 Logical Linux ext3 30848.00
hda7 Logical Linux ext3 8848.00

So, merging hda7 into hda6 should be as simple as removing hda7, and then resizing hda6 to swallow up the 8 gig from the former hda7. Basically, that's how it worked, but I had a few problems. First, at that time is seemed impossible to simply resize ext3 partitions. Neither ext2resize, nor QtParted, nor parted worked for me for some reasons (maybe that has changed recently).

After some googling I finally found a way to do it (which I'll document here, maybe it'll be helpful for others):

  1. Boot from Knoppix, not mounting any partition
  2. Run fsck on both, hda6 and hda7 (optional?)
  3. Remove hda7 (e.g. using cfdisk)
  4. Remove the ext3 journal from hda6 (effectively turning it into an ext2 partition):
    # tune2fs -O^has_journal /dev/hda6
  5. Resize hda6 using parted. The xxxx is the original start of hda6 (you may not change that) and yyyy is the end of the disk:
    # parted
    (parted) resize 6 xxxxx yyyyy
  6. Enable the ext3 journal again on the now enlarged hda6:
    tune2fs -j /dev/hda6
  7. Reboot

But this didn't work from the beginning either — for some strage reason parted didn't believe me that the space after hda6 was free. It did display it as free space, but the "resize" operation complained.

So what I did was this (instead af the above step 3):

  1. Re-add the hda7 partition using, e.g., cfdisk
  2. Start parted, and remove hda7 again from within parted(!):
    # parted
    (parted) rm 7

It seems parted didn't like the way cfdisk removed the hda7 partition... very strange...

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

holy shmoly it actually worked

Much like Giulio, and probably others, I had to resize an ext3 VM partition (vm running on ESX), which had been created in the standard way:
/dev/sda1 was the / ext3 partition,
/dev/sda2 extended
/dev/sda5 swap

I just followed the same steps - expand the vm disk, boot knoppix, remove journaling, delete the extended and swap partitions. expand the ext2 partition, recreate the extended/swap partitions, add journaling to sda1, and reboot.

I was actually kind of surprised when the machine booted and worked correctly on the first try. Alright!

Resizing ext3 partitions with parted

I followed the following on my Debian 4.0 box to remove the idle ext3 /dev/hda3 and add it to /dev/hda2. Booting using Knoppix3.9 and making sure partitions are not mounted

$su
#fsck /dev/hda2
#fsck /dev/hda3
#tune2fs -O^has_journal /dev/hda2
#parted
...
(parted)rm 3
(parted)resize 2 1217 3648
error: File system has incompatible feature enabled.

I am unable to understand the error. Please comment. Thanks.

Its worth mentioning that to

Its worth mentioning that to boot knoppix without mounting your Hard drive, you should type : "knoppix nofstab" at the boot prompt.

Accessing Debian Ext2/3 Volumes from XP Dual Boot System

On my dual boot boxes (Windows XP and Debian Unstable)
could you suggest a driver, useable
from XP which I can use to read
my Debian Volumes from within XP?

I am forced to keep XP on some boxes for
contract work though almost everything
I do is now done in Debian.

Thanks
Jimserac

ext2 IFS can work, BUT

ext2 IFS can work, BUT ext2fsd is better

2 reasons,

1) more options than ext2IFS,
2) its open source

hope it helps,
supermorph

Resizing ext3 partition

theres this utility called partimage which comes prepackaged with sysrecuecd . this creates a bzip of the data in a partition. so you can create a bzip then do whatever u want with the parition and then unzip using the same partimage into the new partition.

resizing a vmware disk

Thanks to your instructions I was able to resize
a vmware disk and the root partition of a virtual Ubuntu
running on Fedore3. Here are the steps
- resize the vmware disk using the utility 'vmware-vdiskmanager'
(not described in the various help of vmware, but the man
is selfexplaining, with an example)
- reboot the virtual machine with knoppix, using option 'noswap':
- remove swap partition with qtparted (yes, I could have
used directly parted)
- resize the root partition following your instructions
- added swap partition (again with qtparted - when it works
it is confortable...)
- rebooted virtual ubuntu and it worked as expected!
[obviously, before the operation I have archieved the virtual
machine with in a tgz file.

Thanks again!

Thanks for this howto

Very useful, thanks.

Marius
Switzerland

debian-installer and partman

To be honest, the easiest partition-management tool I've found so far is the partition manager "partman" included in debian-installer.

how to install?

I've read this in the debian Installation guide. However in the description of the package one is warned of installing it on a normal debian system. Actually, I'm just looking for a way to resize my little external usb-drive's partitions...

partman, cfdisk

I never used partman, but cfdisk should work just fine. Did you have trouble with that?

Uwe.

Reboot


for some strage reason parted didn't believe me that the space after hda6 was free. It did display it as free space, but the "resize" operation complained.

Did you reboot after removing the partition? Intel based hardware is weird in that respects, in that changes to the disk's partitions sometimes aren't seen until a reboot ...

Did you reboot after

Did you reboot after removing the partition?

Yes, I actually had deleted the hda7 partition a long time ago, the free disk space was just sitting there unused. I had multiple reboots since then (laptop)...

Thanks for the hints, Uwe.

Reboot

That is kinda weird, but I've had cfdisk and fdisk complain about changes the other has does to a disk's layout.

LVM

You probably should take a look at LVM for your next installation.

LVM

Will do, thanks. Are there any known problems or issues I should know about before switching to using LVM?

Uwe.

Hi, Why haven't you tried

Hi,

Why haven't you tried the standard tool 'resize2fs'? It comes with e2fsprogs. I've used it a couple of times and I didn't have any problems with it (although, not recently, since I use ReiserFS now).

And to merge two neighbouring partitions, (as in your case, hda6 and hda7), I use the good-old 'fdisk'. Delete both partitions, and re-create hda6 to start at the same point, and end where hda7 used to end. Be sure to set the display/entry units to sectors (the 'u' command), otherwise you might have rounding errors (and create the new partition slightly moved), since default display units (cylinders) are not the smallest possible unit.

On the other hand, it's best not to mess up with 'fdisk' unless you really know what you're doing, or you're willing to risk losing data. (That's the best way to learn, though ;-) ).

Cheers!
-=[david]=-

resize2fs

I remember having read somewhere that resize2fs had problems with ext3, too. But that was some time ago, maybe it does work now...

I didn't want to remove both partitions, as my hda6 was full with my data (and I couldn't easily backup 30 gigs back then)...

Uwe.

Resize Ext3 Partitions

This issue here is that you cannot resize Ext3 filesystems as they are a journaled filesystem. Any resizing would play havoc with Inode referrences. The only way to do this is to:

1. backup your data on the partition
2. delete the Ext3 partition
3. recreate partitions in the empty (deleted) filespace

Resize Ext3 Partitions

The function tune2fs appears to work perfectly.

#tune2fs -O^has_journal /dev/hdaN
Do whatever...

#tune2fs -j /dev/hdaN

I have resized my primary

I have resized my primary Ubuntu (Edgy Eft 6.10) partition from 27GB to 5GB and created another 5GB partition at the same time with the included GParted program with no problems noticed as yet. I had to do it by booting with the LiveCD and running System => Administration => Gnome Partition Editor from the CD.

gparted

I just resized my ext3 partition with gparted. Very easy. No problems encountered.

gparted is awesome!

After spending 2 days trying to resize a ext3 partition under vmware esx, I ran across your comment.

We don't have VirtualCenter, and thus can't get the licensed version of VMWare Converter, which means we can't use that product to increase the size of the drives during a copy. So, I then tried all the partition managment tools that come on Hiren's boot CD 9.2. None of them could do it, including partition magic 8.xx.

Thanks to your comment about GParted, I hunted it down, grabbed the GParted+Clonezilla live CD, and, after having to change from an LSI type SCSI controller to a Bus Logic type SCSI controller on a test vmware guest OS box, added the hard drive image to resize to that virtual machine, booted up the live CD, and within 15 minutes the expansion of the ext3 partition was complete.

GParted rocks! Link: http://gparted.sourceforge.net/

-Scott

gparted

Nice, thanks for reporting!

Uwe.

Great! it works for me!

I was running qtParted, parted, but they didn't work. They said the partition was busy eventhough I booted from a live CD. I'd tried the gparted too, but I thought it was dead because it kept scanning for 10 minutes with no result. After reading your post, I tried it again and was more patience. It worked finally :)

Thanh

resizing ext3 partitions

http://www.howtoforge.com/linux_resizing_ext3_partitions

if something goes wrong with gparted (it often does) just try to follow in which step you are and continue manually