nerdexam
CompTIA

XK0-004 · Question #533

A user deleted a log file because the disk was running out of space on a system running a mission- critical application. Even though the log file was large, the available disk space did not…

The correct answer is D. Option D. On Linux, deleting a file removes only the directory entry; disk blocks are not reclaimed until all open file descriptors to that file are closed, requiring the administrator to truncate the file through the open descriptor in /proc.

Troubleshooting and Diagnostics

Question

A user deleted a log file because the disk was running out of space on a system running a mission- critical application. Even though the log file was large, the available disk space did not increase. The systems administrator determines the following files are still open:

Which of the following should the systems administrator perform to BEST free up disk space?

Exhibits

XK0-004 question #533 exhibit 1
XK0-004 question #533 exhibit 2

Options

  • AOption A
  • BOption B
  • COption C
  • DOption D

How the community answered

(23 responses)
  • A
    17% (4)
  • B
    9% (2)
  • C
    26% (6)
  • D
    48% (11)

Why each option

On Linux, deleting a file removes only the directory entry; disk blocks are not reclaimed until all open file descriptors to that file are closed, requiring the administrator to truncate the file through the open descriptor in /proc.

AOption A

This option does not address the open file handle held by the running process, so the kernel will not release the disk blocks even if a different action is taken.

BOption B

This option likely involves restarting the application to close the file descriptor, which is inappropriate for a mission-critical application when a non-disruptive alternative exists.

COption C

This option does not correctly locate or truncate the specific open file descriptor that is preventing the deleted log file's disk blocks from being freed.

DOption DCorrect

Option D truncates the open file descriptor by redirecting to /dev/null via the path /proc/<pid>/fd/<fd_number>, which immediately zeroes the file size and causes the kernel to release the underlying disk blocks without stopping the application. This works because the kernel tracks inode reference counts separately from directory entries, so the blocks remain allocated as long as any process holds an open file descriptor, but zeroing the content through that descriptor reclaims the space.

Concept tested: Reclaiming disk space from files with open file descriptors

Source: https://www.kernel.org/doc/html/latest/filesystems/vfs.html

Topics

#file descriptors#disk space recovery#lsof#deleted open files

Community Discussion

No community discussion yet for this question.

Full XK0-004 Practice