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]

DESCRIPTION

The mklost+found command is a utility specifically designed for FAT (File Allocation Table) filesystems, including MS-DOS, VFAT, and FAT32. Its primary purpose is to create the special lost+found directory on a mounted FAT filesystem.

This directory serves as a designated place for the filesystem consistency checker, fsck.msdos (also known as dosfsck), to store orphaned files and directories. Orphaned files are those that exist on the disk but are no longer linked to any directory entry. During a filesystem check, if dosfsck finds such unlinked files, it will attempt to recover them and place them into the lost+found directory. Without this directory, dosfsck would not have a standard location to put recovered data, potentially leading to data loss or unrecoverable sectors.

It's crucial to run mklost+found on a FAT partition before performing filesystem checks with dosfsck to ensure proper recovery operations. The command typically creates the directory with strict permissions (e.g., 0700) to protect recovered data.

CAVEATS

This command is specifically for FAT (MS-DOS, VFAT, FAT32) filesystems. It is not used for Ext2/3/4, XFS, Btrfs, or other Linux native filesystems, which have their own mechanisms (e.g., mke2fs creates lost+found automatically).

The lost+found directory created by mklost+found must reside on the target FAT filesystem.

It's essential to create this directory before running dosfsck on a FAT partition to ensure proper recovery of orphaned files.

PURPOSE OF <I>LOST+FOUND</I>

The lost+found directory is a special directory on Unix-like filesystems used by filesystem checkers (like fsck, dosfsck) to store orphaned files and directories. When the checker finds data blocks that are marked as used but are not associated with any file or directory (i.e., they are "lost"), it attempts to reconstruct the corresponding file entries and places them into the lost+found directory. These recovered files are typically named by their inode number (or equivalent, for FAT). Users can then inspect this directory to try and recover their data manually.

HISTORY

The mklost+found utility is part of the dosfstools package, which provides a suite of utilities for manipulating FAT filesystems on Unix-like operating systems. It has been a standard component of this package for a long time, serving the fundamental purpose of preparing FAT volumes for integrity checks, reflecting the long-standing need for robust filesystem maintenance tools across different filesystem types.

SEE ALSO

fsck.msdos(8), dosfsck(8), fsck(8), mkfs.msdos(8), The lost+found directory concept

Copied to clipboard