FSDB(8)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… FSDB β€” the FFS debugging/editing tool, bestie ✨

Okay so first things first: this is fsdb from the System Manager's Manual, and we're about to get deep into file system surgery. Buckle up, bestie. πŸŽ€

πŸ¦‹ SYNOPSIS

fsdb [-d] [-f] [-r] fsname

🌸 DESCRIPTION

So like, the fsdb utility opens fsname (usually a raw disk partition, no cap) and runs a command loop that lets you mess with the file system's inode data. It's giving main character energy for file system repair. πŸ’–

You get prompted to enter a command with fsdb (inum X)> where X is the currently selected i-number. The initial selected inode is the root of the file system (i-number 2). Iconic starting point, honestly. ✨

The command processor uses the editline(3) library, so you can use command line editing to reduce typing if desired β€” lowkey a lifesaver. When you exit the command loop, the file system superblock is marked dirty and any buffered blocks are written to the file system. Slay. πŸ’…

The following options are available:

✨ OPTIONS ✨

  • -d β€” Enable additional debugging output (which comes primarily from fsck(8)-derived code). It's giving verbose mode, and we stan. πŸ”₯
  • -f β€” Left for historical reasons and has no meaning. Literally just vibes at this point. πŸ’€
  • -r β€” Open the file system read/only, and disables all commands that would write to it. Safety first, bestie! 🫢

πŸ‘‘ COMMANDS πŸ‘‘

Besides the built-in editline(3) commands, fsdb supports these commands:

  • help β€” Print out the list of accepted commands. Your bestie when you're lost. 🧚
  • inode i-number β€” Select inode i-number as the new current inode. It's giving navigation, periodt. ⭐
  • back β€” Revert to the previously current inode. Undo button but make it Unix. πŸ™ˆ
  • clri i-number β€” Clear i-number. Bye bestie, you're cleared. πŸ’€
  • lookup name / cd name β€” Find name in the current directory and make its inode the current inode. Name may be a multi-component name or may begin with slash to indicate that the root inode should be used to start the lookup. If some component along the pathname is not found, the last valid directory encountered is left as the active inode. This command is valid only if the starting inode is a directory. It's giving follow the path, iykyk. πŸ¦‹
  • active / print β€” Print out the active inode. Main character reveal. πŸ’…
  • blocks β€” Print out the block list of the active inode. Note that the printout can become long for large files, since all indirect block pointers will also be printed. It's giving receipts, and they're LONG. 😭
  • findblk disk_block_number ... β€” Find the inode(s) owning the specified disk block(s) number(s). Note that these are not absolute disk blocks numbers, but offsets from the start of the partition. Detective mode: activated. πŸ”
  • uplink β€” Increment the active inode's link count. Go up, bestie! 🌈
  • downlink β€” Decrement the active inode's link count. And down we go. πŸ’œ
  • linkcount number β€” Set the active inode's link count to number. You're in control. πŸ‘‘
  • ls β€” List the current inode's directory entries. This command is valid only if the current inode is a directory. The way that this just works, obsessed. ✨
  • rm name / del name β€” Remove the entry name from the current directory inode. This command is valid only if the current inode is a directory. Not me deleting entries, periodt. πŸ’€
  • ln ino name β€” Create a link to inode ino under the name name in the current directory inode. This command is valid only if the current inode is a directory. Linking besties together! 🫢
  • chinum dirslot inum β€” Change the i-number in directory entry dirslot to inum. Swap it, slay. πŸ”₯
  • chname dirslot name β€” Change the name in directory entry dirslot to name. This command cannot expand a directory entry. You can only rename an entry if the name will fit into the existing directory slot. No cap: size matters here. πŸŽ€
  • chtype type β€” Change the type of the current inode to type. Type may be one of: file, dir, socket, or fifo. Glow-up for your inode. πŸ’…
  • chmod mode β€” Change the mode bits of the current inode to mode. You cannot change the file type with this subcommand; use chtype to do that. Respect the distinction, bestie. ✨
  • chflags flags β€” Change the file flags of the current inode to flags. Flag it up! 🚩
  • chown uid β€” Change the owner of the current inode to uid. New owner, new era. πŸ‘‘
  • chgrp gid β€” Change the group of the current inode to gid. Group chat reassignment. πŸ’¬
  • chgen gen β€” Change the generation number of the current inode to gen. Gen Z energy for generation numbers. πŸ¦‹
  • btime time / mtime time / ctime time / atime time β€” Change the creation (birth), modification, change, or access time (respectively) on the current inode to time. Time should be in the format YYYYMMDDHHMMSS[.nsec] where nsec is an optional nanosecond specification. If no nanoseconds are specified, the birthnsec, mtimensec, ctimensec, or atimensec field will be set to zero. Note that btime is available on UFS2 file systems only. Time travel, but make it file systems. ⏰
  • quit, q, exit, <EOF> β€” Exit the program. Bye bestie, see you never (until next time). πŸ‘‹πŸ’–

πŸ”— SEE ALSO

editline(3), fs(5), clri(8), fsck(8) β€” go read these too, bestie. iykyk. πŸ“š

🌈 HISTORY

The fsdb utility appeared in 4.3BSD-Tahoe. It used the source code for fsck(8) to implement most of the file system manipulation code. The remainder of fsdb appeared in NetBSD 1.1 written by John T. Kohl. It first appeared in FreeBSD 2.1.5 ported by Peter Wemm. It's giving legacy, and we respect the heritage. πŸŽ€

😭 BUGS

  • Manipulation of ``short'' symlinks has no effect. In particular, one should not try changing a symlink's type. It's giving undefined behavior, and not the cute kind. πŸ’€
  • You must specify modes as numbers rather than symbolic names. No symbolic shortcuts, bestie. πŸ”’
  • There are a bunch of other things that you might want to do which fsdb does not implement. It's giving limitations, and we simply must accept them. πŸ™ˆ

⚠️ WARNING

Use this tool with extreme caution--you can damage an FFS file system beyond what fsck(8) can repair. This is NOT a drill, bestie. You can literally break your file system so hard that fsck(8) can't even save you. Be careful out there. πŸ’€πŸ”₯

This iconic manual page comes from the Debian project, dated October 3, 2016. Stay safe out there doing your file system edits, bestie! πŸ«ΆπŸ’–βœ¨

πŸ“¦ where this page comes from