{"id":1117,"date":"2016-07-07T14:20:18","date_gmt":"2016-07-07T06:20:18","guid":{"rendered":"http:\/\/www.821121.com\/?p=1117"},"modified":"2020-12-16T14:21:16","modified_gmt":"2020-12-16T06:21:16","slug":"linux%e6%89%a9%e5%b1%95swap%e5%88%86%e5%8c%ba","status":"publish","type":"post","link":"http:\/\/www.821121.com\/?p=1117","title":{"rendered":"linux\u6269\u5c55swap\u5206\u533a"},"content":{"rendered":"<p>linux\u6269\u5c55swap\u5206\u533a:<\/p>\n<pre><code class=\"language-sql\">[root@pow-altibase01 ~]# fdisk \/dev\/sdb\n\nWARNING: DOS-compatible mode is deprecated. It&#039;s strongly recommended to\n         switch off the mode (command &#039;c&#039;) and change display units to\n         sectors (command &#039;u&#039;).\n\nCommand (m for help): n\nCommand action\n   e   extended\n   p   primary partition (1-4)\np  \nPartition number (1-4): 2\nFirst cylinder (4049-71797, default 4049): 4049\nLast cylinder, +cylinders or +size{K,M,G} (4049-71797, default 71797): +59G\n\nCommand (m for help): p\n\nDisk \/dev\/sdb: 590.6 GB, 590558003200 bytes\n255 heads, 63 sectors\/track, 71797 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x18104992\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sdb1               1        4048    32515528+  83  Linux\n\/dev\/sdb2            4049       11751    61874347+  83  Linux\n\nCommand (m for help): w\nThe partition table has been altered!\n\nCalling ioctl() to re-read partition table.\n\nWARNING: Re-reading the partition table failed with error 16: \u8bbe\u5907\u6216\u8d44\u6e90\u5fd9.\nThe kernel still uses the old table. The new table will be used at\nthe next reboot or after you run partprobe(8) or kpartx(8)\nSyncing disks.<\/code><\/pre>\n<p>\u91cd\u542f\u670d\u52a1\u5668<\/p>\n<pre><code class=\"language-sql\">[root@pow-altibase01 ~]# reboot\n\nBroadcast message from root@pow-altibase01\n        (\/dev\/pts\/0) at 8:57 ...\n\nThe system is going down for reboot NOW!\n<\/code><\/pre>\n<p>\u91cd\u542f\u540e\u67e5\u770b<\/p>\n<pre><code class=\"language-sql\">[root@pow-altibase01 ~]# fdisk -l\n\nDisk \/dev\/sda: 21.5 GB, 21474836480 bytes\n64 heads, 32 sectors\/track, 20480 cylinders\nUnits = cylinders of 2048 * 512 = 1048576 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0xfbf90500\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sda1   *           2           9        8192   41  PPC PReP Boot\nPartition 1 does not end on cylinder boundary.\n\/dev\/sda2              10         109      102400   83  Linux\nPartition 2 does not end on cylinder boundary.\n\/dev\/sda3             110        1133     1048576   82  Linux swap \/ Solaris\nPartition 3 does not end on cylinder boundary.\n\/dev\/sda4            1134       20480    19811326+   f  W95 Ext&#039;d (LBA)\nPartition 4 does not end on cylinder boundary.\n\/dev\/sda5            1134       20480    19811325+  8e  Linux LVM\n\nDisk \/dev\/sdb: 590.6 GB, 590558003200 bytes\n255 heads, 63 sectors\/track, 71797 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x18104992\n\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sdb1               1        4048    32515528+  83  Linux\n\/dev\/sdb2            4049       11751    61874347+  83  Linux\n\nDisk \/dev\/mapper\/volGroup-volGroup--root: 53.6 GB, 53569650688 bytes\n255 heads, 63 sectors\/track, 6512 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n\n[root@pow-altibase01 ~]# mkswap \/dev\/sdb2\nSetting up swapspace version 1, size = 61874240 KiB\nno label, UUID=c2bfe1ee-1821-4351-a451-592087a74d44\n[root@pow-altibase01 ~]# swapon \/dev\/sdb2\n\n[root@pow-altibase01 ~]# free -g\n             total       used       free     shared    buffers     cached\nMem:            54          0         53          0          0          0\n-\/+ buffers\/cache:          0         54\nSwap:           60          0         60\n\n[root@pow-altibase01 ~]# vi \/etc\/fstab\n\n#\n# \/etc\/fstab\n# Created by anaconda on Thu Feb 25 07:10:22 2016\n#\n# Accessible filesystems, by reference, are maintained under &#039;\/dev\/disk&#039;\n# See man pages fstab(5), findfs(8), mount(8) and\/or blkid(8) for more info\n#\n\/dev\/mapper\/volGroup-volGroup--root \/                       ext4    defaults        1 1\nUUID=fa8e42a0-ad95-45a1-a54c-a984c94f3327 \/boot                   ext4    defaults        1 2\nUUID=208f458a-a3c6-4bfd-8254-f1268f366288 swap                    swap    defaults        0 0\ntmpfs                   \/dev\/shm                tmpfs   defaults        0 0\ndevpts                  \/dev\/pts                devpts  gid=5,mode=620  0 0\nsysfs                   \/sys                    sysfs   defaults        0 0\nproc                    \/proc                   proc    defaults        0 0\n\/dev\/sdb2    swap           swap    defaults        0 0\n~\n~\n~\n~\n\n~\n&quot;\/etc\/fstab&quot; 16L, 855C written<\/code><\/pre>\n<p>\u518d\u6b21\u91cd\u542f\u9a8c\u8bc1<\/p>\n<pre><code class=\"language-sql\">[root@pow-altibase01 ~]# reboot\n\nBroadcast message from root@pow-altibase01\n        (\/dev\/pts\/0) at 9:07 ...\n\nThe system is going down for reboot NOW!\n\n[root@pow-altibase01 ~]# free -g\n             total       used       free     shared    buffers     cached\nMem:            54          0         53          0          0          0\n-\/+ buffers\/cache:          0         54\nSwap:           60          0         60<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>linux\u6269\u5c55swap\u5206\u533a: [root@pow-<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"class_list":["post-1117","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts\/1117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1117"}],"version-history":[{"count":2,"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts\/1117\/revisions"}],"predecessor-version":[{"id":1119,"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts\/1117\/revisions\/1119"}],"wp:attachment":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1117"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}