Mkswap Man
-
Upload
lalit-joshi -
Category
Documents
-
view
224 -
download
0
Transcript of Mkswap Man
-
8/3/2019 Mkswap Man
1/3
MKSWAP(8) LinuxProgrammer'sManual MKSWAP(8)
NAMEmkswap-setupaLinuxswaparea
SYNOPSISmkswap[-c][-f][-pPSZ][-Llabel][-Uuuid]device[size]
DESCRIPTIONmkswapsetsupaLinuxswapareaonadeviceorinafile.
Thedeviceargumentwillusuallybeadiskpartition(somethinglike/dev/sdb7)butcanalsobeafile.TheLinuxkerneldoesnotlookatpartitionId's,butmanyinstallationscriptswillassumethatpartitionsofhextype82(LINUX_SWAP)aremeanttobeswappartitions.(Warning:Solarisalsousesthistype.BecarefulnottokillyourSolarispartitions.)
Thesizeparameterissuperfluousbutretainedforbackwardscompatibi
lity.(Itspecifiesthedesiredsizeoftheswapareain1024-byteblocks.mkswapwillusetheentirepartitionorfileifitisomitted. Specifyingitisunwise-atypomaydestroyyourdisk.)
ThePSZparameterspecifiesthepagesizetouse.Itisalmostalwaysunnecessary(evenunwise)tospecifyit,butcertainoldlibcversionslieaboutthepagesize,soitispossiblethatmkswapgetsitwrong.Thesymptomisthatasubsequentswaponfailsbecausenoswapsignatureisfound.TypicalvaluesforPSZare4096or8192.
Aftercreatingtheswaparea,youneedtheswaponcommandtostartusingit.Usuallyswapareasarelistedin/etc/fstabsothattheycanbetakenintouseatboottimebyaswapon-acommandinsomebootscript.
WARNINGTheswapheaderdoesnottouchthefirstblock.Abootloaderordisklabelcanbethere,butitisnotrecommendedsetup.TherecommendedsetupistouseaseparatepartitionforaLinuxswaparea.
mkswaplikemanyothersmkfs-likeutilserasesthefirstblocktoremove
oldon-diskfilesystems.
mkswaprefusestoerasethefirstblockonadevicewithadisklabel(SUN,BSD,...)oronwholedisk(e.g./dev/sda).
OPTIONS-cCheckthedevice(ifitisablockdevice)forbadblocksbeforecreatingtheswaparea. Ifanyarefound,thecountisprinted.
-
8/3/2019 Mkswap Man
2/3
-fForce-goaheadevenifthecommandisstupid.Thisallowsthecreationofaswaparealargerthanthefileorpartitionitresideson.
Withoutthisoptionmkswapwillrefusetoerasethefirstblockonadevicewithapartitiontableoronwholedisk(e.g./dec/sda).
-pPSZSpecifythepagesizetouse.
-LlabelSpecifyalabel,toallowswaponbylabel.(Onlyfornewstylesw
apareas.)
-v0,-v1Specifytheswapspaceversion.Thisoptionisdeprecatedand-v1
issupportedonly.
Thekernelhasnotsupportedv0swapspaceformatsince2.5.22.Thenewversionv1issupportedsince2.1.117.
-UuuidSpecifytheuuidtouse.ThedefaultistogenerateUUIDs.
NOTESThemaximumusefulsizeofaswapareadependsonthearchitectureandthekernelversion.Itisroughly2GiBoni386, PPC,m68k,ARM,1GiBonsparc,512MiBonmips,128GiBonalphaand3TiBonsparc64.Forkernelsafter2.3.3thereisnosuchlimitation.
Notethatbefore2.1.117thekernelallocatedonebyteforeachpage,whileitnowallocatestwobytes,sothattakingaswapareaof2GiBinusemightrequire2MiBofkernelmemory.
Presently,Linuxallows32swapareas(thiswas8beforeLinux2.4.10).
Theareasinusecanbeseeninthefile/proc/swaps(since2.1.25).
mkswaprefusesareassmallerthan10pages.
Ifyoudon'tknowthepagesizethatyourmachineuses,youmaybeabletolookitupwith"cat/proc/cpuinfo"(oryoumaynot-thecontentsofthisfiledependonarchitectureandkernelversion).
Tosetupaswapfile,itisnecessarytocreatethatfilebeforeinitializingitwithmkswap,e.g.usingacommandlike
#ddif=/dev/zeroof=swapfilebs=1024count=65536
Notethataswapfilemustnotcontainanyholes(so,usingcp(1)tocreatethefileisnotacceptable).
SEEALSOfdisk(8),swapon(8)
AVAILABILITY
-
8/3/2019 Mkswap Man
3/3
Themkswapcommandispartoftheutil-linux-ngpackageandisavailablefromftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
Linux 13March2009 MKSWAP(8)