Fsck−TheUNIX†FileSystemCheckProgram RevisedJuly28,1983 MarshallKirkMcKusick ComputerSystemsResearchGroup ComputerScienceDivision DepartmentofElectricalEngineeringandComputerScience UniversityofCalifornia,Berkeley Berkeley,CA94720 T.J.Kowalski BellLaboratories MurrayHill,NewJersey07974 ABSTRACT Thisdocumentreflectstheuseoffsckwiththe4.2BSDfilesystemorganization.ThisisarevisionoftheoriginalpaperwrittenbyT.J.Kowalski. FileSystemCheckProgram(fsck)isaninteractivefilesystemcheckand repairprogram.FsckusestheredundantstructuralinformationintheUNIXfile systemtoperformseveralconsistencychecks.Ifaninconsistencyisdetected,itis reportedtotheoperator,whomayelecttofixorignoreeachinconsistency. Theseinconsistenciesresultfromthepermanentinterruptionofthefilesystem updates,whichareperformedeverytimeafileismodified.Unlesstherehasbeen ahardwarefailure,fsckisabletorepaircorruptedfilesystemsusingprocedures basedupontheorderinwhichUNIXhonorsthesefilesystemupdaterequests. Thepurposeofthisdocumentistodescribethenormalupdatingofthefile system,todiscussthepossiblecausesoffilesystemcorruption,andtopresentthe correctiveactionsimplementedbyfsck.Boththeprogramandtheinteraction betweentheprogramandtheoperatoraredescribed. †UNIXisatrademarkofBellLaboratories. ThisworkwasdoneundergrantsfromtheNationalScienceFoundationundergrantMCS80-05144, andtheDefenseAdvanceResearchProjectsAgency(DoD)underArpaOrderNo.4031monitoredby NavalElectronicSystemCommandunderContractNo.N00039-82-C-0235.

