18. 专题
Special
#fdisk /dev/had //使用/dev/had 作为默 Disk /dev/sda: 4294 MB, 4294967296
这里要选择新建的分区类型,是主分区还是
认的分区设备 bytes
255 heads, 63 sectors/track, 522 扩展分区 ;并 选择 p 或是 e 。 然后 就是 设置分
Command (m for help): m //选择命令选项
cylinders 区的大小。
Command action
Units = cylinders of 16065 * 512 =
a toggle a bootable flag 要提醒注意的是,如果硬盘上有扩展分区,
8225280 bytes
b edit bsd disklabel
Device Boot Start End 就只能增加逻辑分区,不能增加扩展分区。
c toggle the dos compatibility Blocks Id System
flag 在增加分区的时候,其类型都是默认的
/dev/hda1 * 41 522
d delete a partition 3871665 83 Linux
l list known partition types Linux Native ,如果要把其中的某些分区改
/dev/hda2 1 40
m print this menu 321268+ 82 Linux swap 变 为 其 他 类 型 , 例 如 Linux Swap 或 FAT32
n add a new partition Partition table entries are not in disk 等,可以通过命令 t 来改变;如果想知道系统
o create a new empty DOS partition order
table 所支持的分区类型,键入 l,如下所示:
Command (m for help):
p print the partition table Command (m for help): t
如果想完全改变硬盘的分区格式,就可以通 Partition number (1-4): 1
q quit without saving changes
s create a new empty Sun disklabel 过 d 参数一个一个地删除存在的硬盘分区。删 Hex code (type L to list codes): 82
t change a partition's system id 除完毕,就可以通过 n 参数来增加新的分区。 Changed system type of partition 1 to
u change display/entry units 82 (Linux swap)
当按下“n”后,可以看到如下所示:
v verify the partition table 改 变 完 了 分 区 类 型 , 就 可 以 按 下 “ w” , 保
w write table to disk and exit Command (m for help): n
Command action 存并退出。如果不想保存,那么可以选择“ q”
x extra functionality (experts
only) e extended 直接退出,如下所示:
p primary partition (1-4) Command (m for help):w
用 户 通 过 提 示 键 入 “ m” , 可 以 显 示 Fdisk p
命令各个参数的说明。 Partiton number(1-4):1 原文:
First cylinder(1-1023):1 http://os.51cto.com/art/201012/240726.htm
在 Linux 分 区 过 程 , 一 般 是 先 通 过 p 参 数
Last cylinder or + size or +sizeK or
来显示硬盘分区表信息,然后根据信息确定将 + sizeM(1-1023):+258M
来的分区。如下所示:
18 http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
投稿信箱:yangsai@51cto.com
19. 专题
Special
* the CPU loadavg code.
load average 是 0 的时候都认为他很低, 10 的时候就觉得高, 20 就不用讲了!但是除
*/
了这两种极端的情况之外,那什么时候是这两个值的临界点?当别人问起我这个问题的时候 static void spu_calc_load(void)
我也不知道如何回答。 {
unsigned long active_tasks; /* fixed-
point */
系统负载:如何判断 Linux load 的值是否过高
active_tasks = count_active_contexts()
* FIXED_1;
文/色萝卜 CALC_LOAD(spu_avenrun[0], EXP_1,
active_tasks);
CALC_LOAD(spu_avenrun[1], EXP_5,
接
active_tasks);
触过和使用过 unix 或 linux 的朋友 系 统 不 行 了 。 load average 是 0 的 时 候 都 CALC_LOAD(spu_avenrun[2], EXP_15,
都知道如何查看 Unix/Linux load 认为他很 低 , 10 的 时候 就 觉 得高, 20 就不用 active_tasks);
}
的值,这边我也重复一下查看 load 的方法: 讲了!但是除了这两种极端的情况之外,那什
[root@aaronw ~]# uptime CALC_LOAD 是这样定义:
么时候是这两个值的临界点?当别人问起我这
13:33:37 up 7 days, 1:52, 1 user, load #define LOAD_FREQ (5*HZ+1) /* 5 sec
个问题的时候,我也不知道如何回答,在我大 intervals */
average: 4.15, 2.00, 3.14
[root@aaronw ~]# w 脑里就根本就没有考虑过。困扰了我很久,我 #define EXP_1 1884 /* 1/exp(5sec/1min)
13:35:35 up 1 days, 1:54, 1 user, load as fixed-point */
觉得要搞明白他!
average: 0.00, 0.00, 0.00 #define EXP_5 2014 /* 1/exp(5sec/5min)
USER TTY FROM LOGIN@ IDLE JCPU PCPU 先 从 linux 的 kernel 的 源 码 开 始 吧 ! 在 */
WHAT #define EXP_15 2037 /*
linux 2.6.36 版本中有这样一段代码:
root pts/1 192.168.2.2 13:33 0.00s 1/exp(5sec/15min) */#define
/** CALC_LOAD(load,exp,n)
0.02s 0.00s w
* spu_calc_load – update the avenrun load *= exp;
load average 后 面 三 个 值 代 表 系 统 在 1 load estimates. load += n*(FIXED_1-exp);
分钟、5 分钟和 15 分钟的负载情况,都知道数 * load >>= FSHIFT;
* No locking against reading these
字越高表示系统负载越大,第一直觉就是这个 values from userspace, as for 从这里我们能看到取负载值的最小周期 5 秒。
19 http://g.51cto.com/linuxops/
http://os.51cto.com/linux/
投稿信箱:yangsai@51cto.com