How to modify the swap partition size after installing Linux __linux

Source: Internet
Author: User

How to modify the swap partition size after installing Linux

The testing test is RH AS4
If you are not sure what swap is, or the concept of partitioning, the following procedure may be of some risk to you.
It is also more convenient to enlarge your own swap. You must have root permission, the process must be very careful, accidentally destroyed the entire hard disk data, the following procedure before you need to reconsider, the consequences of the error by the performer's own commitment, I this script just as a reference.
1. Enter the console with root
2. #swapoff-A #停止交换分区
3. #fdisk/dev/hda #swap所在硬盘的硬盘设备文档, it may be different, you'd better see/etc/fstab the number behind the hd* that has the swap line removed
4. In Fdisk own operation, uses D to delete the swap partition first, then the n adds the partition (the hard disk must have the free space when adding, the space size parameter is the cylinder number cylinders, is not the byte, you need to calculate for yourself, the p command can see each cylinder number of bytes), Then use T to change the newly added partition ID to the (Linux swap type), with W to actually write the operation to the hard disk after each step (your operation is invalid before W). Again, this step must be very careful, a mistake your system may be broken, data loss.
5. #mkswap/dev/hda6 #格式化swap分区, the hda6 here depends on the actual partition device name shown after you add the P command
6. #swapon/dev/hda6 #看是否能够启动新的swap分区
7. Modify the/etc/fstab in the line of swap device name such as/DEV/HDA6 (if you do not change the location, usually the same as before), let him start loading himself. It should be noted that if you are a label=swap-hda6 this place, then you have two choices: first. Change him to the actual device name, such as:/dev/hda6. Second, without changing the/etc/fstab, the command line in step 5th needs to be slightly different #mkswap-L SWAP-HDA6/DEV/HDA6 that is, when formatted, add a label to the SWAP, which is supported only in new releases, and can be Mkswap- Help to see if he supports-l option.
8. Reboot, all OK

increase the Swap partition size on Linux systems

First, view the current system partition situation:
>free-m total used free shared buffers Cached
mem:438 432 6 0 8 141
-/+ buffers/cache:282 156
swap:2047 1375 6,712, create a file to swap partitions: If you want to increase the 2G size of the swap partition, the command is written as follows, where count equals the desired block size
>dd If=/dev/zero of=/home/swap bs=block_size count=number_of_block dd if=/dev/zero of=/home/swap bs=1024 count= 2048000 2048000+0 Records in
2048000+0 Records out
2097152000 bytes (2.1 GB) copied, 60.4492 seconds, 34.7 MB/s three, set up swap partition files:
>mkswap/home/swap Four, enable the swap partition file now:
>swapon/home/swap v. To change the swap line in the file/etc/fstab if you want to enable it at boot time:
/home/swap Swap Defaults 0 0

[Root@test ~]# Free-m
Total used free shared buffers Cached
mem:438 433 5 0 2

267
-/+ buffers/cache:        163         275
swap:         4047       1465        2581

Related Article

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.