Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to extend swap Partition

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to expand the swap partition, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

1.mkswap / devices (formatted into swap format)

2.swapon / swap (activate / swap, add to the swap partition)

1. Divide into regions first.

[root@xuegod63 ~] # fdisk / dev/sdb

Command (enter m for help): n

Partition type:

P primary (0 primary, 0 extended, 4 free)

E extended

Select (default p): P

Partition number (1-4, default 1):

Start sector (2048-41943039, default is 2048):

The default value of 2048 will be used

Last sector, + sector or + size {K Magne M Magi G} (2048-41943039, default is 41943039): + 1G

Partition 1 has been set to Linux type and size to 1 GiB

Command (enter m for help): W

The partition table has been altered!

Calling ioctl () to re-read partition table.

Synchronizing disks.

[root@xuegod63 ~] # ls / dev/sd*

/ dev/sda / dev/sda1 / dev/sda2 / dev/sdb / dev/sdb1

2 format swap

[root@xuegod63 ~] # mkswap / dev/sdb1

Setting swap space version 1, size = 2097148 KiB

No tag, UUID=dc41b5ef-bcf1-477c-902e-c5bb00d41c1e

Verify:

[root@xuegod63] # free-m

Total used free shared buff/cache available

Mem: 977 557 75 16 345 168

Swap: 2047 234 1813

3 enable swap

[root@xuegod63 ~] # swapon / dev/sdb1-enable

[root@xuegod63] # free-m

Total used free shared buff/cache available

Mem: 977 556 75 16 345 169

Swap: 3071 234 2837

4 close swap

[root@xuegod63 ~] # swapoff / dev/sdb1-close

[root@xuegod63] # free-m

Total used free shared buff/cache available

Mem: 977 556 75 16 345 169

Swap: 2047 234 1813

5 View swap

[root@xuegod63] # swapon-s

Filename Type Size Used Priority

/ dev/dm-1 partition 2097148 240532-1

[root@xuegod63 ~] # swapon / dev/sdb2

[root@xuegod63 ~] # swapon-s # View

Filename Type Size Used Priority

/ dev/dm-1 partition 2097148 240532-1

/ dev/sdb1 partition 1048572 0-2

6. Boot self-booting newly added swap partition

1.vim / etc/fstab (boot self-boot newly added swap partition), append at the end:

Echo "/ dev/sdb1 swap swap defaults 0" > > / etc/fstab

If you don't want to use it, you need to delete it, just execute # swapoff / swap.

Increase the SWAP space through the file 1. Create a file of 500m size using the dd command

[root@xuegod63 ~] # dd if=/dev/zero of=swap_file bs=1M count=500

two。 View permissions

[root@xuegod63 ~] # ll / root/swap_file

3. Modify permissions

[root@xuegod63 ~] # chmod 0600 / root/swap_file

4. Formatted into a swap file

[root@xuegod63] # mkswap-f / root/swap_file

5. Turn on swap

[root@xuegod63 ~] # swapon / root/swap_file

6. View swap

[root@xuegod63] # free-m

The answer to the question on how to expand the swap partition is shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report