发表于: lnmp | 作者: | 日期: 2013/9/16 07:09
标签:

fdisk是linux下的一个硬盘分区工具,硬盘分区原理一样,但工具格式等等都不一样,一个是在装系统时的分区,一个是装好系统后的分区。
装系统时的分区,装好系统后一般是没法修改也不好调整的,在装系统时未分区的硬盘空间,装好系统后是可以操作或分区加载的。
这里主要是说这种情况,一个是对未分区的空闲硬盘的操作,又或是对新加的硬盘操作,
这里就要用到fdisk了,不过这个只能在2T以内的硬盘操作,大于2T的,就没法用了,得用到另一个parted的工具。
还有一点,Linux对于硬盘的理解是以
/dev/hd|sd(a|b|xxx)这样方式的
hd主要是对于IDE的硬盘,这个已经很少见了
大部分都是sd开头的,包括stata,sas,scsi等接口的硬盘,比如
hda是第一块硬盘
hdb是第二块硬盘
sda是第一块硬盘
sdb是第二块硬盘
这里的顺序,还和一个因素有关,就是接口顺序或是跳线,大家应该知道,硬盘接口里是有一个跳线什么的,也就是一个主硬盘等
下面介绍fdisk的用法
fdisk -l是列表所有的硬盘,如下

[root@hnwt ~]# fdisk -l
Disk /dev/sda: 320.0 GB, 320071851520 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 38913 312464250 8e Linux LVM

fdisk /dev/sda表示操作硬盘,运行这个后会进入fdisk的交互状态,如下

[root@hnwt ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 38913.
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):

这里提示你,按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)
Command (m for help):

上面这里就列出了所有的参数
根据上面的提示,可以继续操作,如下简单说明
新加分区
1 按n新加
2 选择主分区/扩展分区
3 起始值,默认回车就可以
4 分区大小值
完成
删除分区
1 按d
2 选择相应的分区号,回车即可
改变分区类型
1 按t
2 选择分区
3 选择分区类型(按l可列表所有分区及ID)
linux下主要是一个交换分区里需要在此操作
一般的操作,有如上的三个
在所有操作完时,也确保正确时,可以按w保存并退出
如果有操作有误,按q直接退出就可以
上面的操作,请勿在线上环境/生产环境测试,否则后果自负
对于测试机或虚拟机,可以多操作几次,熟能生巧
来源:http://www.wdlinux.cn/bbs/thread-1089-1-1.html

: https://blog.darkmi.com/2013/09/16/1084.html

本文相关评论 - 1条评论都没有呢
Post a comment now » 本文目前不可评论

No comments yet.

Sorry, the comment form is closed at this time.