Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can parted resize a partition without resizing the underlying filesystem?

Currently, it prints a warning:

WARNING: you are attempting to use parted to operate on (resize) a file system. parted's file system manipulation code is not as robust as what you'll find in dedicated, file-system-specific packages like e2fsprogs. We recommend you use parted only to manipulate partition tables, whenever possible. Support for performing most operations on most types of file systems will be removed in an upcoming release.

share|improve this question
Why would one want to resize the partition but not the filesysem? – amotzg Aug 13 '12 at 15:13
If you would resize the partition but not the filesystem, the filesystem would still believe these sectors are still available for it for free say it with the vocabulary of Dwarf Fortress, that will lead to !!!FUN!!!. – Bobby Aug 13 '12 at 15:18
In my particular case, because parted doesn't resize btrfs yet. But one could, say, want two filesystems in one partition, so the second is somewhat hidden. – goncalopp Aug 13 '12 at 15:18
@Bobby Yes, that would occur if you try to shrink the partition without shrinking the filesystem first. If you're looking to expand a partition, the order is reversed. – goncalopp Aug 13 '12 at 15:42

Resizing a partition is a common task particularly when using hardware RAID, virtual machines etc where disk sized can (and do) change size, even while the OS is running.

Unfortunately, parted will not resize a partition (and never really was able to). To achieve the same thing you must delete the original partition an recreate it with a new end address. You must keep the start address the same or you may corrupt all your data. You must also set any flags back to their original values to ensure that the partition is used correctly at the next boot.

Before starting, make sure you have a backup of you system!

In parted, switch the display unit to sectors with u s and print out you current values with p

It is worth writing these values down in case you break something and need to restore your original partitions.

Then delete the existing partition rm

Then create a new partition with mkpart

Finally set the flags with toggle

After quiting parted you may need to run partprobe to make the kernel update it's view of the partitions eg: cat /proc/partitions

When using LVM2, you can make the partition bigger and then run pvresize /dev/... and your new capacity will become available to the volume group. You can then proceed with lvresize and resize2fs or whatever is suited to your OS.

share|improve this answer
I wish this would get fixed in parted... – mcr Mar 9 at 18:31

What you're trying to do is risky and difficult at best, and disastrous at worst.

Filesystems are designed to occupy an entire partition by themselves. It is "valid" to have a filesystem that is formatted to occupy less than the entire partition, but it would be very much a hack to try and use the unclaimed space for another filesystem.

There are two types of "resize": grow and shrink.

If your initial state is that one filesystem occupies the entirety of a partition, and you grow the partition (make it larger), that basically means you tweaked the partition table (just a bunch of numbers in a small area of the hard drive, the format depends on your partition type, e.g. MBR or GPT) so that there will be more blocks allocated to the partition than the filesystem is using. The filesystem will not use the additional blocks at the end of the partition, because the filesystem still thinks it's operating on a smaller partition than it actually has. A "smart" filesystem COULD easily detect and start using the remaining space, but I don't know if any actually do that. Either way, you'll probably get at least warnings when mounting your drive.

If you try to shrink the partition (make it smaller) without also shrinking the filesystem, you WILL lose data: when the filesystem tries to write to blocks that are beyond the end of the partition, the device node will throw an exception for trying to write past the boundary of the partition, and the filesystem will throw an I/O error up to userspace. Any data you previously had in the re-partitioned space will be lost.

Either way, you're shooting yourself in the foot. I have no idea how you would even begin to tell a filesystem to mount a filesystem starting at a certain block within a partition. A command like mount /dev/sda1 implies that the mount starts at the very beginning of the partition. Yes, you would be slightly obscuring the location of any data in the "hidden partition" if you were able to create a filesystem in there; but anyone savvy enough to want to poke around on your hard drive is going to very easily find it, so don't think you're gaining any measure of security.

If you are worried about other users of the computer or unauthorized persons with physical access to the computer, you should use full disk encryption based on strong cryptography. Merely hiding a partition isn't going to confuse most physical-access users for very long if they are looking for interesting things on your disk.

Check out fdisk or cfdisk if you still want to do this, but you're voiding every warranty in the book (and then some) by doing this...

share|improve this answer
As to how to mount a filesystem in the middle of a partition, mount -o offset would suffice, I think. Your point about disk encryption is well taken (please note I'm not actually trying to do the two-filesystems-in-one-partition scheme, only trying to resize a btrfs partition). I'm still wondering if parted can do this (as the warning seems to imply), but will look into fdisk and cfdisk, thanks! – goncalopp Aug 13 '12 at 18:38
This is a bad answer because There is no other way if one wanted to shrink ext4. Parted will error out when using move or resize with "Error: File system has an incompatible feature enabled..." – user1133275 May 22 '15 at 16:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.