[mythtv-users] Change filesystem format in place?

Rod Smith mythtv at rodsbooks.com
Mon Jul 13 14:05:08 UTC 2015


On 07/11/2015 10:07 AM, Richard Shaw wrote:
> I currently have a 2TB drive formatted EXT4 and I'm considering moving
> to XFS but I don't have a spare 2TB drive to move the recordings to.
> 
> Does anyone have a practical method of doing this in place?
> 
> I'm thinking:
> 
> 1. expire just enough old recordings to create a decent amount of space
> 2. shrink the ext4 partition as much as possible
> 3. create an xfs partition
> 4. move as many recordings that fit to the xfs partition
> 5. Repeat steps 2-4 until I can remove the ext4 partition and use the
> whole drive for xfs.
> 
> Risky?

Yes. Others have said why, so I won't belabor the point.

UB40D wrote:
> Not the requested answer but if I were in your shoes I'd definitely buy
> another 2TB (or rather 4 or 5 TB) drive, connect both at the same time
> (even temporarily if there isn't space in the case) and do the transfer
> that way.

Overall, this is the safest and quickest approach.

Richard Shaw wrote:
> I wonder if I can shrink the front of the ext4 partition then?

Yes, you can; however, that poses the same risk as moving the front of
the XFS partition, so it doesn't really buy you anything. (At least, not
qualitatively; the probabilities of problems most likely vary from one
filesystem to another, but I don't happen to know what those exact
probabilities are.)

Dan Wilga wrote:
> There is also this project which purports to do this in one step.
> I have not used it, and cannot say how well it works:
> 
> https://github.com/cosmos72/fstransform 

That's intriguing; however, without a solid record of successful runs
(as in, lots of people had used it for months or years without
problems), I'd be reluctant to entrust 2TB of data to such a program.

There are two more alternatives that deserve mention. The first is to
use LVM. Instead of a simple XFS partition, make your target partition
an LVM with an XFS logical volume within it. You can then engage in the
shrink-grow-copy-repeat procedure you outlined earlier, with one
difference: To grow the target filesystem, you'll create a new partition
in the freed space, add it to the volume group, and expand the logical
volume. When you grow the logical volume, there will be no movement of
data; the logical volume will be extended much like a file on a
filesystem, by putting the new space wherever it's available, which in
this case will be in the new partition *BEFORE* the earlier data. This
will be faster and safer than moving your new filesystem and expanding
it. The result will be a fragmented filesystem, like this:

+-------------------------------------------------------+
|  Segment 4  |  Segment 3  |  Segment 2  |  Segment 1  |
+-------------------------------------------------------+

Assuming the segments aren't too small, this won't cause a real problem
for a MythTV setup. It will also be easier and safer to expand in the
future, since LVM can span multiple hard disks; or if you buy a bigger
disk as a replacement, you can create a new partition and expand into it.

This approach doesn't eliminate all risks, though; there will still be
risks associated with shrinking the original filesystem, which are
significant. Also, with your filesystem fragmented in this way, there
will be little hope of recovering it with a tool like TestDisk if the
LVM or partition table data structures go belly-up.

The second alternative is conceptually similar to the LVM solution, but
you'd implement it using MythTV storage groups rather than LVM. This
doesn't eliminate the risks associated with shrinking the original
partition, but it could make recovery easier if your partition table
becomes damaged.

Overall, I have to agree with the suggestion to buy a new disk. I'm
presenting the LVM and storage group options as alternatives only in
case you're on a very tight budget and can't afford a new disk at the
moment. Even then, it might be better to put off a filesystem conversion
until you can afford a new disk.

-- 
Rod Smith
rodsmith at rodsbooks.com



More information about the mythtv-users mailing list