SG_SYNC(8)
โจ 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โCOUNTis how many blocks to synchronize, starting from and includingLBA. default is 0. when it's 0, every block in the cache fromLBAup to the highest block address gets synchronized โจ-g,--group=GNโGNis 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โLBAis 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โSECSis 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 ๐
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
- alpine 3.24: sg3_utils-doc 1.48-r0 ยท BSD-2-Clause AND GPL-2.0-or-later
- arch rolling: sg3_utils 1.49-1 ยท GPL-2.0-or-later AND BSD-2-Clause
- centos-stream 10: sg3_utils 1.48-11.el10 ยท GPL-2.0-or-later AND BSD-2-Clause
- debian trixie: sg3-utils 1.48-3~deb13u1
- fedora 43: sg3_utils 1.48-10.fc43 ยท GPL-2.0-or-later AND BSD-2-Clause
- fedora 43: sg3_utils 1.48-6.fc43 ยท GPL-2.0-or-later AND BSD-2-Clause
- fedora 44: sg3_utils 1.48-10.fc44 ยท GPL-2.0-or-later AND BSD-2-Clause
- fedora 44: sg3_utils 1.48-8.fc44 ยท GPL-2.0-or-later AND BSD-2-Clause
- nixos 26.05: sg3_utils 1.48
- nixpkgs unstable: sg3_utils 1.49
- ubuntu questing: sg3-utils 1.48-2ubuntu1
- ubuntu resolute: sg3-utils 1.48-3ubuntu3
- ubuntu resolute: sg3-utils 1.48-3ubuntu3.2
- ubuntu stonking: sg3-utils 1.48-3ubuntu5
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms