SG_PREVENT(8)

πŸ“¦
version 1.49 Β· 3 versions
, in alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ SG_PREVENT(8) ✨

okay so this is the SG_PREVENT(8) page from the SG3_UTILS crew πŸ’… it's all about sg_prevent and it is so iconic 🫢

πŸŽ€ NAME

sg_prevent - send SCSI PREVENT ALLOW MEDIUM REMOVAL command πŸ¦‹

🌸 SYNOPSIS

sg_prevent [--allow] [--help] [--prevent=PC] [--verbose] [--version]
DEVICE

πŸ’– DESCRIPTION

bestie, this one sends a SCSI PREVENT ALLOW MEDIUM REMOVAL command to DEVICE ✨ by default it's giving "nope, nobody is ejecting that disc" πŸ™…β€β™€οΈ it stops the removing or ejecting of the medium from a drive. it does this by ignoring the SCSI START STOP UNIT command (see sg_start) and ignoring the eject button when someone presses it πŸ’€ drives that hold removable disks, tape cartridges or cd/dvd media usually implement this command, so it's lowkey everywhere 🌈

ngl the "prevent" codes are a little different depending on what you're dealing with. for disks and tapes they're covered by SBC-3 and SSC-3, but for cd/dvd drives they're covered by MMC-5 🧚 the "prevent codes" described on this page are the MMC-5 ones, so keep that in mind 🫢

✨ OPTIONS ✨

quick heads up: arguments to long options are mandatory for short options as well πŸŽ€

  • -a, --allow β€” allows medium removal πŸ”“ this is the same as setting --prevent=2. it can't be mixed with the --prevent=PC option, so pick one: no options at all (which means prevent removal), this one, or --prevent=PC πŸ’…
  • -h, --help β€” shows the usage message and then exits πŸ™ˆ
  • -p, --prevent=PC β€” PC is the prevent code value πŸ’œ the defined values are: 0 allows removal, 1 prevents removal (this is the default πŸ‘‘), 2 allows persistent removal, and 3 prevents persistent removal. so "persistent" here means that whichever initiator (port) successfully uses code 3 blocks other initiators (ports) from allowing removal 😭 a persistent prevent can be cleared by the owner allowing persistent removal with code 2, by a power cycle, by anything that resets the device (LU), or by some special commands like various service actions of Persistent Reserve Out (see SPC-3) 🌸
  • -v, --verbose β€” turns up the verbosity, which means more debug output πŸ”
  • -V, --version β€” prints the version string and then exits ⭐

🌷 EXIT STATUS

if it works, sg_prevent exits with 0 βœ… if it doesn't, you'll need to check the sg3_utils(8) man page for the exit status 🫢

πŸ‘©β€πŸ’» AUTHORS

written by Douglas Gilbert πŸ‘‘ the legend himself ✨

πŸ› REPORTING BUGS

found a bug? report it to <dgilbert at interlog dot com> πŸ“¬ (that's the address as written in the page πŸ’Œ)

Copyright Β© 2004-2012 Douglas Gilbert πŸŽ€

this software is distributed under a BSD-2-Clause license. there is NO warranty, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE πŸ’€ use it with love but also with eyes open πŸ™ˆ

πŸ¦‹ SEE ALSO

sg_start(sg3_utils), sg_persist(sg3_utils) 🧚


ok that's the whole tea πŸ“ this page came from sg3_utils-1.35, dated November 2012, and it's all SG_PREVENT(8) πŸ’– slay forever, bestie πŸ’…βœ¨

πŸ“¦ where this page comes from