In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "what to do with the deficiency of Swap", which is easy to understand and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn the article "how to do with the deficiency of Swap".
1. Use the dd command to create a new file and mount it as SWAP
Use command 'dd' to create a file and mount as swap
[root@localhost] # free-m
Total used free shared buffers cached
Mem: 5966 334 5631 0 16 99
-/ + buffers/cache: 218 5747
Swap: 6143 0 6143
[root@localhost ~] # dd if=/dev/zero of=/root/swap bs=1024 count=1024000
1024000 million 0 records in
1024000 million 0 records out
1048576000 bytes (1.0 GB) copied, 3.20295 s, 327 MB/s
Bs= is bytes,count is blocks block, 1024bytesfolk 1K is 1024000km 1000m
[root@localhost ~] # mkswap / root/swap
Mkswap: / root/swap: warning: don't erase bootbits sectors
On whole disk. Use-f to force.
Setting up swapspace version 1, size = 1023996 KiB
No label, UUID=af12e46f-16da-4b89-a89f-301bdce4b138
[root@localhost ~] # swapon / root/swap
[root@localhost] # free-m
Total used free shared buffers cached
Mem: 5966 1604 4361 0 21 1217
-/ + buffers/cache: 365 5600
Swap: 7143 0 7143
Compared with the original one, it has increased by nearly 1000m.
two。 Format unused partitions with fdisk and mount them as swap partitions
Use 'fdisk' to format other partitions and mount as swap
[root@localhost ~] # fdisk-l
Disk / dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/sda1 * 1 13 104391 83 Linux
/ dev/sda2 14 2078 16587112 + 83 Linux
/ dev/sda3 2079 2600 4192965 82 Linux swap / Solaris
[root@localhost ~] # fdisk / dev/sda
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024
And could in certain setups cause problems with:
1) software that runs at boot time (e.g.old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): P
Disk / dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/sda1 * 1 13 104391 83 Linux
/ dev/sda2 14 2078 16587112 + 83 Linux
/ dev/sda3 2079 2600 4192965 82 Linux swap / Solaris
Command (m for help): n
Command action
E extended
P primary partition (1-4)
E
Selected partition 4
First cylinder (2601-2610, default 2601):
Using default value 2601
Last cylinder or + size or + sizeM or + sizeK (2601-2610, default 2610): + 50m-add a new 50m extended partition.
-add an extend partition of 50m
Command (m for help): P
Disk / dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/sda1 * 1 13 104391 83 Linux
/ dev/sda2 14 2078 16587112 + 83 Linux
/ dev/sda3 2079 2600 4192965 82 Linux swap / Solaris
/ dev/sda4 2601 2607 56227 + 5 Extended
Command (m for help): n
First cylinder (2601-2607, default 2601):
Using default value 2601
Last cylinder or + size or + sizeM or + sizeK (2601-2607, default 2607):
Using default value 2607
Command (m for help): P
Disk / dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/sda1 * 1 13 104391 83 Linux
/ dev/sda2 14 2078 16587112 + 83 Linux
/ dev/sda3 2079 2600 4192965 82 Linux swap / Solaris
/ dev/sda4 2601 2607 56227 + 5 Extended
/ dev/sda5 2601 2607 56196 83 Linux
Command (m for help): W
The 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 at the next reboot.
Syncing disks.
[root@bys3] # free-m
Total used free shared buffers cached
Mem: 2013 218 1795 0 15 153
-/ + buffers/cache: 49 1964
Swap: 5094 0 5094
[root@bys3 ~] # swapoff / root/swap closes a SWAP space
Off a swap space
[root@bys3] # free-m
Total used free shared buffers cached
Mem: 2013 218 1795 0 15 153
-/ + buffers/cache: 49 1964
Swap: 4094 0 4094
[root@bys3 ~] # mkswap / dev/sda5
/ dev/sda5: No such file or directory
[root@bys3 ~] # partprobe-synchronize partition tables
Sync of partition table
Warning: Unable to open / dev/sr0 read-write (Read-only file system). / dev/sr0 has been opened read-only.
Segmentation fault
[root@bys3 ~] # mkswap / dev/sda5
Setting up swapspace version 1, size = 57540 kB
[root@bys3 ~] # swapon / dev/sda5
[root@bys3] # free-m
Total used free shared buffers cached
Mem: 2013 218 1795 0 15 153
-/ + buffers/cache: 49 1964
Swap: 4149 0 4149
Power on and mount automatically
Auto mount during boot process
[root@localhost ~] # vi / etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot / boot ext3 defaults 1 2
Tmpfs / dev/shm tmpfs defaults 0 0
Devpts / dev/pts devpts gid=5,mode=620 0 0
Sysfs / sys sysfs defaults 0 0
Proc / proc proc defaults 0 0
LABEL=SWAP-sda3 swap swap defaults 0 0
/ root/swap swap swap defaults-dd mount method (dd mount)
/ dev/sda5 swap swap defaults 0 0-formatted mount method (formatting partition mount)
[root@localhost ~] # mount-a-mount successfully if no error is reported (No errors then mount succeed)
The above is all the content of this article "what to do with insufficient Swap". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.