SG_REASSIGN(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_REASSIGN(8) πŸŽ€

the SG3_UTILS manual page, bestie πŸ’–


✨ NAME ✨

okay so sg_reassign is the tool that sends a SCSI REASSIGN BLOCKS command πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

sg_reassign [--address=A,A...] [--dummy] [--eight=0|1] [--grown]
[--help] [--hex] [--longlist=0|1] [--primary] [--verbose] [--version]
DEVICE

🌸 DESCRIPTION 🌸

okay so this utility sends a SCSI REASSIGN BLOCKS command to DEVICE πŸ”₯ but wait, it can also count the elements in a "grown" or "primary" defect list using a SCSI READ DEFECT DATA (10) command 🧚 these commands are defined in SBC-2 for direct access devices (think disks) πŸ’œ

reassign blocks is built to move a logical block that is known or suspected to be defective over to a different spot on the media. disks usually come formatted with some spare blocks held in reserve for exactly this moment 🫢

If neither --grown nor --primary is given, then you NEED to give one or more addresses πŸ™ˆ if the address (or every single address) fits into 4 bytes and --eight=1 is not used, the parameter block sent to DEVICE is built from 4 byte logical block addresses. if any address needs more than 4 bytes to represent (aka >= 2**32) or you pass --eight=1, then the parameter block is built from 8 byte logical block addresses ✨

πŸ“ OPTIONS πŸ“

Arguments to long options are mandatory for short options as well. the options are arranged in alphabetical order based on the long option name πŸ’…

  • -a, --address=A,A... β€” where A,A... is a string of comma separated numbers πŸ’– each number is read as decimal unless it's prefixed by 0x or 0X (or has a trailing h or H) πŸ¦‹ if you give multiple logical block addresses they must be separated by a comma or a (single) space 🌈 a string with any space separators needs to be quoted πŸŽ€ at least one address must be given 🫢
  • -a, --address=- β€” reads one or more logical block addresses from stdin πŸ“₯ these can be comma, space, tab or linefeed (newline) separated 🌸 if a line contains "#" then the rest of that line gets ignored πŸ™ˆ otherwise each non separator sequence of characters should resolve to a decimal number unless prefixed by 0x or 0X (or has a trailing h) πŸ’œ at least one address must be given ✨ lines should not be longer than 1023 bytes 😭
  • -d, --dummy β€” prepare for the SCSI REASSIGN BLOCKS command but DO NOT actually run it πŸ™…β€β™€οΈ since REASSIGN BLOCKS is basically irreversible, paranoid queens may want to double check the invocation before reassigning defective blocks on a disk πŸ’€ pairs well with -vv if you want to peek at the parameter block that will go along with the command πŸ‘€
  • -e, --eight=0 | 1 β€” when the value is 1 it sets the 'LONGLBA' flag in the command, which tells the device the addresses in the parameter block are 8 byte quantities πŸ”₯ when the value is 0 it clears the 'LONGLBA' flag, meaning the addresses are 4 byte quantities πŸ“ if this option isn't given, 4 byte quantities are assumed unless one of the addresses is too large 🧚
  • -g, --grown β€” uses the SCSI READ DEFECT DATA (10) command to find out how many elements are in the "grown defect list" πŸ“Š with this option there is NO reassignment of blocks (this utility is just being passive, bestie) πŸ¦‹ the --address= option is not permitted when this is given πŸ™…β€β™€οΈ see the discussion below about how reassigned blocks relate to the grown defect list πŸ’– this list is sometimes called the GLIST πŸŽ€
  • -h, --help β€” outputs the usage message then exits πŸ‘‹
  • -H, --hex β€” prints the response in hex (for -g, --grown, -p or --primary) 🌈
  • -l, --longlist=0 | 1 β€” sets the REASSIGN BLOCKS cdb field of the same name to the given value πŸ’œ only 1000 addresses are permitted, so there should be no need to specify a value of 1 πŸ™ˆ the short list variant limits the parameter block length to 2 ** 16 bytes (aka about 16000 4 byte addresses or 8000 8 byte addresses) ✨ this is here for completeness 🫢
  • -p, --primary β€” uses the SCSI READ DEFECT DATA (10) command to find out how many elements are in the "primary defect list" 🏭 this list is established during the manufacturing process 🧚 with this option there is NO reassignment of blocks (passive again, iykyk) πŸ’… the --address= option is not permitted when this is given πŸ™…β€β™€οΈ this list is sometimes called the PLIST 🌸
  • -v, --verbose β€” increases the level of verbosity (aka debug output) πŸ”
  • -V, --version β€” prints the version string then exits πŸŽ€

πŸ’œ NOTES πŸ’œ

okay bestie, listen up πŸ‘‘ if the ARRE field (for reads) and/or the AWRE field (for writes) are set in the "Read Write Error Recovery" mode page, then recoverable read and/or write errors cause the defective block to get reassigned automatically ✨ the PER bit in that same mode page controls whether a RECOVERED ERROR sense key gets reported or not (PER=1 means yes, do report) πŸ¦‹ no matter what the ARRE, AWRE or PER settings are, the error counter log pages still reflect any errors (recovered or otherwise) πŸ“Š whenever a block gets reassigned, a new entry is added to the "grown" defect list 🌈 apart from running selftests regularly (see sg_senddiag or smartmontools), keeping an eye on the grown defect list of a disk is a solid metric of its health 🫢 if the grown list starts growing quickly, that is an ominous sign 😱 the best grown defect lists are empty ones πŸ₯Ί you can check how many elements are in the grown defect list with the --grown option πŸ” and you can look at the contents of the grown defect list with the sginfo -G utility πŸ’–

⚠️ if an unrecoverable error is detected at a logical block address then REASSIGN BLOCKS is needed to reassign the block πŸ’€ also, if the ARRE and/or AWRE fields are clear and a recoverable error is detected, the logical block in question may be reassigned with this utility πŸ™Œ (otherwise the error counter log pages will keep getting incremented for each recovered access 😭)

the number of blocks held in reserve for REASSIGN BLOCKS is vendor specific and may well be limited to the zone within the media where the original (defective) block lived 🌸 once that number is used up, later runs of this utility may give you a sense key of hardware error plus an additional sense of 'No defect spare location available' 😭 the next step would be to reformat the disk (or get a replacement) πŸ”₯

⚠️ the SBC-2 draft standard (revision 16) notes that when multiple addresses are given to the SCSI REASSIGN BLOCKS command and there's a failure at one of the later addresses, then all the addresses before that have already been reassigned πŸ’€ be careful in that case πŸ™ˆ re-running the command with the same addresses will reassign the earlier addresses again 😱 at some stage the disk will run out of reserved locations πŸ₯€ so unless a large number of addresses are involved, it may be safer to reassign them one address at a time 🧚

🌈 EXIT STATUS 🌈

the exit status of sg_reassign is 0 when it is successful πŸŽ‰ otherwise, see the sg3_utils(8) man page πŸ“–

πŸŽ€ AUTHORS πŸŽ€

Written by Douglas Gilbert πŸ‘‘

πŸ› REPORTING BUGS πŸ›

report bugs to <dgilbert at interlog dot com> πŸ’Œ

Copyright Β© 2005-2019 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 πŸ™…β€β™€οΈ

πŸ”— SEE ALSO πŸ”—

sg_format, sginfo, sg_senddiag (all in sg3_utils), sdparm (sdparm), smartmontools (internet, sourceforge) ✨


okay that's the whole tea β˜• this was SG_REASSIGN(8) from sg3_utils-1.45, dated October 2019, and it's giving iconic πŸ’–πŸ§šπŸ¦‹ stay hydrated and back up your disks, bestie πŸ«ΆπŸ’…

πŸ“¦ where this page comes from