SG_SYNC(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

โœจ NAME โœจ

sg_sync, but make it cute: sg_sync โ€” send SCSI SYNCHRONIZE CACHE command ๐Ÿงš

๐ŸŽ€ SYNOPSIS ๐ŸŽ€

sg_sync [--16] [--count=COUNT] [--group=GN] [--help] [--immed]
[--lba=LBA] [--sync-nv] [--timeout=SECS] [--verbose] [--version] DEVICE

๐Ÿ’– DESCRIPTION ๐Ÿ’–

okay so this command sends a SYNCHRONIZE CACHE(10) or SYNCHRONIZE CACHE(16) command to DEVICE ๐Ÿซถ these are defined for SCSI block devices (see SBC-3). if it works, they make sure that any blocks whose newest versions are sitting in cache get written to the medium, aka "synchronized with" the medium โœจ

if LBA and COUNT are both zero (their defaults), then everything in the cache gets synchronized ๐Ÿ’… if LBA is greater than zero but COUNT is zero, then blocks from and including LBA up to the highest lba on the device get synchronized ๐ŸŒธ and if both LBA and COUNT are non zero, then blocks in the range LBA to LBA+COUNT-1 inclusive get synchronized with the medium ๐Ÿฆ‹

๐ŸŒˆ OPTIONS ๐ŸŒˆ

Arguments to long options are mandatory for short options as well. no skipping the value, bestie ๐Ÿ™ˆ

  • -S, --16 โ€” runs a SYNCHRONIZE CACHE(16) command. the default is SYNCHRONIZE CACHE(10) ๐Ÿ’œ
  • -c, --count=COUNT โ€” COUNT is how many blocks to synchronize, starting from and including LBA. default is 0. when it's 0, every block in the cache from LBA up to the highest block address gets synchronized โœจ
  • -g, --group=GN โ€” GN is the group number, anywhere from 0 to 63 inclusive. the default is 0. group numbers are used to segregate data collected within the device. this is a new feature in SBC-2 and can probably be ignored for the time being ๐Ÿ“
  • -h, --help โ€” outputs the usage message, then exits ๐Ÿซง
  • -i, --immed โ€” sets the IMMED bit in the SYNCHRONIZE CACHE command. if the command format is acceptable, this tells the device to return a GOOD status right away instead of waiting for the cached blocks to be synchronized (aka written) to the medium โšก
  • -l, --lba=LBA โ€” LBA is the lowest logical block address in the cache to synchronize to the medium. default is 0 ๐ŸŽ€
  • -s, --sync-nv โ€” synchronizes the (volatile) cache with the non-volatile cache ๐ŸงŠ without this option (or if the device has no non-volatile cache), the sync goes to the medium instead. the SYNC_NV bit was made obsolete in SBC-3 revision 35d ๐Ÿ’€
  • -t, --timeout=SECS โ€” SECS is how many seconds the OS waits for the SYNCHRONIZE CACHE(16) to finish before it tries to cancel the command ๐Ÿ˜ญ cancelling commands (usually with the task management function "abort task") is best avoided, so be careful. this option only works together with --16. the default timeout is 60 seconds for both SYNCHRONIZE CACHE(10) and SYNCHRONIZE CACHE(16). and fun fact: timeout issues can be avoided with --immed ๐Ÿ•ฐ๏ธ
  • -v, --verbose โ€” turns up the verbosity (aka debug output) ๐Ÿ”Š
  • -V, --version โ€” prints the version string, then exits ๐Ÿท๏ธ

๐Ÿฆ‹ NOTES ๐Ÿฆ‹

with SYNCHRONIZE CACHE(16), LBA can be up to 64 bits and COUNT up to 32 bits. with SYNCHRONIZ CACHE(10) (that's how the original page spells it, lol), LBA can be up to 32 bits and COUNT up to 16 bits ๐Ÿงฎ

numeric arguments (like LBA) can include multiplicative suffixes or be given in hexadecimal. see the "NUMERIC ARGUMENTS" section in the sg3_utils(8) man page ๐Ÿ”ข

๐ŸŒธ EXIT STATUS ๐ŸŒธ

the exit status of sg_sync is 0 when it's successful ๐Ÿฅณ otherwise, check out the sg3_utils(8) man page ๐Ÿ”

๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

Written by Douglas Gilbert, the legend himself ๐Ÿซก

๐Ÿž REPORTING BUGS ๐Ÿž

report bugs to dgilbert at interlog dot com ๐Ÿ“ฌ

Copyright ยฉ 2004-2018 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_start(sg3_utils) ๐Ÿงš


ur all set, bestie ๐Ÿ’… this was sg3_utils-1.43, May 2018, and it's the SG_SYNC(8) page ๐Ÿฆ‹โœจ

๐Ÿ“ฆ where this page comes from