VPS creation and deletion swap partitioning method

Source: Internet
Author: User
Tags vps

Root permissions are required for all operations

1. Create swap swap partitions
First view the hard disk partition with Fdisk-l

  code is as follows copy code

fdisk-l

defaultdisk/dev/sda:21.5 GB, 21474836480 bytes
255 heads, 6 3 Sectors/track, 2610 cylinders
Units = cylinders of 16065 * 5 = 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/o size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00097743

 &N Bsp Device boot      start         End       blocks   id  System
/dev/sda1   *            1        2481    19922944    83  Linux

Only one partition.

Create a new partition for swap swap.

The code is as follows Copy Code


Fdisk/dev/sda

[Root@itnmg ~]# FDISK/DEV/SDA

Warning:dos-compatible mode is deprecated. It ' s strongly recommended to
Switch off "mode" (Command ' C ') and change display units to
Sectors (Command ' u ').

Command (M for help): M
Command Action
A toggle a bootable flag
b Edit BSD Disklabel
C Toggle the DOS compatibility flag
d Delete a partition delete a partition
L list known partition types
The M Print this menu displays the Help menus
n Add a new partition create a new partition
o Create a new empty DOS partition table
P Print the partition table shows the partition tables
Q Quit without saving changes do not save exit
s create a new empty Sun Disklabel
t change a partition ' s system ID changes partition type
U Change display/entry units
V Verify the partition table
W Write table to disk and exit save exit
X Extra functionality (experts only)

Command (M for help):

What we often use is the Chinese to mark out those.

Enter N to create a new partition

The code is as follows Copy Code

DefaultCommand (M for help): N
Command Action
E Extended
P primary partition (1-4)

Choose to create an extended partition or primary partition, where we select the primary partition and enter P

The code is as follows Copy Code

Defaultp
Partition number (1-4):

Enter the partition number, 1-4, because there is a sda1, so enter 2

The code is as follows Copy Code

Defaultpartition number (1-4): 2
The cylinder (2498-2610, default 2498):

Enter the starting position, do not change here, direct return.

The code is as follows Copy Code

Defaultusing Default Value 2498
Last cylinder, +cylinders or +size{k,m,g} (2498-2610, default 2610):

Enter +200m, set to 200M size.

No back information at this time, and then enter P to view the partition.

  code is as follows copy code

Default    Device boot      start         End       blocks   id  System
/dev/sda1   *            1        2497    20056128   83  Linux
/dev/sda2             2498        2523      208845   83   Linux

A new partition has been created, input W save exit. The partition is reloaded after exiting.

Create a swap on a new partition

The code is as follows Copy Code

Mkswap/dev/sda2
Swapon-a

Set up system self-enabled swap files, edit/etc/fstab files, add the following

The code is as follows Copy Code

/dev/sda2 Swap Defaults 0 0

Free-m Viewing effects

2. Delete the swap partition

Deactivate swap partition

The code is as follows Copy Code
Swapoff-a

Delete a swap partition

The code is as follows Copy Code

Fdisk/dev/sda

This is similar to the increment operation, except to delete the partition instead, enter D

The code is as follows Copy Code

Partition number (1-4):

Enter the partition number you want to delete, 2

Enter P to view the partition and has been deleted.

Enter W save exit.

Modify/etc/fstab file, delete/dev/sda2 swap defaults 0 0 Save


Note:

Install the Linux operating system VPS Add swap partition (only the VPS using Xen virtualization technology can, currently OPENVZ does not support the addition of swap).

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.