shrink ext4 partition

Posted by user276851 on Ask Ubuntu See other posts from Ask Ubuntu or by user276851
Published on 2014-05-27T21:19:32Z Indexed on 2014/05/27 22:13 UTC
Read the original article Hit count: 228

Filed under:
|
|
|

My question is similar to Move ext4 partition, but the challenge I couldn't figure out is how to shrink a partition from the start.

So suppose originally the partition (with raid) is like this.

(************** /dev/md127 ***************)

After resizing, I want to achieve like this.

(*** unallocated ***)(**** /dev/md127 ****)

Note, I cannot use gparted, and parted does not support ext4.

The commands I have tried so far,

% resize2fs -p /dev/md127 1676G    # <== This is good.

% lvreduce -L 1676G /dev/md127
Path required for Logical Volume "md127"
Please provide a volume group name
Run `lvreduce --help' for more information.

Failed here, I guess it may be because the underlying partition is primary and the lvreduce only works on logical? Anyway, no idea.

Then after that, I am thinking to create another partition right after this one, copy the data to that partition, and remove this one, like.

1. (************** /dev/md127 ***************)

2. (**** /dev/md127 ****)(*** new partition **)

3. (*** unallocated ****)(**** /dev/md127 ****)

Thanks for the help.

© Ask Ubuntu or respective owner

Related posts about partitioning

Related posts about gparted