You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could this tool be used to convert a filesystem from 512 byte sectors to 4k?
For example:
If one replaces or adds a 4K formatted disk to lvm or md raid it will transform the lvm volume/md raid to a 4K devices which some filesystems (xfs at least) struggle with.
XFS for example will give the error xfs device supports 4096 byte sectors (not 512) and refuse to mount again until you remove the 4K device (which tranforms the device back to a 512 byte one).
The text was updated successfully, but these errors were encountered:
Yes, you can use fstransform to create a new filesystem with different options and move the content of existing filesystem into it, in place.
For example, if a certain filesystem type (say, xfs) supports both 512B blocks and 4kB blocks,
and you have an existing xfs filesystem (for example inside device /dev/sda1) that uses 512B blocks, you can use
to convert it to 4kB blocks, while keeping the filesystem type to xfs.
I did a test with a loop filesystem:
$ ls -l img
-rw-r--r-- 1 root root 1073741824 Apr 15 17:17 img
$ file img
img: SGI XFS filesystem data (blksz 1024, inosz 512, v2 dirs)
$ losetup /dev/loop0 img
$ fstransform --opts-mkfs='-b size=4096' /dev/loop0 xfs
[ lots of output ... ]
17:19:56 fsck: /usr/sbin/fsck.xfs: XFS file system.
17:19:56 fstransform: completed successfully. device '/dev/loop0' now contains 'xfs' file-system
$ xfs_repair /dev/loop0 # because fsck.xfs does nothing...
[ lots of output ... ]
Phase 7 - verify and correct link counts...
done
$ file img
img: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs)
As usual, remember that I do not take any responsibility if fstransform damages your filesystem.
Read: you'd better have a backup!
P.S. the operations described above create a new filesystem, and move the existing content into it.
They know nothing about RAID, LVM etc. and in particular they know nothing about xfs support for disks with 4kB sectors.
They just create a filesystem with a blocksize = 4kB, which is hopefully compatible with disks having 4kB sectors.
That's fantastic!
It's a big issue when replacing disks in a raid/lvm and the new disks you get are 4K, every single post I've seen about that issue has the only resolution to get a new replacement disk or format the array/volume, which is a tough solution in many cases.
This issue can be closed, but it's good that this solution is documented somewhere. Perhaps it would be good to add this to the readme so others that are seeking a solution can stumble across this.
cosmos72
changed the title
Converting between 512 and 4096 byte sectors?
Converting between 512 and 4096 byte sectors? [question] [solved]
Apr 16, 2021
Could this tool be used to convert a filesystem from 512 byte sectors to 4k?
For example:
If one replaces or adds a 4K formatted disk to lvm or md raid it will transform the lvm volume/md raid to a 4K devices which some filesystems (xfs at least) struggle with.
XFS for example will give the error
xfs device supports 4096 byte sectors (not 512)
and refuse to mount again until you remove the 4K device (which tranforms the device back to a 512 byte one).The text was updated successfully, but these errors were encountered: