cosmos72 / fstransform

tool for in-place filesystem conversion (for example from jfs/xfs/reiser to ext2/ext3/ext4) without backup
GNU General Public License v2.0
278 stars 28 forks source link

Converting XFS RAID5 to EXT4 #50

Open NickJH opened 1 year ago

NickJH commented 1 year ago

Hi, this is a question rather than a problem. I have a (degraded as one disk is missing) 54TB RAID5 array (was 4 x 18TB) formatted as XFS. I don't want to replace the missing disk, but just shrink the filesystem to allow me to convert the array to a 3 disk RAID5. There is a bit less than 10TB of data on the array. Are the conversion times dependent on actual disk usage or partition size? I am trying to gauge how long it may take. 36 days at 16h/1TB based on the partition size I can't do but I can think about 160h based on the data size.

cosmos72 commented 1 year ago

Hi NickJH, the fastest option is undoubtedly copying the data on some other disk, then reformat, and finally copy back the data - provided you have 10TB free space somewhere, of course.

Converting a 54TB filesystem with 10TB data in it will take approximately as long as converting a ~30TB full (or almost full) filesystem. The reason is there are three main steps during conversion:

  1. Create a sparse loop file, format it, mount it and move all files into it. The time it takes is proportional to actual disk usage
  2. Remap the loop file onto the underlying device (partition, raid device...). Again, the time it takes is proportional to actual disk usage.
  3. Cleanup: all unused space in the converted filesystem is filled with zeroes. This takes a time proportional to the partition size.

Skipping step 3. is a tempting speedup, but in my experience it has the bad habit of leaving a corrupted filesystem

cosmos72 commented 1 year ago

Update: if XFS supports shrinking the filesystem, you should definitely shrink it - and the underlying partition - before running fstransform.

In this way, you'll be converting a smaller filesystem and step 3. above will be accordingly faster.

Alternatively, there is a way to convince fstransform to shrink the filesystem while converting it, but I don't remember if the main program supports it directly or you'll have to fiddle with the low-level tools fsmove and fsremap

NickJH commented 1 year ago

That is the nub of the issue. I am trying to change the array from 4 x 18TB to 3 x 18TB due to disk failure and not needing the extra space. The array is XFS formatted but XFS does not support shrinking of partitions. To get round it, I was going to convert it to EXT4 so I could shrink it and then leave it as EXT4. I may be able to get enough disks together to be able to temporarily move the data off the array then go for a simple reformat, or even a full array rebuild to save doing a reshape.