稳定互联,中美互联,站长交流,虚拟主机,香港主机,美国主机,虚拟空间,免费空间,免费VPS,免费域名

 找回密码
 立即注册
查看: 3253|回复: 0

[经验] linux下添加新硬盘方法

[复制链接]
发表于 2014-2-9 19:20:26 | 显示全部楼层 |阅读模式
  1. fdisk
复制代码
Usage: fdisk [-l] [-b SSZ] [-u] device    E.g.: fdisk /dev/hda  (for the first IDE disk)
+ {0 j5 Q& W7 I. U3 L      or: fdisk /dev/sdc  (for the third SCSI disk)
' r- z: C8 |7 a- J+ e  o0 V# X) {      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)' _8 i; a4 i. U% t. P& @
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
  g: t4 a5 d0 m0 `& L$ I      ...
) m' @3 j8 `6 B
  1. df -k
    7 G. }$ C$ E0 ~0 ]& Y
  2. df -lh
    7 l, V8 s! }* [- f' _, V% p
  3. 查看有几块硬盘:fdisk -l
    $ ]% H* B2 U* L. F
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点! H0 D0 r7 L. m8 V/ A
    /dev/sda3              3723848    705968   2828716  20% /
( y- _% q% G9 ?    /dev/sda1               101089      9274     86596  10% /boot
9 _& U# i5 i( B; s' K" z5 h    none                     14520         0     14520   0% /dev/shm) G# O) F& I; [  X0 G5 F0 H
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用/ j" s8 c3 K$ l1 }) l0 J" s
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel4 U6 q' r6 C7 q* [2 \2 X$ n/ D
    Building a new DOS disklabel. Changes will remain in memory only,
, h, U3 w8 S% w/ Q3 ~# B1 [1 t    until you decide to write them. After that, of course, the previous, v) E9 o1 ]4 S- K2 K; F. g4 ]( z
    content won't be recoverable.
) n6 _5 D" D$ }7 V7 q    The number of cylinders for this disk is set to 8322.7 M5 d4 ~4 b& I5 Y2 c
    There is nothing wrong with that, but this is larger than 1024,
2 G) m4 J4 V2 h; C0 |    and could in certain setups cause problems with:
! {% I  |7 p) Y, f9 `! _( g    1) software that runs at boot time (e.g., old versions of LILO): Q- f$ o( h! H: [# k4 M+ p# Z
    2) booting and partitioning software from other OSs
( _  L  j: x2 R2 O3 G8 I9 Z6 m% B       (e.g., DOS FDISK, OS/2 FDISK)' a$ k7 K9 A! N
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)# M; y' t0 F1 P* j+ f
    Command (m for help): p/ o, r7 B) Z  P
    Disk /dev/hda: 4294 MB, 4294967296 bytes
$ ?3 U6 H! g4 E; W8 V7 l  D& G    16 heads, 63 sectors/track, 8322 cylinders
6 K, o7 U; y; w# h    Units = cylinders of 1008 * 512 = 516096 bytes0 k( ]3 ?) f  M& {) {) ?6 G
       Device Boot    Start       End    Blocks   Id  System5 L5 L$ F# L, e) D
    Command (m for help): m4 L) \* [1 w( _  Q% G
    Command action
4 s/ S; S' h$ U. c/ Q! h& z0 i       a   toggle a bootable flag! q) ~' }3 o: b7 @5 z, X& V$ A, `/ R
       b   edit bsd disklabel
$ [2 z$ q# w+ l; V5 ^& t; u4 `       c   toggle the dos compatibility flag
% @) x, ?9 a$ U       d   delete a partition
* h2 a  Z3 t* Z: s" U' G0 A3 Z       l   list known partition types4 @8 u" r  n3 q
       m   print this menu
8 L6 h5 ?% k6 N( t' V       n   add a new partition
5 }, X6 [1 j! a1 J+ c       o   create a new empty DOS partition table
8 b/ l5 x0 c7 X$ z+ c, D       p   print the partition table
1 p6 x8 K9 q; n( G9 Q/ b       q   quit without saving changes
" {' E) D1 R6 W" {7 @       s   create a new empty Sun disklabel
$ A) D+ Z/ O4 {7 s/ w- S3 o       t   change a partition's system id
- A# @4 r' _2 X, D7 H8 K       u   change display/entry units
  {! N( e6 ?( m+ v  e0 ]       v   verify the partition table
+ T  M- s) s$ A* L9 s5 ^       w   write table to disk and exit5 r! A6 \. |: `) D3 ]4 W5 ]' A
       x   extra functionality (experts only)8 d" s% o, N- [6 z+ H9 s% q! h
    Command (m for help): n4 g' W6 n5 v7 T2 c9 V) m; n. `
    Command action
! c2 R1 e0 ~1 x) J       e   extended* g$ ]  L; ~) K- X% z; R$ Q
       p   primary partition (1-4), C, U2 }) b9 c1 J* M; r0 e. ]! k
    p
