Linux commands: Swap partition, free view memory usage, Mkswap create swap partition

Source: Internet
Author: User
Tags hex code

Mkswap Command Introduction:

Used to create a formatted swap partition swap.

1 . Command format:

Free to view system memory usage

-M: Displayed in m (default in bytes)

[[email protected] ~]# free

Total used free shared buffers Cached

mem:1938628 161284 1777344 0 26632 57404

-/+ buffers/cache:77248 1861380

swap:2047992 0 2047992

[Email protected] ~]# free-m

Total used free shared buffers Cached

mem:1893 157 1735 0 26 56

-/+ buffers/cache:75 1817

swap:1999 0 1999

Mkswap Disk EG:MKSWAP/DEV/SDA

-L label Specifies the volume label

SWAPON/DEVB/SDA9 Enable swap partition

SWAPOFF/DEV/SDA9 closing the Swap partition

2 . Command function:

Swap formatting for a partition

3 . Command parameters:

Free to view system memory usage

-M: Displayed in m (default in bytes)

Mkswap Disk EG:MKSWAP/DEV/SDA

-L label Specifies the volume label

4 . Command instance:

How do I increase the swap partition?

[Email protected] ~]# FDISK/DEV/SDA

Warning:dos-compatible mode is deprecated. It ' s strongly recommended to

Switch off the mode (command ' C ') and change display units to

Sectors (Command ' u ').


Command (M for help): p See if the hard disk has unallocated capacity and partition information


disk/dev/sda:21.5 GB, 21474836480 bytes

255 heads, Sectors/track, 2610 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk identifier:0x000f2a2b


Device Boot Start End Blocks Id System

/DEV/SDA1 * 1 2048000 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 893 5120000 Linux

Partition 2 does not end on cylinder boundary.

/dev/sda3 893 1403 4096000-up Linux

/DEV/SDA4 1403 2611 9706496 5 Extended

/dev/sda5 1403 1786 3072000-up Linux

/dev/sda6 1786 2041 2048000, Linux Swap/solaris

/DEV/SDA7 2041 2296 2048000-up Linux

/dev/sda8 2296 2427 1057726 fd Linux raid Autodete

Command (M for help): n adds a new partition

First cylinder (2428-2611, default 2428):

Using Default Value 2428

Last cylinder, +cylinders or +size{k,m,g} (2428-2611, default 2611): +1g new partition size 1G

Command (M for help): t Modify partition type

Partition number (1-9): 9 Select the type of partition you want to modify

Hex code (Type L to list codes): l View all partition types supported by the system

0 Empty NEC DOS bayi minix/old Lin BF Solaris

1 FAT12 Plan 9 swap/so C1 drdos/sec (fat-

2 Xenix root 3c partitionmagic Linux C4 drdos/sec (fat-

3 Xenix usr Venix 80286 os/2 hidden c:c6 drdos/sec (fat-

4 FAT16 <32m PPC PReP Boot-up Linux extended C7 Syrinx

5 Extended SFS, NTFS volume set da non-fs data

6 FAT16 4d qnx4.x NTFS Volume set db cp/m/CTOS/.

7 Hpfs/ntfs 4e qnx4.x 2nd part of the Linux plaintext de Dell Utility

8 AIX 4f qnx4.x 3rd part 8e Linux LVM DF bootit

9 AIX bootable Ontrack DM Amoeba E1 DOS Access

A os/2 Boot manag Wuyi ontrack DM6 Aux 94 Amoeba BBT E3 DOS r/o

b W95 FAT32 cp/m 9f bsd/os e4 speedstor

C W95 FAT32 (LBA) Ontrack DM6 Aux A0 IBM Thinkpad hi EB BeOS FS

E W95 FAT16 (LBA) OnTrackDM6 a5 FreeBSD ee GPT

F W95 Ext ' d (LBA) ez-drive a6 OpenBSD ef EFI (fat-12/16/

Ten OPUS Bow A7 NeXTSTEP f0 linux/pa-risc b

One Hidden FAT12 5c Priam edisk A8 Darwin UFS F1 SpeedStor

Compaq diagnost speedstor A9 NetBSD f4 SpeedStor

Hidden FAT16 <3, GNU HURD or Sys ab Darwin boot F2 DOS Secondary

Hidden FAT16 Novell Netware af hfs/hfs+ fb VMware VMFS

Hidden hpfs/ntf Novell Netware b7 BSDI FS FC VMware Vmkcore

AST smartsleep disksecure Mult b8 BSDI swap fd Linux RAID auto

1b Hidden W95 FAT3 pc/ix bb Boot Wizard hid Fe lanstep

1c Hidden

Hex code (type L to list codes): 82 Select the type of partition type

Changed system type of partition 9 to Swap/solaris (Linux)


Command (M for help): p See if the hard disk has unallocated capacity and partition information


disk/dev/sda:21.5 GB, 21474836480 bytes

255 heads, Sectors/track, 2610 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk identifier:0x000f2a2b


Device Boot Start End Blocks Id System

/DEV/SDA1 * 1 2048000 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 893 5120000 Linux

Partition 2 does not end on cylinder boundary.

/dev/sda3 893 1403 4096000-up Linux

/DEV/SDA4 1403 2611 9706496 5 Extended

/dev/sda5 1403 1786 3072000-up Linux

/dev/sda6 1786 2041 2048000, Linux Swap/solaris

/DEV/SDA7 2041 2296 2048000-up Linux

/dev/sda8 229 2427 1057726 fd Linux raid AutoDetect

/DEV/SDA9 2428 2559 1060258+ the Linux swap/solaris partition has been modified to swap type

W95 FAT3 Minix be Solaris boot ff BBT

1e Hidden W95 FAT1

Command (M for help): W Save partition operation and Exit

The partition table has been altered!

Calling IOCTL () to re-read partition table.

Warning:re-reading the partition table failed with error 16: The device or resource is busy.

The kernel still uses the old table. The new table is being used at

The next reboot or after you run Partprobe (8) or KPARTX (8)

[[email protected] ~]# PARTPROBE/DEV/SDA notify kernel to identify newly created partition

[[email protected] ~]# mkswap/dev/sda9 Format the partition as swap

Setting up, swapspace version 1, size=1011671 KB already formatted as swap format

[[email protected] ~]# free-m free-m View system memory usage in megabytes

Total used free shared buffers Cached

mem:1893 157 1735 0 26 56

-/+ buffers/cache:75 1817

swap:1999 0 1999 But there's still no increase in swap partition here .

[Email protected] ~]# swapon/dev/sda9

[[email protected] ~]# free-m free-m View system memory usage in megabytes

Total used free shared buffers Cached

mem:1893 157 1735 0 26 56

-/+ buffers/cache:75 1817

swap:2999 0 2999 here Swap partition swap increased to 3G new 1G





This article is from the "Learn Linux history" blog, please be sure to keep this source http://woyaoxuelinux.blog.51cto.com/5663865/1867555

Linux commands: Swap partition, free view memory usage, Mkswap create swap partition

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.