FlossDoc: 請協力 GPLv3 的中文翻譯工作。
建立置換空間 (swap space)
FlossDoc,自由中文開源知識庫
在 GNU/Linux 上要建立置換空間 (swap space) 有兩個方法:
[编辑]
使用置換分割區 (swap partition)
使用 fdisk 或其他磁碟分割程式分割一個分割區,該分割區類型為 0x82:
Disk /dev/sda: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00052d4e Device Boot Start End Blocks Id System /dev/sda1 * 1 7972 64035058+ 83 Linux /dev/sda2 7973 9729 14113102+ 5 Extended /dev/sda5 7973 9381 11317729+ 83 Linux /dev/sda6 9382 9729 2795247 82 Linux swap / Solaris
然後使用命令「mkswap 置換裝置」格式化 swap 空間:
# mkswap /dev/sda5 Setting up swapspace version 1, size = 2000024 KiB no label, UUID=56655b26-7b67-4372-ac9a-6477b554c8a7
啟用 swap 空間:
swapon /dev/sda5
[编辑]
使用置換檔案 (swap file)
在不想重新分割分割區的情況下,可以使用置換檔案 (swap file)。
首先建立一個空檔案:
dd if=/dev/zero of=swapfile bs=1024 count=100
以上指令會建一個 100MB 大小的空檔案。(如要大一點的 swap 空間,可以改動 count 的值)
然後使用命令「mkswap 置換檔案」格式化 swap 空間:
# mkswap swapfile Setting up swapspace version 1, size = 104810 kB no label, UUID=a3142a69-8fc8-41f4-80e1-dc4e4aaf239b
啟用 swap 空間:
swapon swapfile
[编辑]
相關連結
- Idea Excursion: All About Linux Swap (2009)
- “Part 1: Introduction” (2009-01-29)
- “Part 2: Management” (2009-02-02)
- “Part 3: Analysis” (2009-02-06)
- “Linux: Should You Use Twice the Amount of Ram as Swap Space?” (Vivek Gite 2008-12-08)
- Red Hat Enterprise Linux 5.2 Deployment Guide: “5.1. What is Swap Space?” (Red Hat 2008-03-15)
- “All about Linux swap space” (Gary Sims 2007-12-03)
- IBM developerWorks: “System Administration Toolkit: Swap space management and tricks” (Martin Brown 2006-10-31)
- The Linux System Administrator's Guide, Version 0.9: “6.2. Creating a swap space” (Lars Wirzenius, Joanna Oja, Stephen Stafford & Alex Weeks 2005-06)
- “Increase your available swap space with a swap file” (Matt Moen 2005-03-03)
- Red Hat Linux 9: Red Hat Linux Customization Guide: “2.2. Adding Swap Space” (Red Hat 2003)
- 台灣 Debian 中文 Wiki: SwapFile (2003-12-02)
- “Linux Swap Space Mini-HOWTO”, version 1.6 (Rahul Sundaram 2002-12-27)
- “Swap This! Swap Space Management” (OutRider 2000-03-05)
- “Adding Swap Space on the Fly in Linux” (Urbana Der Ga'had 2000-05-29)
- Puppy Linux Wiki: SwapFile

