Use fdisk to Create a Swap Partition

This section assumes a swap partition is available, appropriately sized for the RAM on the local system. This section illustrates how to create an additional swap partition using fdisk. You already know how to open a disk for editing with fdisk. Here, I create a swap partition on my second SCSI hard drive. For the purpose of this exercise, I assume there’s at least 512MB of free space available. (For learning purposes, the swap partition can be smaller.)

1. I run the sudo fdisk /dev/sdb command to get to the following fdisk prompt:

Command (m for help):

2. I run the l command to list available file types. While the fdisk default creates a Linux Native type partition, many other types are available. Note the hex code for a regular Linux partition (83) and a Linux swap partition (82).

3. I run the n command to create a new primary or logical partition. I create it and specify with a size of 512MB.

4. I run the p command to review the new partition, and note the number assigned to the partition.

5. I run the t command, and type in 82 to change the file system type to a Linux swap partition.

6. I confirm the result by running the p command again.

7. I run the w command to write the changes to disk. At this point, I can format the new partition, activate it as a swap device, and then configure it in /etc/fstab. This process is discussed a bit later.

Posted on: 22/12/2009

If you want to leave a comment please Login or Register
New Debian stable release......
OpenSuSE 11.3......
The Origins of Linux......
Use fdisk to Create a Swap Partition......
Checking In a File Revision......