Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
possible duplicate of How to resize / enlarge / grow a non-LVM ext4 partition –  bodhi.zazen May 27 at 21:25
    
Question modified, definitely not duplicate. –  user276851 May 27 at 23:21
add comment

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
Got it, thanks! –  user276851 May 28 at 19:26
add comment

After some searching, I finally realize it is not possible to --grow RAID 10.

share|improve this answer
add comment

Your Answer

 
discard

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.