LinuxCommandLibrary

mklost+found

Create lost+found directory on a filesystem

TLDR

Create a lost+found directory in the current directory

$ mklost+found
copy

SYNOPSIS

mklost+found directory

PARAMETERS

directory
    The path to the directory where the lost+found directory should be created. Often it's the filesystem's root directory (/).

DESCRIPTION

The mklost+found command creates a lost+found directory at the specified location, typically the root directory of a filesystem. This directory is crucial for the file system integrity check utility, fsck. When fsck finds orphaned files or directory fragments (files whose inode numbers are still valid but no longer referenced in the directory tree), it places them into the lost+found directory. This allows system administrators to recover data that would otherwise be lost. mklost+found ensures the directory has the correct permissions and ownership (typically root:root with mode 0700) to prevent unauthorized access and potential security issues. The command is typically executed automatically during the file system creation process. Creating a lost+found directory when the filesystem is in use might cause issues.

CAVEATS

Creating a lost+found directory on a mounted file system could lead to file system corruption or other unforeseen issues. It's best to create it on a freshly formatted or unmounted file system.

PERMISSIONS

The lost+found directory typically has permissions 0700 (drwx------), owned by root. This restricts access to only the root user, preventing unauthorized individuals from accessing or manipulating potentially sensitive data within the directory.

USAGE EXAMPLE

mklost+found /mnt/myfilesystem creates a lost+found directory within the root of the filesystem mounted at /mnt/myfilesystem.
This is typically done before mounting the filesystem and putting it into production.

HISTORY

The lost+found directory and the mklost+found command are fundamental parts of the Unix-like operating system philosophy of data recovery and system maintenance. It's been a standard feature since the early days of Unix file systems, providing a way to recover orphaned files after a system crash or unexpected shutdown. The exact implementation might vary slightly across different distributions and file system types, but the core functionality remains the same.

SEE ALSO

fsck(8)

Copied to clipboard