0

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.

Then I found some link (http://www.howtoforge.com/how-to-resize-raid-partitions-shrink-and-grow-software-raid) that describing how to change partition of raid.

$ mdadm --grow /dev/md127 --size=max
mdadm: Cannot set device size for /dev/md127: Invalid argument

Failed here, "man mdadm" shows that "--grow" does not with raid 10. Need some help. Note, I use "--size=max" just for quick test, it won't work with other values either.

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.

1 Answers1

2

You have some confusion in your question that needs cleared up first, but it looks like the answer is that you can not do what you want.

First, lvresize is for changing the size of an lvm logical volume, so is not applicable to /dev/md127 because that is a raid array. Second, you asked to have unallocated space preceeding /dev/md127, which does not make sense because it is a raid array, so there is no space before or after it, in terms of the raid array. The raid may be built on top of partitions, like /dev/sda1 and /dev/sdb1, so that must be where you want preceding free space. mdadm can change the size of /dev/sda1 that is used for the raid, allowing you to use parted to shrink that partition, but that only moves the end of the array and partition, not the start. There is no way to move the start.

psusi
  • 37,551