Linux disk and file system management (5) _ creating swap partitions

Source: Internet
Author: User
Tags hex code

Linux disk and file system management (5) _ creating swap partitions
Swap partition swap: When the cpu usage is insufficient, it will temporarily occupy a portion of the hard disk space to store memory information, which is the swap partition. Create a new swap partition swap: 1 create a new partition, set the Id, create a swap partition 2 format the swap partition mkswap device name 3 Start swap: swapon device name 4 View swap: free command mkswap command: Use a device or file to set a swap partition swap format mkswap [options] device [size] parameter:-c: before creating a swap partition, check whether there are bad blocks-f, -- force: forcibly create-L, -- label 'label': Create-U according to the specified label, -- uuid UUID: create free command based on uuid: view the Usage Status of memory and swap partition swap free [options]-m: In MB-g: in GB-h: display the capacity swapon in a readable manner, swapoff command: enable and disable devices and files as swap partitions (enable/disable devices and files for paging and swapping) swapon: enable swap partition swapon [option] [DEVICE]-: activate all swap partitions-p PRIORITY: set its PRIORITY; Use-v First: Show Details swapoff: Disable swap partition swapoff [option] [DEVICE]-: disable all swap partitions-v: Show Details Example:

#1 create a new partition swap [root @ localhost ~] # Fdisk/dev/sdaWelcome to fdisk (util-linux 2.23.2 ). changes will remain in memory only, until you decide to write them. be careful before using the write command. command (m for help): nAll primary partitions are in useAdding logical partition 9 First sector (107507712-251658239, default 107507712): Using default value 107507712 Last sector, + sectors or + size {K, M, G} (107507712-251658239, default 25165 8239): + 512 MPartition 9 of type Linux and of size 512 MiB is setCommand (m for help): pDisk/dev/sda: 128.8 GB, 128849018880 bytes, 251658240 sectorsUnits = sectors of 1*512 = 512 bytesSector size (logical/physical): 512 bytes/512 bytesI/O size (minimum/optimal): 512 bytes/512 bytesDisk label type: dosDisk identifier: 0x000c2314 Device Boot Start End Blocks Id System .... /dev/sda6 82337792 86 532095 2097152 82 Linux swap/Solaris/dev/sda7 61853696 61855743 1024 83 Linux/dev/sda8 86534144 107505663 10485760 107507712 83 Linux/dev/sda9 108556287 524288 83 LinuxPartition table entries are not in disk orderCommand (m for help): tPartition number (1-9, default 9): 9Hex code (type L to list all codes ): L 0 Empty 24 nec dos 81 Minix/old Lin bf Solaris 1 FAT12 27 Hidden NTFS Win 82 Linux sw Ap/So c1 DRDOS/sec (FAT-2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT-4 FAT16 <32 M 40 Venix 80286 85 Linux extended c7 syr00005 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 6 FAT16 42 SFS 87 NTFS volume set db CP/M/CTOS /. 7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility 8 AIX 4e QNX4.x 2nd p Art 8e Linux LVM df BootIt 9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 dos r/O B W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT f W95 Ext 'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/10 OPUS 55 EZ-Drive a7 NeXTSTEP F0 Linux/PA-RISC b11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor 12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor 14 Hidden FAT16 <3 61 SpeedStor AB Darwin boot f2 DOS secondary 16 Hidden FAT16 63 gnu hurd or Sys af HFS/HFS + fb VMware VMFS 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto1b Hidd En W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep 1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT 1e Hidden W95 FAT1 80 Old Minix Hex code (type L to list all codes): 82 Changed type of partition 'linux 'to 'linux swap/Solaris' Command (m for help): pDisk/dev/sda: 128.8 GB, 128849018880 bytes, 251658240 sectorsUnits = sectors of 1*512 = 512 bytesSector size (logical/physical): 512 Bytes/512 bytesI/O size (minimum/optimal): 512 bytes/512 bytesDisk label type: dosDisk identifier: 0x000c2314 Device Boot Start End Blocks Id System ...... /dev/sda6 82337792 86532095 2097152 82 Linux swap/Solaris/dev/sda7 61853696 61855743 1024 83 Linux/dev/sda8 86534144 107505663 10485760 83 Linux/dev/sda9 107507712 108556287 524288 82 Linux swap /SolarisPartition table entries are not in Disk orderCommand (m for help): wThe partition table has been altered! Calling ioctl () to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. the kernel still uses the old table. the new table will be used atthe next reboot or after you run partprobe (8) or kpartx (8) Syncing disks. #2 format the swap partition [root @ localhost ~] # Mkswap/dev/sda9Setting up swapspace version 1, size = 524284 KiBno label, UUID = 7362fb3d-4bda-41d4-bef5-ba238de58aa2 # view memory information [root @ localhost ~] # Free-h total used free shared buff/cache availableMem: 979 M 127 M 704 M 6.7 M 147 M 703 MSwap: 2.0G 0B 2.0G #3 load the swap partition [root @ localhost ~] # Swapon/dev/sda9 [root @ localhost ~] # Free-h total used free shared buff/cache availableMem: 979 M 128 M 704 M 6.7 M 147 M 702 MSwap: 2.5G 0B 2.5G # disable the specified swap partition [root @ localhost ~] # Swapoff-v/dev/sda9swapoff/dev/sda9 # enable the specified swap partition [root @ localhost ~] # Swapon-v/dev/sda9swapon/dev/sda9swapon:/dev/sda9: found swap signature: version 1, page-size 4, same byte orderswapon:/dev/sda9: pagesize = 4096, swapsize = 536870912, devsize = 536870912

 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.