LFS-SWAP_LAYOUTS(1)

NAME
lfs-swap_layouts - swap the data layout and OST objects between two files

SYNOPSIS
lfs swap_layouts [-n] FILE1 FILE2

DESCRIPTION
Swap the data (layout and OST objects) of two regular files. After the swap, FILE1 will contain the data that was in FILE2, and FILE2 will contain the data that was in FILE1. The file names and paths remain unchanged.

This operation is atomic and is commonly used for:

•   Replacing a file's contents while maintaining the same inode

•   Implementing atomic file updates

•   Data migration between different storage layouts

RESTRICTIONS
The two files must meet the following requirements:

•   Both files must be regular files (not directories)

•   Both files must be in the same Lustre filesystem

•   Both files must be owned by the same user

•   Both files must reside on the same MDT

•   Both files must be writable by the user

OPTIONS

-n  Do not preserve mtime and atime. By default, the modification time (mtime) and access time (atime) are preserved during the swap.

EXAMPLES
Swap the layouts of two files:
        $ lfs swap_layouts /mnt/lustre/file1 /mnt/lustre/file2

Swap layouts without preserving timestamps:
        $ lfs swap_layouts -n /mnt/lustre/file1 /mnt/lustre/file2

Atomic file replacement pattern:
        $ cp /mnt/lustre/original /mnt/lustre/original.new
        $ # modify /mnt/lustre/original.new
        $ lfs swap_layouts /mnt/lustre/original /mnt/lustre/original.new
        $ rm /mnt/lustre/original.new

NOTES
The swap operation exchanges the data objects and layout information, but the file metadata (permissions, ownership, extended attributes) remains with the original file names.

Swapping the layout of two directories is not permitted.

AVAILABILITY
The lfs swap_layouts command is part of the lustre(7) filesystem package.

SEE ALSO
lfs(1), lfs-migrate(1), lfs-setstripe(1)