nerdexam
CompTIA

LX0-103 · Question #122

Creating a hard link to an ordinary file returns an error. What could be the reason for this?

The correct answer is E. The source and the target are on different filesystems.. Hard links reference inodes directly, and inode numbers are only unique within a single filesystem, so hard links cannot span different filesystems.

Devices, Linux Filesystems, Filesystem Hierarchy Standard

Question

Creating a hard link to an ordinary file returns an error. What could be the reason for this?

Options

  • AThe source file is hidden.
  • BThe source file is read-only.
  • CThe source file is a shell script.
  • DThe source file is already a hard link.
  • EThe source and the target are on different filesystems.

How the community answered

(49 responses)
  • A
    6% (3)
  • C
    4% (2)
  • D
    2% (1)
  • E
    88% (43)

Why each option

Hard links reference inodes directly, and inode numbers are only unique within a single filesystem, so hard links cannot span different filesystems.

AThe source file is hidden.

Hidden files (prefixed with a dot) are valid hard link sources; the hidden attribute only affects default directory listing visibility.

BThe source file is read-only.

Read-only permissions on the source file do not prevent hard link creation, because the operation modifies the directory entry rather than the file's data or metadata.

CThe source file is a shell script.

Shell scripts are ordinary files and can be hard-linked without any restriction.

DThe source file is already a hard link.

A file that is already a hard link (link count greater than 1) can still receive additional hard links, as all directory entries pointing to the same inode are treated equally by the filesystem.

EThe source and the target are on different filesystems.Correct

Hard links work by creating an additional directory entry pointing to the same inode as the source file, but inode numbers are local to and only meaningful within their own filesystem. When the source and target reside on different filesystems (for example, / and /home on separate partitions), the kernel cannot create a valid inode reference across that boundary and returns an 'Invalid cross-device link' error.

Concept tested: Hard link limitations across filesystem boundaries

Source: https://man7.org/linux/man-pages/man1/ln.1.html

Topics

#hard links#inode#filesystem boundaries#link constraints

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice