Linux下用fdisk进行分区的步骤

系统 Linux
当你在Linux服务器上装上全新的硬盘后,你需要用类似 fdisk 这样的工具进行相应的分区。 fdisk中相应的提供5种基本操作:

当你在Linux服务器上装上全新的硬盘后,你需要用类似 fdisk 这样的工具进行相应的分区。

fdisk中相应的提供5种基本操作:

o n – 创建新分区 
o d – 删除一个已有的分区 
o p – 打印现有的分区表 
o w – 把改动写入到分区表,也就是保存. 
o q – 离开 fdisk

创建新分区

在下面的例子中, 我创建了主分区 /dev/sda1

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. The number of cylinders for this disk is set to 34893. 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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): p
Disk /dev/sda: 287.0 GB, 287005343744 bytes
255 heads, 63 sectors/track, 34893 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-34893, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-34893, default 34893):
Using default value 34893
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

 

确认分区是否创建成功

 

1
2
3
4
5
6
7
8
9
10
11
12
# fdisk /dev/sda
The number of cylinders for this disk is set to 34893.
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: 287.0 GB, 287005343744 bytes
255 heads, 63 sectors/track, 34893 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 34893 280277991 83 Linux
Command (m for help): q

 

Linux下用fdisk进行分区的步骤就介绍到这里了。

【编辑推荐】

  1. 如何在RHEL5.7下搭建和配置DHCP服务器
  2. Linux服务器的16个监控命令
  3. 服务器性能指标:拨开服务器评测体系迷雾
责任编辑:赵宁宁
相关推荐

2010-05-28 18:23:27

Linux分区工具

2019-02-11 14:50:21

Linux分区命令

2014-08-07 11:26:04

linuxfdiskpartprobe

2022-01-11 15:10:18

Linuxfdiskparted

2009-12-25 09:54:56

linuxfdisk

2010-12-24 10:25:20

SCP 命令

2011-03-09 10:25:25

Linux安装LAMP

2009-03-06 16:21:59

LinuxTestdisk修复软件

2018-01-15 14:59:35

Linux命令交换分区

2009-01-09 22:52:16

服务器硬盘Linux

2011-08-16 16:45:18

2011-08-10 14:51:46

LinuxLVM分区

2011-01-10 13:40:35

linux硬盘分区

2011-08-16 17:19:59

linux加密分区

2009-12-08 12:24:36

LinuxNTFS分区写操作

2010-11-02 14:16:02

linux下安装DB2

2016-10-27 13:25:08

LinuxMySQL安装

2009-12-17 17:41:52

2010-01-04 10:02:10

Linux挂载u盘

2010-03-02 15:35:41

Linux硬盘分区
点赞
收藏

51CTO技术栈公众号