Fsck -i- Contents TABLEOFCONTENTS 1.Introduction 2.Overviewofthefilesystem .1.Superblock .2.SummaryInformation .3.Cylindergroups .4.Fragments .5.Updatestothefilesystem 3.Fixingcorruptedfilesystems .1.Detectingandcorrectingcorruption .2.Superblockchecking .3.Freeblockchecking .4.Checkingtheinodestate .5.Inodelinks .6.Inodedatasize .7.Checkingthedataassociatedwithaninode .8.Filesystemconnectivity Acknowledgements References 4.AppendixA .1.Conventions .2.Initialization .3.Phase1-CheckBlocksandSizes .4.Phase1b-RescanformoreDups .5.Phase2-CheckPathnames .6.Phase3-CheckConnectivity .7.Phase4-CheckReferenceCounts .8.Phase5-CheckCylgroups .9.Phase6-SalvageCylinderGroups .10.Cleanup CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -1- Introduction 1.Introduction Thisdocumentreflectstheuseoffsckwiththe4.2BSDfilesystemorganization.Thisisa revisionoftheoriginalpaperwrittenbyT.J.Kowalski. WhenaUNIXoperatingsystemisbroughtup,aconsistencycheckofthefilesystemsshould alwaysbeperformed.Thisprecautionarymeasurehelpstoinsureareliableenvironmentforfile storageondisk.Ifaninconsistencyisdiscovered,correctiveactionmustbetaken.Fsckrunsin twomodes.Normallyitisrunnon-interactivelybythesystemafteranormalboot.Whenrun-ninginthismode,itwillonlymakechangestothefilesystemthatareknowntoalwaysbecor-rect.Ifanunexpectedinconsistencyisfoundfsckwillexitwithanon-zeroexitstatus,leavingthe systemrunningsingle-user.Typicallytheoperatorthenrunsfsckinteractively.Whenrunningin thismode,eachproblemislistedfollowedbyasuggestedcorrectiveaction.Theoperatormust decidewhetherornotthesuggestedcorrectionshouldbemade. Thepurposeofthismemoistodispelthemystiquesurroundingfilesysteminconsistencies. Itfirstdescribestheupdatingofthefilesystem(thecalmbeforethestorm)andthendescribes filesystemcorruption(thestorm).Finally,thesetofdeterministiccorrectiveactionsusedbyfsck (theCoastGuardtotherescue)ispresented. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -2-OverviewoftheFileSystem 2.Overviewofthefilesystem Thefilesystemisdiscussedindetailin[Mckusick83];thissectiongivesabriefoverview. 2.1.Superblock Afilesystemisdescribedbyitssuper-block.Thesuper-blockisbuiltwhenthefilesystemis created(newfs(8))andneverchanges.Thesuper-blockcontainsthebasicparametersofthefile system,suchasthenumberofdatablocksitcontainsandacountofthemaximumnumberof files.Becausethesuper-blockcontainscriticaldata,newfsreplicatesittoprotectagainstcatas-trophicloss.Thedefaultsuperblockalwaysresidesatafixedoffsetfromthebeginningofthefile system’sdiskpartition.Theredundantsuperblocksarenotreferencedunlessaheadcrashor otherharddiskerrorcausesthedefaultsuper-blocktobeunusable.Theredundantblocksare sprinkledthroughoutthediskpartition. Withinthefilesystemarefiles.Certainfilesaredistinguishedasdirectoriesandcontaincollectionsofpointerstofilesthatmaythemselvesbedirectories.Everyfilehasadescriptorassociatedwithitcalledaninode.Theinodecontainsinformationdescribingownershipofthefile,time stampsindicatingmodificationandaccesstimesforthefile,andanarrayofindicespointingto thedatablocksforthefile.Inthissection,weassumethatthefirst12blocksofthefileare directlyreferencedbyvaluesstoredintheinodestructureitself†.Theinodestructuremayalso containreferencestoindirectblockscontainingfurtherdatablockindices.Inafilesystemwitha 4096byteblocksize,asinglyindirectblockcontains1024furtherblockaddresses,adoublyindirectblockcontains1024addressesoffurthersingleindirectblocks,andatriplyindirectblockcontains1024addressesoffurtherdoublyindirectblocks. Inordertocreatefileswithupto2↑32bytes,usingonlytwolevelsofindirection,theminimumsizeofafilesystemblockis4096bytes.Thesizeoffilesystemblockscanbeanypowerof twogreaterthanorequalto4096.Theblocksizeofthefilesystemismaintainedinthesuperblock,soitispossibleforfilesystemsofdifferentblocksizestobeaccessiblesimultaneouslyon thesamesystem.Theblocksizemustbedecidedwhennewfscreatesthefilesystem;theblock sizecannotbesubsequentlychangedwithoutrebuildingthefilesystem. 2.2.Summaryinformation Associatedwiththesuperblockisnonreplicatedsummaryinformation.Thesummary informationchangesasthefilesystemismodified.Thesummaryinformationcontainsthe numberofblocks,fragments,inodesanddirectoriesinthefilesystem. 2.3.Cylindergroups Thefilesystempartitionsthediskintooneormoreareascalledcylindergroups.Acylinder groupiscomprisedofoneormoreconsecutivecylindersonadisk.Eachcylindergroupincludes inodeslotsforfiles,ablockmapdescribingavailableblocksinthecylindergroup,andsummary informationdescribingtheusageofdatablockswithinthecylindergroup.Afixednumberof inodesisallocatedforeachcylindergroupwhenthefilesystemiscreated.Thecurrentpolicyis toallocateoneinodeforeach2048bytesofdiskspace;thisisexpectedtobefarmoreinodesthan willeverbeneeded. Allthecylindergroupbookkeepinginformationcouldbeplacedatthebeginningofeach cylindergroup.Howeverifthisapproachwereused,alltheredundantinformationwouldbeon thetopplatter.Asinglehardwarefailurethatdestroyedthetopplattercouldcausethelossofall copiesoftheredundantsuper-blocks.Thusthecylindergroupbookkeepinginformationbeginsat afloatingoffsetfromthebeginningofthecylindergroup.Theoffsetforthei+1stcylindergroup isaboutonetrackfurtherfromthebeginningofthecylindergroupthanitwasfortheithcylindergroup.Inthisway,theredundantinformationspiralsdownintothepack;anysingletrack, cylinder,orplattercanbelostwithoutlosingallcopiesofthesuper-blocks.Exceptforthefirst cylindergroup,thespacebetweenthebeginningofthecylindergroupandthebeginningofthe †Theactualnumbermayvaryfromsystemtosystem,butisusuallyintherange5-13. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -3-Overviewofthefilesystem cylindergroupinformationstoresdata. 2.4.Fragments Toavoidwasteinstoringsmallfiles,thefilesystemspaceallocatordividesasinglefilesystemblockintooneormorefragments.Thefragmentationofthefilesystemisspecifiedwhenthe filesystemiscreated;eachfilesystemblockcanbeoptionallybrokeninto2,4,or8addressable fragments.Thelowerboundonthesizeofthesefragmentsisconstrainedbythedisksectorsize; typically512bytesisthelowerboundonfragmentsize.Theblockmapassociatedwitheach cylindergrouprecordsthespaceavailabilityatthefragmentlevel.Alignedfragmentsareexaminedtodetermineblockavailability. Onafilesystemwithablocksizeof4096bytesandafragmentsizeof1024bytes,afileis representedbyzeroormore4096byteblocksofdata,andpossiblyasinglefragmentedblock.Ifa filesystemblockmustbefragmentedtoobtainspaceforasmallamountofdata,theremainderof theblockismadeavailableforallocationtootherfiles.Forexample,consideran11000bytefile storedona4096/1024bytefilesystem.Thisfileusestwofullsizeblocksanda3072bytefragment.Ifnofragmentswithatleast3072bytesareavailablewhenthefileiscreated,afullsize blockissplityieldingthenecessary3072bytefragmentandanunused1024bytefragment.This remainingfragmentcanbeallocatedtoanotherfile,asneeded. 2.5.Updatestothefilesystem Everyworkingdayhundredsoffilesarecreated,modified,andremoved.Everytimeafileis modified,theoperatingsystemperformsaseriesoffilesystemupdates.Theseupdates,when writtenondisk,yieldaconsistentfilesystem.Thefilesystemstagesallmodificationsofcritical information;modificationcaneitherbecompletedorcleanlybackedoutafteracrash.Knowing theinformationthatisfirstwrittentothefilesystem,deterministicprocedurescanbedeveloped torepairacorruptedfilesystem.Tounderstandthisprocess,theorderthattheupdaterequests werebeinghonoredmustfirstbeunderstood. Whenauserprogramdoesanoperationtochangethefilesystem,suchasawrite,thedata tobewritteniscopiedintoaninternalin-corebufferinthekernel.Normally,thediskupdateis handledasynchronously;theuserprocessisallowedtoproceedeventhoughthedatahasnotyet beenwrittentothedisk.Thedata,alongwiththeinodeinformationreflectingthechange,is eventuallywrittenouttodisk.Therealdiskwritemaynothappenuntillongafterthewritesystemcallhasreturned.Thusatanygiventime,thefilesystem,asitresidesonthedisk,lagsthe stateofthefilesystemrepresentedbythein-coreinformation. Thediskinformationisupdatedtoreflectthein-coreinformationwhenthebufferis requiredforanotheruse,whenasync(2)isdone(at30secondintervals)by/etc/update(8),orby manualoperatorinterventionwiththesync(8)command.Ifthesystemishaltedwithoutwriting outthein-coreinformation,thefilesystemonthediskwillbeinaninconsistentstate. Ifallupdatesaredoneasynchronously,severalseriousinconsistenciescanarise.Oneinconsistencyisthatablockmaybeclaimedbytwoinodes.Suchaninconsistencycanoccurwhenthe systemishaltedbeforethepointertotheblockintheoldinodehasbeenclearedinthecopyof theoldinodeonthedisk,andafterthepointertotheblockinthenewinodehasbeenwrittenout tothecopyofthenewinodeonthedisk.Here,thereisnodeterministicmethodfordeciding whichinodeshouldreallyclaimtheblock.Asimilarproblemcanarisewithamultiplyclaimed inode. Theproblemwithasynchronousinodeupdatescanbeavoidedbydoingallinodedeallocationssynchronously.Consequently,inodesandindirectblocksarewrittentothedisksynchronously(i.e.theprocessblocksuntiltheinformationisreallywrittentodisk)whentheyare beingdeallocated.Similarlyinodesarekeptconsistentbysynchronouslydeleting,adding,or changingdirectoryentries. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -4-Fixingcorruptedfilesystems 3.Fixingcorruptedfilesystems Afilesystemcanbecomecorruptedinseveralways.Themostcommonofthesewaysare impropershutdownproceduresandhardwarefailures. Filesystemsmaybecomecorruptedduringanuncleanhalt.Thishappenswhenproper shutdownproceduresarenotobserved,physicallywrite-protectingamountedfilesystem,ora mountedfilesystemistakenoff-line.Themostcommonoperatorproceduralfailureisforgetting tosyncthesystembeforehaltingtheCPU. Filesystemsmaybecomefurthercorruptedifproperstartupproceduresarenotobserved, e.g.,notcheckingafilesystemforinconsistencies,andnotrepairinginconsistencies.Allowinga corruptedfilesystemtobeused(and,thus,tobemodifiedfurther)canbedisastrous. Anypieceofhardwarecanfailatanytime.Failurescanbeassubtleasabadblockona diskpack,orasblatantasanon-functionaldisk-controller. 3.1.Detectingandcorrectingcorruption Normallyfsckisrunnon-interactively.Inthismodeitwillonlyfixcorruptionsthatare expectedtooccurfromanuncleanhalt.Theseactionsareapropersubsetoftheactionsthatfsck willtakewhenitisrunninginteractively.Throughoutthispaperweassumethatfsckisbeingrun interactively,andallpossibleerrorscanbeencountered.Whenaninconsistencyisdiscoveredin thismode,fsckreportstheinconsistencyfortheoperatortochoseacorrectiveaction. Aquiescent‡filesystemmaybecheckedforstructuralintegritybyperformingconsistency checksontheredundantdataintrinsictoafilesystem.Theredundantdataiseitherreadfrom thefilesystem,orcomputedfromotherknownvalues.Thefilesystemmustbeinaquiescent statewhenfsckisrun,sincefsckisamulti-passprogram. Inthefollowingsections,wediscussmethodstodiscoverinconsistenciesandpossiblecorrectiveactionsforthecylindergroupblocks,theinodes,theindirectblocks,andthedatablockscontainingdirectoryentries. 3.2.Super-blockchecking Themostcommonlycorruptediteminafilesystemisthesummaryinformationassociated withthesuper-block.Thesummaryinformationispronetocorruptionbecauseitismodified witheverychangetothefilesystem’sblocksorinodes,andisusuallycorruptedafteranunclean halt. Thesuper-blockischeckedforinconsistenciesinvolvingfile-systemsize,numberofinodes, free-blockcount,andthefree-inodecount.Thefile-systemsizemustbelargerthanthenumberof blocksusedbythesuper-blockandthenumberofblocksusedbythelistofinodes.Thefile-systemsizeandlayoutinformationarethemostcriticalpiecesofinformationforfsck.While thereisnowaytoactuallycheckthesesizes,sincetheyarestaticallydeterminedbynewfs,fsck cancheckthatthesesizesarewithinreasonablebounds.Allotherfilesystemchecksrequirethat thesesizesbecorrect.Iffsckdetectscorruptioninthestaticparametersofthedefaultsuperblock,fsckrequeststheoperatortospecifythelocationofanalternatesuper-block. 3.3.Freeblockchecking Fsckchecksthatalltheblocksmarkedasfreeinthecylindergroupblockmapsarenot claimedbyanyfiles.Whenalltheblockshavebeeninitiallyaccountedfor,fsckchecksthatthe numberoffreeblocksplusthenumberofblocksclaimedbytheinodesequalsthetotalnumberof blocksinthefilesystem. Ifanythingiswrongwiththeblockallocationmaps,fsckwillrebuildthem,basedonthelist ithascomputedofallocatedblocks. ‡I.e.,unmountedandnotbeingwrittenon. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -5-Fixingcorruptedfilesystems Thesummaryinformationassociatedwiththesuper-blockcountsthetotalnumberoffree blockswithinthefilesystem.Fsckcomparesthiscounttothenumberoffreeblocksitfound withinthefilesystem.Ifthetwocountsdonotagree,thenfsckreplacestheincorrectcountin thesummaryinformationbytheactualfree-blockcount. Thesummaryinformationcountsthetotalnumberoffreeinodeswithinthefilesystem. Fsckcomparesthiscounttothenumberoffreeinodesitfoundwithinthefilesystem.Ifthetwo countsdonotagree,thenfsckreplacestheincorrectcountinthesummaryinformationbythe actualfree-inodecount. 3.4.Checkingtheinodestate Anindividualinodeisnotaslikelytobecorruptedastheallocationinformation.However, becauseofthegreatnumberofactiveinodes,afewoftheinodesareusuallycorrupted. Thelistofinodesinthefilesystemischeckedsequentiallystartingwithinode2(inode0 marksunusedinodes;inode1issavedforfuturegenerations)andprogressingthroughthelast inodeinthefilesystem.Thestateofeachinodeischeckedforinconsistenciesinvolvingformat andtype,linkcount,duplicateblocks,badblocks,andinodesize. Eachinodecontainsamodeword.Thismodeworddescribesthetypeandstateofthe inode.Inodesmustbeoneofsixtypes:regularinode,directoryinode,symboliclinkinode,special blockinode,specialcharacterinode,orsocketinode.Inodesmaybefoundinoneofthreeallocationstates:unallocated,allocated,andneitherunallocatednorallocated.Thislaststatesuggests anincorrectlyformatedinode.Aninodecangetinthisstateifbaddataiswrittenintotheinode list.Theonlypossiblecorrectiveactionisforfsckistocleartheinode. 3.5.Inodelinks Eachinodecountsthetotalnumberofdirectoryentrieslinkedtotheinode.Fsckverifies thelinkcountofeachinodebystartingattherootofthefilesystem,anddescendingthroughthe directorystructure.Theactuallinkcountforeachinodeiscalculatedduringthedescent. Ifthestoredlinkcountisnon-zeroandtheactuallinkcountiszero,thennodirectoryentry appearsfortheinode.Ifthishappens,fsckwillplacethedisconnectedfileinthelost+found directory.Ifthestoredandactuallinkcountsarenon-zeroandunequal,adirectoryentrymay havebeenaddedorremovedwithouttheinodebeingupdated.Ifthishappens,fsckreplacesthe incorrectstoredlinkcountbytheactuallinkcount. Eachinodecontainsalist,orpointerstolists(indirectblocks),ofalltheblocksclaimedby theinode.Sinceindirectblocksareownedbyaninode,inconsistenciesinindirectblocksdirectly affecttheinodethatownsit. Fsckcompareseachblocknumberclaimedbyaninodeagainstalistofalreadyallocated blocks.Ifanotherinodealreadyclaimsablocknumber,thentheblocknumberisaddedtoalist ofduplicateblocks.Otherwise,thelistofallocatedblocksisupdatedtoincludetheblocknumber. Ifthereareanyduplicateblocks,fsckwillperformapartialsecondpassovertheinodelist tofindtheinodeoftheduplicatedblock.Thesecondpassisneeded,sincewithoutexaminingthe filesassociatedwiththeseinodesforcorrectcontent,notenoughinformationisavailabletodeterminewhichinodeiscorruptedandshouldbecleared.Ifthisconditiondoesarise(onlyhardware failurewillcauseit),thentheinodewiththeearliestmodifytimeisusuallyincorrect,andshould becleared.Ifthishappens,fsckpromptstheoperatortoclearbothinodes.Theoperatormust decidewhichoneshouldbekeptandwhichoneshouldbecleared. Fsckcheckstherangeofeachblocknumberclaimedbyaninode.Iftheblocknumberis lowerthanthefirstdatablockinthefilesystem,orgreaterthanthelastdatablock,thenthe blocknumberisabadblocknumber.Manybadblocksinaninodeareusuallycausedbyanindirectblockthatwasnotwrittentothefilesystem,aconditionwhichcanonlyoccuriftherehas beenahardwarefailure.Ifaninodecontainsbadblocknumbers,fsckpromptstheoperatorto clearit. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -6-Fixingcorruptedfilesystems 3.6.Inodedatasize Eachinodecontainsacountofthenumberofdatablocksthatitcontains.Thenumberof actualdatablocksisthesumoftheallocateddatablocksandtheindirectblocks.Fsckcomputes theactualnumberofdatablocksandcomparesthatblockcountagainsttheactualnumberof blockstheinodeclaims.Ifaninodecontainsanincorrectcountfsckpromptstheoperatortofix it. Eachinodecontainsathirty-twobitsizefield.Thesizeisthenumberofdatabytesinthe fileassociatedwiththeinode.Theconsistencyofthebytesizefieldisroughlycheckedbycomputingfromthesizefieldthemaximumnumberofblocksthatshouldbeassociatedwiththe inode,andcomparingthatexpectedblockcountagainsttheactualnumberofblockstheinode claims. 3.7.Checkingthedataassociatedwithaninode Aninodecandirectlyorindirectlyreferencethreekindsofdatablocks.Allreferenced blocksmustbethesamekind.Thethreetypesofdatablocksare:plaindatablocks,symbolic linkdatablocks,anddirectorydatablocks.Plaindatablockscontaintheinformationstoredina file;symboliclinkdatablockscontainthepathnamestoredinalink.Directorydatablockscontaindirectoryentries.Fsckcanonlycheckthevalidityofdirectorydatablocks. Eachdirectorydatablockischeckedforseveraltypesofinconsistencies.Theseinconsistenciesincludedirectoryinodenumberspointingtounallocatedinodes,directoryinodenumbersthat aregreaterthanthenumberofinodesinthefilesystem,incorrectdirectoryinodenumbersfor‘‘.’’ and‘‘..’’,anddirectoriesthatarenotattachedtothefilesystem.Iftheinodenumberinadirectorydatablockreferencesanunallocatedinode,thenfsckwillremovethatdirectoryentry.Again, thisconditioncanonlyarisewhentherehasbeenahardwarefailure. Ifadirectoryentryinodenumberreferencesoutsidetheinodelist,thenfsckwillremovethat directoryentry.Thisconditionoccursifbaddataiswrittenintoadirectorydatablock. Thedirectoryinodenumberentryfor‘‘.’’mustbethefirstentryinthedirectorydata block.Theinodenumberfor‘‘.’’mustreferenceitself;e.g.,itmustequaltheinodenumberfor thedirectorydatablock.Thedirectoryinodenumberentryfor‘‘..’’mustbethesecondentryin thedirectorydatablock.Itsvaluemustequaltheinodenumberfortheparentofthedirectory entry(ortheinodenumberofthedirectorydatablockifthedirectoryistherootdirectory).If thedirectoryinodenumbersareincorrect,fsckwillreplacethemwiththecorrectvalues. 3.8.Filesystemconnectivity Fsckchecksthegeneralconnectivityofthefilesystem.Ifdirectoriesarenotlinkedintothe filesystem,thenfscklinksthedirectorybackintothefilesysteminthelost+founddirectory. Thisconditiononlyoccurswhentherehasbeenahardwarefailure. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -7-Fixingcorruptedfilesystems Acknowledgements IthankBillJoy,SamLeffler,RobertElzandDennisRitchiefortheirsuggestionsandhelp inimplementingthenewfilesystem.ThanksalsotoRobertHenryforhiseditorialinputtoget thisdocumenttogether.Finallywethankoursponsors,theNationalScienceFoundationunder grantMCS80-05144,andtheDefenseAdvanceResearchProjectsAgency(DoD)underArpa OrderNo.4031monitoredbyNavalElectronicSystemCommandunderContractNo. N00039-82-C-0235.(KirkMcKusick,July1983) IwouldliketothankLarryA.WehrforadvicethatleadtothefirstversionoffsckandRick B.BrandtforadaptingfscktoUNIX/TS.(T.Kowalski,July1979) References [Dolotta78]Dolotta,T.A.,andOlsson,S.B.eds.,UNIXUser’sManual,Edition1.1 (January1978). [Joy83]Joy,W.,Cooper,E.,Fabry,R.,Leffler,S.,McKusick,M.,andMosher,D. 4.2BSDSystemManual,UniversityofCaliforniaatBerkeley,Computer SystemsResearchGroupTechnicalReport#4,1982. [McKusick83]McKusick,M.,Joy,W.,Leffler,S.,andFabry,R.AFastFileSystemfor UNIX,UniversityofCaliforniaatBerkeley,ComputerSystemsResearch GroupTechnicalReport#7,1982. [Ritchie78]Ritchie,D.M.,andThompson,K.,TheUNIXTime-SharingSystem,The BellSystemTechnicalJournal57,6(July-August1978,Part2),pp. 1905-29. [Thompson78]Thompson,K.,UNIXImplementation,TheBellSystemTechnicalJournal 57,6(July-August1978,Part2),pp.1931-46. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -8-AppendixA−FsckErrorConditions 4.AppendixA−FsckErrorConditions 4.1.Conventions Fsckisamulti-passfilesystemcheckprogram.Eachfilesystempassinvokesadifferent Phaseofthefsckprogram.Aftertheinitialsetup,fsckperformssuccessivePhasesovereachfile system,checkingblocksandsizes,path-names,connectivity,referencecounts,andthemapoffree blocks,(possiblyrebuildingit),andperformssomecleanup. Normallyfsckisrunnon-interactivelytopreenthefilesystemsafteranuncleanhalt.While preen’ingafilesystem,itwillonlyfixcorruptionsthatareexpectedtooccurfromanunclean halt.Theseactionsareapropersubsetoftheactionsthatfsckwilltakewhenitisrunninginteractively.Throughoutthisappendixmanyerrorshaveseveraloptionsthattheoperatorcantake. Whenaninconsistencyisdetected,fsckreportstheerrorconditiontotheoperator.Ifaresponse isrequired,fsckprintsapromptmessageandwaitsforaresponse.Whenpreen’ingmosterrors arefatal.Forthosethatareexpected,theresponsetakenisnoted.Thisappendixexplainsthe meaningofeacherrorcondition,thepossibleresponses,andtherelatederrorconditions. TheerrorconditionsareorganizedbythePhaseofthefsckprograminwhichtheycanoccur. TheerrorconditionsthatmayoccurinmorethanonePhasewillbediscussedininitialization. 4.2.Initialization Beforeafilesystemcheckcanbeperformed,certaintableshavetobesetupandcertain filesopened.Thissectionconcernsitselfwiththeopeningoffilesandtheinitializationoftables. Thissectionlistserrorconditionsresultingfromcommandlineoptions,memoryrequests,opening offiles,statusoffiles,filesystemsizechecks,andcreationofthescratchfile.Alloftheinitializationerrorsarefatalwhenthefilesystemisbeingpreen’ed. Coption? Cisnotalegaloptiontofsck;legaloptionsare−b,−y,−n,and−p.Fsckterminatesonthis errorcondition.Seethefsck(8)manualentryforfurtherdetail. cannotallocNNNbytesforblockmap cannotallocNNNbytesforfreemap cannotallocNNNbytesforstatemap cannotallocNNNbytesforlncntp Fsck’srequestformemoryforitsvirtualmemorytablesfailed.Thisshouldneverhappen.Fsck terminatesonthiserrorcondition.Seeaguru. Can’topenchecklistfile:F ThefilesystemchecklistfileF(usually/etc/fstab)cannotbeopenedforreading.Fsckterminatesonthiserrorcondition.CheckaccessmodesofF. Can’tstatroot Fsck’srequestforstatisticsabouttherootdirectory‘‘/’’failed.Thisshouldneverhappen.Fsck terminatesonthiserrorcondition.Seeaguru. Can’tstatF Can’tmakesenseoutofnameF Fsck’srequestforstatisticsaboutthefilesystemFfailed.Whenrunningmanually,itignoresthis filesystemandcontinuescheckingthenextfilesystemgiven.CheckaccessmodesofF. Can’topenF Fsck’srequestattempttoopenthefilesystemFfailed.Whenrunningmanually,itignoresthis filesystemandcontinuescheckingthenextfilesystemgiven.CheckaccessmodesofF. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -9-AppendixA−FsckErrorConditions F:(NOWRITE) Eitherthe−nflagwasspecifiedorfsck’sattempttoopenthefilesystemFforwritingfailed. Whenrunningmanually,allthediagnosticsareprintedout,butnomodificationsareattemptedto fixthem. fileisnotablockorcharacterdevice;OK Youhavegivenfsckaregularfilenamebymistake.Checkthetypeofthefilespecified. PossibleresponsestotheOKpromptare: YESIgnorethiserrorcondition. NOignorethisfilesystemandcontinuescheckingthenextfilesystemgiven. Oneofthefollowingmessageswillappear: MAGICNUMBERWRONG NCGOUTOFRANGE CPGOUTOFRANGE NCYLDOESNOTJIVEWITHNCG*CPG SIZEPREPOSTEROUSLYLARGE TRASHEDVALUESINSUPERBLOCK andwillbefollowedbythemessage: F:BADSUPERBLOCK:B USE-bOPTIONTOFSCKTOSPECIFYLOCATIONOFANALTERNATE SUPER-BLOCKTOSUPPLYNEEDEDINFORMATION;SEEfsck(8). Thesuperblockhasbeencorrupted.Analternativesuperblockmustbeselectedfromamong thoselistedbynewfs(8)whenthefilesystemwascreated.Forfilesystemswithablocksizeless than32K,specifying−b32isagoodfirstchoice. INTERNALINCONSISTENCY:M Fsck’shashadaninternalpanic,whosemessageisspecifiedasM.Thisshouldneverhappen.See aguru. CANNOTSEEK:BLKB(CONTINUE) Fsck’srequestformovingtoaspecifiedblocknumberBinthefilesystemfailed.Thisshould neverhappen.Seeaguru. PossibleresponsestotheCONTINUEpromptare: YESattempttocontinuetorunthefilesystemcheck.Often,howevertheproblemwillpersist. Thiserrorconditionwillnotallowacompletecheckofthefilesystem.Asecondrunoffsck shouldbemadetore-checkthisfilesystem.Iftheblockwaspartofthevirtualmemory buffercache,fsckwillterminatewiththemessage‘‘FatalI/Oerror’’. NOterminatetheprogram. CANNOTREAD:BLKB(CONTINUE) Fsck’srequestforreadingaspecifiedblocknumberBinthefilesystemfailed.Thisshouldnever happen.Seeaguru. PossibleresponsestotheCONTINUEpromptare: YESattempttocontinuetorunthefilesystemcheck.Often,however,theproblemwillpersist. Thiserrorconditionwillnotallowacompletecheckofthefilesystem.Asecondrunoffsck shouldbemadetore-checkthisfilesystem.Iftheblockwaspartofthevirtualmemory buffercache,fsckwillterminatewiththemessage‘‘FatalI/Oerror’’. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -10-AppendixA−FsckErrorConditions NOterminatetheprogram. CANNOTWRITE:BLKB(CONTINUE) Fsck’srequestforwritingaspecifiedblocknumberBinthefilesystemfailed.Thediskiswriteprotected.Seeaguru. PossibleresponsestotheCONTINUEpromptare: YESattempttocontinuetorunthefilesystemcheck.Often,however,theproblemwillpersist. Thiserrorconditionwillnotallowacompletecheckofthefilesystem.Asecondrunoffsck shouldbemadetore-checkthisfilesystem.Iftheblockwaspartofthevirtualmemory buffercache,fsckwillterminatewiththemessage‘‘FatalI/Oerror’’. NOterminatetheprogram. 4.3.Phase1−CheckBlocksandSizes Thisphaseconcernsitselfwiththeinodelist.Thissectionlistserrorconditionsresulting fromcheckinginodetypes,settingupthezero-link-counttable,examininginodeblocknumbers forbadorduplicateblocks,checkinginodesize,andcheckinginodeformat.Allerrorsinthis phaseexceptINCORRECTBLOCKCOUNTarefatalifthefilesystemisbeingpreen’ed, CGC:BADMAGICNUMBERThemagicnumberofcylindergroupCiswrong.Thisusuallyindicatesthatthecylindergroupmapshavebeendestroyed.Whenrunningmanuallythe cylindergroupismarkedasneedingtobereconstructed. UNKNOWNFILETYPEI=I(CLEAR)ThemodewordoftheinodeIindicatesthatthe inodeisnotaspecialblockinode,specialcharacterinode,socketinode,regularinode,symbolic link,ordirectoryinode. PossibleresponsestotheCLEARpromptare: YESde-allocateinodeIbyzeroingitscontents.ThiswillalwaysinvoketheUNALLOCATED errorconditioninPhase2foreachdirectoryentrypointingtothisinode. NOignorethiserrorcondition. LINKCOUNTTABLEOVERFLOW(CONTINUE) Aninternaltableforfsckcontainingallocatedinodeswithalinkcountofzerohasnomoreroom. RecompilefsckwithalargervalueofMAXLNCNT. PossibleresponsestotheCONTINUEpromptare: YEScontinuewiththeprogram.Thiserrorconditionwillnotallowacompletecheckofthefile system.Asecondrunoffsckshouldbemadetore-checkthisfilesystem.Ifanotherallo-catedinodewithazerolinkcountisfound,thiserrorconditionisrepeated. NOterminatetheprogram. BBADI=I InodeIcontainsblocknumberBwithanumberlowerthanthenumberofthefirstdatablockin thefilesystemorgreaterthanthenumberofthelastblockinthefilesystem.ThiserrorconditionmayinvoketheEXCESSIVEBADBLKSerrorconditioninPhase1ifinodeIhastoo manyblocknumbersoutsidethefilesystemrange.Thiserrorconditionwillalwaysinvokethe BAD/DUPerrorconditioninPhase2andPhase4. EXCESSIVEBADBLKSI=I(CONTINUE) Thereismorethanatolerablenumber(usually10)ofblockswithanumberlowerthanthe numberofthefirstdatablockinthefilesystemorgreaterthanthenumberoflastblockinthe filesystemassociatedwithinodeI. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -11-AppendixA−FsckErrorConditions PossibleresponsestotheCONTINUEpromptare: YESignoretherestoftheblocksinthisinodeandcontinuecheckingwiththenextinodeinthe filesystem.Thiserrorconditionwillnotallowacompletecheckofthefilesystem.Asecondrunoffsckshouldbemadetore-checkthisfilesystem. NOterminatetheprogram. BDUPI=I InodeIcontainsblocknumberBwhichisalreadyclaimedbyanotherinode.Thiserrorcondition mayinvoketheEXCESSIVEDUPBLKSerrorconditioninPhase1ifinodeIhastoomany blocknumbersclaimedbyotherinodes.ThiserrorconditionwillalwaysinvokePhase1bandthe BAD/DUPerrorconditioninPhase2andPhase4. EXCESSIVEDUPBLKSI=I(CONTINUE) Thereismorethanatolerablenumber(usually10)ofblocksclaimedbyotherinodes. PossibleresponsestotheCONTINUEpromptare: YESignoretherestoftheblocksinthisinodeandcontinuecheckingwiththenextinodeinthe filesystem.Thiserrorconditionwillnotallowacompletecheckofthefilesystem.Asecondrunoffsckshouldbemadetore-checkthisfilesystem. NOterminatetheprogram. DUPTABLEOVERFLOW(CONTINUE) Aninternaltableinfsckcontainingduplicateblocknumbershasnomoreroom.Recompilefsck withalargervalueofDUPTBLSIZE. PossibleresponsestotheCONTINUEpromptare: YEScontinuewiththeprogram.Thiserrorconditionwillnotallowacompletecheckofthefile system.Asecondrunoffsckshouldbemadetore-checkthisfilesystem.Ifanotherdupli-cateblockisfound,thiserrorconditionwillrepeat. NOterminatetheprogram. PARTIALLYALLOCATEDINODEI=I(CLEAR) InodeIisneitherallocatednorunallocated. PossibleresponsestotheCLEARpromptare: YESde-allocateinodeIbyzeroingitscontents. NOignorethiserrorcondition. INCORRECTBLOCKCOUNTI=I(XshouldbeY)(CORRECT) TheblockcountforinodeIisXblocks,butshouldbeYblocks.Whenpreen’ingthecountiscorrected. PossibleresponsestotheCORRECTpromptare: YESreplacetheblockcountofinodeIwithY. NOignorethiserrorcondition. 4.4.Phase1B:RescanforMoreDups Whenaduplicateblockisfoundinthefilesystem,thefilesystemisrescannedtofindthe inodewhichpreviouslyclaimedthatblock.Thissectionliststheerrorconditionwhentheduplicateblockisfound. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -12-AppendixA−FsckErrorConditions BDUPI=I InodeIcontainsblocknumberBthatisalreadyclaimedbyanotherinode.Thiserrorcondition willalwaysinvoketheBAD/DUPerrorconditioninPhase2.Youcandeterminewhichinodes haveoverlappingblocksbyexaminingthiserrorconditionandtheDUPerrorconditioninPhase 1. 4.5.Phase2−CheckPathnames Thisphaseconcernsitselfwithremovingdirectoryentriespointingtoerrorconditioned inodesfromPhase1andPhase1b.Thissectionlistserrorconditionsresultingfromrootinode modeandstatus,directoryinodepointersinrange,anddirectoryentriespointingtobadinodes. Allerrorsinthisphasearefatalifthefilesystemisbeingpreen’ed. ROOTINODEUNALLOCATED.TERMINATING. Therootinode(usuallyinodenumber2)hasnoallocatemodebits.Thisshouldneverhappen. Theprogramwillterminate. NAMETOOLONGF Anexcessivelylongpathnamehasbeenfound.Thisisusuallyindicativeofloopsinthefilesystemnamespace.Thiscanoccurifthesuperuserhasmadecircularlinkstodirectories.The offendinglinksmustberemoved(byaguru). ROOTINODENOTDIRECTORY(FIX) Therootinode(usuallyinodenumber2)isnotdirectoryinodetype. PossibleresponsestotheFIXpromptare: YESreplacetherootinode’stypetobeadirectory.Iftherootinode’sdatablocksarenotdirectoryblocks,aVERYlargenumberoferrorconditionswillbeproduced. NOterminatetheprogram. DUPS/BADINROOTINODE(CONTINUE) Phase1orPhase1bhavefoundduplicateblocksorbadblocksintherootinode(usuallyinode number2)forthefilesystem. PossibleresponsestotheCONTINUEpromptare: YESignoretheDUPS/BADerrorconditionintherootinodeandattempttocontinuetorun thefilesystemcheck.Iftherootinodeisnotcorrect,thenthismayresultinalargenumber ofothererrorconditions. NOterminatetheprogram. IOUTOFRANGEI=INAME=F(REMOVE) AdirectoryentryFhasaninodenumberIwhichisgreaterthantheendoftheinodelist. PossibleresponsestotheREMOVEpromptare: YESthedirectoryentryFisremoved. NOignorethiserrorcondition. UNALLOCATEDI=IOWNER=OMODE=MSIZE=SMTIME=TDIR=F (REMOVE) AdirectoryentryFhasadirectoryinodeIwithoutallocatemodebits.TheownerO,modeM, sizeS,modifytimeT,anddirectorynameFareprinted. PossibleresponsestotheREMOVEpromptare: CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -13-AppendixA−FsckErrorConditions YESthedirectoryentryFisremoved. NOignorethiserrorcondition. UNALLOCATEDI=IOWNER=OMODE=MSIZE=SMTIME=TFILE=F (REMOVE) AdirectoryentryFhasaninodeIwithoutallocatemodebits.TheownerO,modeM,sizeS, modifytimeT,andfilenameFareprinted. PossibleresponsestotheREMOVEpromptare: YESthedirectoryentryFisremoved. NOignorethiserrorcondition. DUP/BADI=IOWNER=OMODE=MSIZE=SMTIME=TDIR=F(REMOVE) Phase1orPhase1bhavefoundduplicateblocksorbadblocksassociatedwithdirectoryentryF, directoryinodeI.TheownerO,modeM,sizeS,modifytimeT,anddirectorynameFare printed. PossibleresponsestotheREMOVEpromptare: YESthedirectoryentryFisremoved. NOignorethiserrorcondition. DUP/BADI=IOWNER=OMODE=MSIZE=SMTIME=TFILE=F(REMOVE) Phase1orPhase1bhavefoundduplicateblocksorbadblocksassociatedwithdirectoryentryF, inodeI.TheownerO,modeM,sizeS,modifytimeT,andfilenameFareprinted. PossibleresponsestotheREMOVEpromptare: YESthedirectoryentryFisremoved. NOignorethiserrorcondition. ZEROLENGTHDIRECTORYI=IOWNER=OMODE=MSIZE=SMTIME=T DIR=F(REMOVE) AdirectoryentryFhasasizeSthatiszero.TheownerO,modeM,sizeS,modifytimeT,and directorynameFareprinted. PossibleresponsestotheREMOVEpromptare: YESthedirectoryentryFisremoved;thiswillalwaysinvoketheBAD/DUPerrorconditionin Phase4. NOignorethiserrorcondition. DIRECTORYTOOSHORTI=IOWNER=OMODE=MSIZE=SMTIME=T DIR=F(FIX) AdirectoryFhasbeenfoundwhosesizeSislessthantheminimumsizedirectory.TheownerO, modeM,sizeS,modifytimeT,anddirectorynameFareprinted. PossibleresponsestotheFIXpromptare: YESincreasethesizeofthedirectorytotheminimumdirectorysize. NOignorethisdirectory. DIRECTORYCORRUPTEDI=IOWNER=OMODE=MSIZE=SMTIME=T DIR=F(SALVAGE) Adirectorywithaninconsistentinternalstatehasbeenfound. PossibleresponsestotheFIXpromptare: CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -14-AppendixA−FsckErrorConditions YESthrowawayallentriesuptothenext512-byteboundary.Thisratherdrasticactioncan throwawayupto42entries,andshouldbetakenonlyafterotherrecoveryeffortshave failed. NOSkipuptothenext512-byteboundaryandresumereading,butdonotmodifythedirectory. BADINODENUMBERFOR‘.’I=IOWNER=OMODE=MSIZE=SMTIME=T DIR=F(FIX) AdirectoryIhasbeenfoundwhoseinodenumberfor‘.’doesdoesnotequalI. PossibleresponsestotheFIXpromptare: YESchangetheinodenumberfor‘.’tobeequaltoI. NOleavetheinodenumberfor‘.’unchanged. MISSING‘.’I=IOWNER=OMODE=MSIZE=SMTIME=TDIR=F(FIX) AdirectoryIhasbeenfoundwhosefirstentryisunallocated. PossibleresponsestotheFIXpromptare: YESmakeanentryfor‘.’withinodenumberequaltoI. NOleavethedirectoryunchanged. MISSING‘.’I=IOWNER=OMODE=MSIZE=SMTIME=TDIR=F CANNOTFIX,FIRSTENTRYINDIRECTORYCONTAINSF AdirectoryIhasbeenfoundwhosefirstentryisF.Fsckcannotresolvethisproblem.Thefile systemshouldbemountedandtheoffendingentryFmovedelsewhere.Thefilesystemshould thenbeunmountedandfsckshouldberunagain. MISSING‘.’I=IOWNER=OMODE=MSIZE=SMTIME=TDIR=F CANNOTFIX,INSUFFICIENTSPACETOADD‘.’ AdirectoryIhasbeenfoundwhosefirstentryisnot‘.’.Fsckcannotresolvethisproblemasit shouldneverhappen.Seeaguru. EXTRA‘.’ENTRYI=IOWNER=OMODE=MSIZE=SMTIME=TDIR=F(FIX) AdirectoryIhasbeenfoundthathasmorethanoneentryfor‘.’. PossibleresponsestotheFIXpromptare: YESremovetheextraentryfor‘.’. NOleavethedirectoryunchanged. BADINODENUMBERFOR‘..’I=IOWNER=OMODE=MSIZE=SMTIME=T DIR=F(FIX) AdirectoryIhasbeenfoundwhoseinodenumberfor‘..’doesdoesnotequaltheparentofI. PossibleresponsestotheFIXpromptare: YESchangetheinodenumberfor‘..’tobeequaltotheparentofI. NOleavetheinodenumberfor‘..’unchanged. MISSING‘..’I=IOWNER=OMODE=MSIZE=SMTIME=TDIR=F(FIX) AdirectoryIhasbeenfoundwhosesecondentryisunallocated. PossibleresponsestotheFIXpromptare: YESmakeanentryfor‘..’withinodenumberequaltotheparentofI. NOleavethedirectoryunchanged. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -15-AppendixA−FsckErrorConditions MISSING‘..’I=IOWNER=OMODE=MSIZE=SMTIME=TDIR=F CANNOTFIX,SECONDENTRYINDIRECTORYCONTAINSF AdirectoryIhasbeenfoundwhosesecondentryisF.Fsckcannotresolvethisproblem.Thefile systemshouldbemountedandtheoffendingentryFmovedelsewhere.Thefilesystemshould thenbeunmountedandfsckshouldberunagain. MISSING‘..’I=IOWNER=OMODE=MSIZE=SMTIME=TDIR=F CANNOTFIX,INSUFFICIENTSPACETOADD‘..’ AdirectoryIhasbeenfoundwhosesecondentryisnot‘..’.Fsckcannotresolvethisproblemasit shouldneverhappen.Seeaguru. EXTRA‘..’ENTRYI=IOWNER=OMODE=MSIZE=SMTIME=TDIR=F(FIX) AdirectoryIhasbeenfoundthathasmorethanoneentryfor‘..’. PossibleresponsestotheFIXpromptare: YESremovetheextraentryfor‘..’. NOleavethedirectoryunchanged. 4.6.Phase3−CheckConnectivity ThisphaseconcernsitselfwiththedirectoryconnectivityseeninPhase2.Thissectionlists errorconditionsresultingfromunreferenceddirectories,andmissingorfulllost+founddirectories. UNREFDIRI=IOWNER=OMODE=MSIZE=SMTIME=T(RECONNECT) ThedirectoryinodeIwasnotconnectedtoadirectoryentrywhenthefilesystemwastraversed. TheownerO,modeM,sizeS,andmodifytimeTofdirectoryinodeIareprinted.When preen’ing,thedirectoryisreconnectedifitssizeisnon-zero,otherwiseitiscleared. PossibleresponsestotheRECONNECTpromptare: YESreconnectdirectoryinodeItothefilesysteminthedirectoryforlostfiles(usually lost+found).Thismayinvokethelost+founderrorconditioninPhase3ifthereareproblemsconnectingdirectoryinodeItolost+found.ThismayalsoinvoketheCONNECTED errorconditioninPhase3ifthelinkwassuccessful. NOignorethiserrorcondition.ThiswillalwaysinvoketheUNREFerrorconditioninPhase4. SORRY.NOlost+foundDIRECTORY Thereisnolost+founddirectoryintherootdirectoryofthefilesystem;fsckignorestherequest tolinkadirectoryinlost+found.ThiswillalwaysinvoketheUNREFerrorconditioninPhase4. Checkaccessmodesoflost+found.Seefsck(8)manualentryforfurtherdetail.Thiserrorisfatal ifthefilesystemisbeingpreen’ed. SORRY.NOSPACEINlost+foundDIRECTORY Thereisnospacetoaddanotherentrytothelost+founddirectoryintherootdirectoryofthefile system;fsckignorestherequesttolinkadirectoryinlost+found.Thiswillalwaysinvokethe UNREFerrorconditioninPhase4.Cleanoutunnecessaryentriesinlost+foundormake lost+foundlarger.Seefsck(8)manualentryforfurtherdetail.Thiserrorisfatalifthefilesystem isbeingpreen’ed. DIRI=I1CONNECTED.PARENTWASI=I2 ThisisanadvisorymessageindicatingadirectoryinodeI1wassuccessfullyconnectedtothe lost+founddirectory.TheparentinodeI2ofthedirectoryinodeI1isreplacedbytheinode numberofthelost+founddirectory. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -16-AppendixA−FsckErrorConditions 4.7.Phase4−CheckReferenceCounts ThisphaseconcernsitselfwiththelinkcountinformationseeninPhase2andPhase3. Thissectionlistserrorconditionsresultingfromunreferencedfiles,missingorfulllost+found directory,incorrectlinkcountsforfiles,directories,symboliclinks,orspecialfiles,unreferenced files,symboliclinks,anddirectories,badandduplicateblocksinfiles,symboliclinks,anddirectories,andincorrecttotalfree-inodecounts.Allerrorsinthisphasearecorrectableifthefilesys-temisbeingpreen’edexceptrunningoutofspaceinthelost+founddirectory. UNREFFILEI=IOWNER=OMODE=MSIZE=SMTIME=T(RECONNECT) InodeIwasnotconnectedtoadirectoryentrywhenthefilesystemwastraversed.TheownerO, modeM,sizeS,andmodifytimeTofinodeIareprinted.Whenpreen’ingthefileisclearedif eitheritssizeoritslinkcountiszero,otherwiseitisreconnected. PossibleresponsestotheRECONNECTpromptare: YESreconnectinodeItothefilesysteminthedirectoryforlostfiles(usuallylost+found).This mayinvokethelost+founderrorconditioninPhase4ifthereareproblemsconnectinginode Itolost+found. NOignorethiserrorcondition.ThiswillalwaysinvoketheCLEARerrorconditioninPhase4. (CLEAR) Theinodementionedintheimmediatelypreviouserrorconditioncannotbereconnected.This cannotoccurifthefilesystemisbeingpreen’ed,sincelackofspacetoreconnectfilesisafatal error. PossibleresponsestotheCLEARpromptare: YESde-allocatetheinodementionedintheimmediatelypreviouserrorconditionbyzeroingits contents. NOignorethiserrorcondition. SORRY.NOlost+foundDIRECTORY Thereisnolost+founddirectoryintherootdirectoryofthefilesystem;fsckignorestherequest tolinkafileinlost+found.ThiswillalwaysinvoketheCLEARerrorconditioninPhase4. Checkaccessmodesoflost+found.Thiserrorisfatalifthefilesystemisbeingpreen’ed. SORRY.NOSPACEINlost+foundDIRECTORY Thereisnospacetoaddanotherentrytothelost+founddirectoryintherootdirectoryofthefile system;fsckignorestherequesttolinkafileinlost+found.ThiswillalwaysinvoketheCLEAR errorconditioninPhase4.Checksizeandcontentsoflost+found.Thiserrorisfatalifthefile systemisbeingpreen’ed. LINKCOUNTFILEI=IOWNER=OMODE=MSIZE=SMTIME=TCOUNT=X SHOULDBEY(ADJUST) ThelinkcountforinodeIwhichisafile,isXbutshouldbeY.TheownerO,modeM,sizeS, andmodifytimeTareprinted.Whenpreen’ingthelinkcountisadjusted. PossibleresponsestotheADJUSTpromptare: YESreplacethelinkcountoffileinodeIwithY. NOignorethiserrorcondition. LINKCOUNTDIRI=IOWNER=OMODE=MSIZE=SMTIME=TCOUNT=X SHOULDBEY(ADJUST) ThelinkcountforinodeIwhichisadirectory,isXbutshouldbeY.TheownerO,modeM,size S,andmodifytimeTofdirectoryinodeIareprinted.Whenpreen’ingthelinkcountisadjusted. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -17-AppendixA−FsckErrorConditions PossibleresponsestotheADJUSTpromptare: YESreplacethelinkcountofdirectoryinodeIwithY. NOignorethiserrorcondition. LINKCOUNTFI=IOWNER=OMODE=MSIZE=SMTIME=TCOUNT=X SHOULDBEY(ADJUST) ThelinkcountforFinodeIisXbutshouldbeY.ThenameF,ownerO,modeM,sizeS,and modifytimeTareprinted.Whenpreen’ingthelinkcountisadjusted. PossibleresponsestotheADJUSTpromptare: YESreplacethelinkcountofinodeIwithY. NOignorethiserrorcondition. UNREFFILEI=IOWNER=OMODE=MSIZE=SMTIME=T(CLEAR) InodeIwhichisafile,wasnotconnectedtoadirectoryentrywhenthefilesystemwastraversed. TheownerO,modeM,sizeS,andmodifytimeTofinodeIareprinted.Whenpreen’ing,thisis afilethatwasnotconnectedbecauseitssizeorlinkcountwaszero,henceitiscleared. PossibleresponsestotheCLEARpromptare: YESde-allocateinodeIbyzeroingitscontents. NOignorethiserrorcondition. UNREFDIRI=IOWNER=OMODE=MSIZE=SMTIME=T(CLEAR) InodeIwhichisadirectory,wasnotconnectedtoadirectoryentrywhenthefilesystemwastraversed.TheownerO,modeM,sizeS,andmodifytimeTofinodeIareprinted.When preen’ing,thisisadirectorythatwasnotconnectedbecauseitssizeorlinkcountwaszero,hence itiscleared. PossibleresponsestotheCLEARpromptare: YESde-allocateinodeIbyzeroingitscontents. NOignorethiserrorcondition. BAD/DUPFILEI=IOWNER=OMODE=MSIZE=SMTIME=T(CLEAR) Phase1orPhase1bhavefoundduplicateblocksorbadblocksassociatedwithfileinodeI.The ownerO,modeM,sizeS,andmodifytimeTofinodeIareprinted.Thiserrorcannotarisewhen thefilesystemisbeingpreen’ed,asitwouldhavecausedafatalerrorearlier. PossibleresponsestotheCLEARpromptare: YESde-allocateinodeIbyzeroingitscontents. NOignorethiserrorcondition. BAD/DUPDIRI=IOWNER=OMODE=MSIZE=SMTIME=T(CLEAR) Phase1orPhase1bhavefoundduplicateblocksorbadblocksassociatedwithdirectoryinodeI. TheownerO,modeM,sizeS,andmodifytimeTofinodeIareprinted.Thiserrorcannotarise whenthefilesystemisbeingpreen’ed,asitwouldhavecausedafatalerrorearlier. PossibleresponsestotheCLEARpromptare: YESde-allocateinodeIbyzeroingitscontents. NOignorethiserrorcondition. FREEINODECOUNTWRONGINSUPERBLK(FIX) Theactualcountofthefreeinodesdoesnotmatchthecountinthesuper-blockofthefilesystem. Whenpreen’ing,thecountisfixed. CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -18-AppendixA−FsckErrorConditions PossibleresponsestotheFIXpromptare: YESreplacethecountinthesuper-blockbytheactualcount. NOignorethiserrorcondition. 4.8.Phase5-CheckCylgroups Thisphaseconcernsitselfwiththefree-blockmaps.Thissectionlistserrorconditions resultingfromallocatedblocksinthefree-blockmaps,freeblocksmissingfromfree-blockmaps, andthetotalfree-blockcountincorrect. CGC:BADMAGICNUMBER ThemagicnumberofcylindergroupCiswrong.Thisusuallyindicatesthatthecylindergroup mapshavebeendestroyed.Whenrunningmanuallythecylindergroupismarkedasneedingto bereconstructed.Thiserrorisfatalifthefilesystemisbeingpreen’ed. EXCESSIVEBADBLKSINBITMAPS(CONTINUE) Aninodecontainsmorethanatolerablenumber(usually10)ofblocksclaimedbyotherinodesor thatareoutofthelegalrangeforthefilesystem.Thiserrorisfatalifthefilesystemisbeing preen’ed. PossibleresponsestotheCONTINUEpromptare: YESignoretherestofthefree-blockmapsandcontinuetheexecutionoffsck. NOterminatetheprogram. SUMMARYINFORMATIONTBAD whereTisoneormoreof: (INODEFREE) (BLOCKOFFSETS) (FRAGSUMMARIES) (SUPERBLOCKSUMMARIES) Theindicatedsummaryinformationwasfoundtobeincorrect.Thiserrorconditionwillalways invoketheBADCYLINDERGROUPSconditioninPhase6.Whenpreen’ing,thesummary informationisrecomputed. XBLK(S)MISSING Xblocksunusedbythefilesystemwerenotfoundinthefree-blockmaps.Thiserrorcondition willalwaysinvoketheBADCYLINDERGROUPSconditioninPhase6.Whenpreen’ing, theblockmapsarerebuilt. BADCYLINDERGROUPS(SALVAGE) Phase5hasfoundbadblocksinthefree-blockmaps,duplicateblocksinthefree-blockmaps,or blocksmissingfromthefilesystem.Whenpreen’ing,thecylindergroupsarereconstructed. PossibleresponsestotheSALVAGEpromptare: YESreplacetheactualfree-blockmapswithanewfree-blockmaps. NOignorethiserrorcondition. FREEBLKCOUNTWRONGINSUPERBLOCK(FIX) Theactualcountoffreeblocksdoesnotmatchthecountinthesuper-blockofthefilesystem. Whenpreen’ing,thecountsarefixed. PossibleresponsestotheFIXpromptare: CSRGTR/9 July28,1983 McKusick,et.al.