2 @, T1 f! b5 R7 y0 H; N    Partition number (1-4): 18 x5 c8 n' _: B5 q5 C5 z& J, Q0 [4 A
    First cylinder (1-8322, default 1): + m, N' X) ^3 r9 ]& ?: G3 a# N
    Using default value 1
. L! F5 \3 K; V5 L& i  g) Q5 ~    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
/ i/ P' b/ G0 u' i    Command (m for help): p- z. [4 y. J  f' t+ K$ Q
    Disk /dev/hda: 4294 MB, 4294967296 bytes
+ v" ?2 ^9 S: x3 ]    16 heads, 63 sectors/track, 8322 cylinders. E6 U- W& m- B. e+ q- X
    Units = cylinders of 1008 * 512 = 516096 bytes
. k4 ?. o( D% O' Z% x       Device Boot    Start       End    Blocks   Id  System: @- P' u$ c, r1 Z  j
    /dev/hda1             1      1000    503968+  83  Linux/ Q$ I0 Z5 u- T0 \
    Command (m for help): w
0 B8 }$ R2 G. O) G# ?    The partition table has been altered!$ Z. H% |( Z7 P) A" h) Q
    Calling ioctl() to re-read partition table.
: T8 m4 u$ o7 |0 [* ?2 \$ \    Syncing disks.
7 z5 M) j$ R& I5 D* O+ f  a    //格式化新分区8 f+ ~4 K- U- M% E5 W, r
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)+ h3 z6 s0 |0 B; Y) f; Y
    Filesystem label=4 U! |9 f- I% B& G. m
    OS type: Linux
3 i2 n; F0 c/ Z0 E+ H9 ^9 ]    Block size=1024 (log=0)
" I5 T6 S% \0 R. h7 y    Fragment size=1024 (log=0)& }8 v; h/ H& ?
    126480 inodes, 503968 blocks# S# V- i: G( }0 F; `, e
    25198 blocks (5.00%) reserved for the super user3 }! R) J- F9 i
    First data block=1
+ d( D! K: b+ }4 z7 `    62 block groups% B) V4 a: u! F; w8 B
    8192 blocks per group, 8192 fragments per group
) l2 @- P+ E) x/ L$ }1 R% F    2040 inodes per group+ r3 b& V7 Y- M
    Superblock backups stored on blocks: & I& h; P% t- c+ A8 s# r7 S" b
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409$ d. Z! c3 ~# C$ `. x7 u( t
    Writing inode tables: done                           
- s: ]3 a+ ]9 [* }6 y' `    Creating journal (8192 blocks): done. h7 M! L9 O! T. l
    Writing superblocks and filesystem accounting information: done: C' h) N* }# w+ K% V' K
    This filesystem will be automatically checked every 30 mounts or' |3 S  M- c! U) d. U5 p
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
. m- T$ G  o8 x9 f5 n- g6 E
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点( r4 D0 _# D/ b
    /dev/sda3              3723848    705992   2828692  20% /
" z# z3 Z! p8 C/ r" S2 H    /dev/sda1               101089      9274     86596  10% /boot
) Z# l: U6 Z2 U% K9 z    none                     14520         0     14520   0% /dev/shm5 f* g! Y* t8 G' o! l2 G7 y
    //挂上新分区3 k2 ^/ w9 L- h
  1. mount /dev/hda1 /home
    ! x* L2 q9 u0 }3 f
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
  C  I7 b7 U- Y- P1 k( g- O    /dev/sda3              3723848    705992   2828692  20% /
: O; t/ x' W# D' D/ G! w    /dev/sda1               101089      9274     86596  10% /boot1 u0 l0 e( ]4 D
    none                     14520         0     14520   0% /dev/shm
4 b8 Y$ C  Q0 @1 T( l4 v) B    /dev/hda1               488006      8239    454569   2% /home
9 y& _( w, ~/ M) w- ?
) L* U/ l7 T  W% i" V+ A自动挂载:
! m& t; C" S0 G3 d- n/ o
  1.           vi /etc/fstab& I7 \! X, u' m" b# h! W7 H

  2. . E; h8 Y- L: L  K) n1 \7 g# S& g
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    9 J) @7 E/ t6 _& Q- x

  4. 5 o# J1 z) u3 [! ?8 `+ W
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:' s" r- X! H# \8 `# t! B  b. W8 j
  1.           mount /dev/sdb5 /mnt/ljp13 S$ p2 m$ |5 _+ d
  2. & O3 l% x$ U& H. o, m
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
) O" J3 F# L& J8 q3 g: b
% z! c0 C! G& |& _5 F/ y6 u5 y
1 Y0 q: ~- o7 x; h8 i
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|WdidcNet ( 苏ICP备17005075号-1 )

GMT+8, 2026-8-14 01:31 , Processed in 0.011288 second(s), 8 queries , Redis On.

Powered by Discuz!

© 2010.

快速回复 返回顶部 返回列表