root@slackware:/# fdisk /dev/sda
The number of cylinders for this disk is set to 8841.
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):
现在我们告诉 fdisk 我们希望分区。1024 柱面限制并不是问题,Slackware 引导大于此的硬盘也没有问题。输入 m 来获取帮助。
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
在最小情况下,你需要一个 / 分区以及一个 swap 分区。你可能也像单独分出 /home 分区用来存放用户文件(这对于之后升级和安装不同的 Linux 操作系统而要保持用户文件很容易)。创建一个新的分区可以输入 n 。
Command: (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-8841, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-8841, default 8841): +8G
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (975-8841, default 975): 975
Last cylinder or +size or +sizeM or +sizeK (975-8841, default 8841): +1G
这里我们创建了两个分区,一个 8GB,一个 1GB,可以输入 p 来查看。
Command (m for help): p
Disk /dev/sda: 72.7 GB, 72725037056 bytes
255 heads, 63 sectors/track, 8841 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 974 7823623+ 83 Linux
/dev/sda2 975 1097 987997+ 83 Linux
这两个分区类型都是 Linux 文件系统。我们需要改变 /dev/sda2 为 swap(id 为 82)。
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 82
Command (me for help): p
Disk /dev/sda: 72.7 GB, 72725037056 bytes
255 heads, 63 sectors/track, 8841 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 974 7823623+ 83 Linux
/dev/sda2 975 1097 987997+ 82 Linux swap
Command: (me for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1098-8841, default 1098): 1098
Last cylinder or +size or +sizeM or +sizeK (1098-8841, default 8841): 8841
现在我们可以将修改写入。
Command: (me for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@slackware:/#