Fsck -19-AppendixA−FsckErrorConditions YESreplacethecountinthesuper-blockbytheactualcount. NOignorethiserrorcondition. 4.9.Phase6-SalvageCylinderGroups Thisphaseconcernsitselfwiththefree-blockmapsreconstruction.Noerrormessagesare produced. 4.10.Cleanup Onceafilesystemhasbeenchecked,afewcleanupfunctionsareperformed.Thissection listsadvisorymessagesaboutthefilesystemandmodifystatusofthefilesystem. Vfiles,Wused,Xfree(Yfrags,Zblocks) ThisisanadvisorymessageindicatingthatthefilesystemcheckedcontainedVfilesusingWfragmentsizedblocksleavingXfragmentsizedblocksfreeinthefilesystem.ThenumbersinparenthesisbreaksthefreecountdownintoYfreefragmentsandZfreefullsizedblocks. *****REBOOTUNIX***** Thisisanadvisorymessageindicatingthattherootfilesystemhasbeenmodifiedbyfsck.If UNIXisnotrebootedimmediately,theworkdonebyfsckmaybeundonebythein-corecopiesof tablesUNIXkeeps.Whenpreen’ing,fsckwillexitwithacodeof4.Theauto-rebootscriptinter-pretsanexitcodeof4byissuingarebootsystemcall. *****FILESYSTEMWASMODIFIED***** Thisisanadvisorymessageindicatingthatthecurrentfilesystemwasmodifiedbyfsck.Ifthis filesystemismountedoristhecurrentrootfilesystem,fsckshouldbehaltedandUNIX rebooted.IfUNIXisnotrebootedimmediately,theworkdonebyfsckmaybeundonebytheincorecopiesoftablesUNIXkeeps. CSRGTR/9 July28,1983 McKusick,et.al.