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

 找回密码
 立即注册
查看: 2655|回复: 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); x+ H2 n0 {- ~
      or: fdisk /dev/sdc  (for the third SCSI disk)9 K4 k/ O9 p. t5 \% \; W% r1 C# P
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)7 E, l8 e: T2 Z% k$ n
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)8 Q- X7 n: u# c9 U- A$ {0 E
      ...
2 D; R; s$ i; F: l- |5 {9 C# P
  1. df -k: P/ n0 [+ E) S
  2. df -lh
    5 h) E2 z3 p9 k3 k
  3. 查看有几块硬盘:fdisk -l
    ' `/ k3 `" ~" I* P" ?% u
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
! ?/ Q0 v0 l9 ~0 ~7 P% B    /dev/sda3              3723848    705968   2828716  20% /) E% `5 q$ k5 b3 |; @  F
    /dev/sda1               101089      9274     86596  10% /boot
& Z, E. D1 B) [/ ^; L1 s7 ^$ k3 Z+ G    none                     14520         0     14520   0% /dev/shm1 e+ u8 O# `3 y, B* @% M6 n
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
' L7 h6 K) j2 e$ P( E
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel; y$ B- q7 \4 ]  h2 t- q8 E& O
    Building a new DOS disklabel. Changes will remain in memory only,3 h7 w$ u  M# @7 h7 ]: c7 f
    until you decide to write them. After that, of course, the previous
* B1 |9 W4 O& e/ ]    content won't be recoverable.6 e2 ~  _. M6 T
    The number of cylinders for this disk is set to 8322.7 v5 r2 T' \" k/ p
    There is nothing wrong with that, but this is larger than 1024," C& ]" I( z# D% V9 D2 I+ E
    and could in certain setups cause problems with:* \0 i% Y  v2 o6 B- |
    1) software that runs at boot time (e.g., old versions of LILO)
3 x, g& j% b: e8 o; o) t    2) booting and partitioning software from other OSs
4 ~+ B6 ?# a$ C. Y% C7 d" `, v       (e.g., DOS FDISK, OS/2 FDISK)
9 L+ b* V" m# W2 H/ S    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite); }6 U) T$ q- Z
    Command (m for help): p& t' F  B( b* R( r
    Disk /dev/hda: 4294 MB, 4294967296 bytes6 r$ u1 H' ?; q# {5 p. G0 T8 J
    16 heads, 63 sectors/track, 8322 cylinders8 g/ W( N3 x# u& K4 Y
    Units = cylinders of 1008 * 512 = 516096 bytes
) C1 a$ q3 _: j7 E: G' p       Device Boot    Start       End    Blocks   Id  System
! V) m. h) a+ E1 [) s% E3 f) I    Command (m for help): m
, |. i8 j8 E# T. x! i' c    Command action8 C% I. x, z- t  ]! Y2 O
       a   toggle a bootable flag% b. X7 B" r6 |0 T+ a
       b   edit bsd disklabel
: x/ y/ N% l0 F- Z       c   toggle the dos compatibility flag2 O5 f& F& x- M
       d   delete a partition
. ]4 T) M3 K( I- }" ~% s5 m       l   list known partition types" j* |  y0 M( g
       m   print this menu6 K5 b2 w; Y9 C6 o
       n   add a new partition. q' f: ]# w  d- k1 @9 C4 J
       o   create a new empty DOS partition table0 Y: ~7 B* G9 N
       p   print the partition table/ n3 @3 p' c( b, T$ `2 t4 b" a
       q   quit without saving changes' b  b/ R! H8 L9 Q0 Z
       s   create a new empty Sun disklabel
: T/ P- l; u, s  l, K       t   change a partition's system id( K  y. Z# J, e: |9 X8 a: V  P& I
       u   change display/entry units" L" g6 v: B( \6 t0 y# o
       v   verify the partition table
9 a3 G+ P. F4 Y# v       w   write table to disk and exit# q7 V! j2 G+ k; ^
       x   extra functionality (experts only)
5 X7 h1 A- G5 M( r    Command (m for help): n
# H; \; b3 A+ W    Command action' q, S3 i. V' ?+ }# Z" m
       e   extended
. W/ ]5 S0 v& W% n" v       p   primary partition (1-4)
+ E$ |  ^' J% K, Z: Q* p0 ?' F    p
: c, I7 I4 J) q( n% @    Partition number (1-4): 1
/ Y; ^% y; s& @* o# P    First cylinder (1-8322, default 1):
- B+ H" W; I4 s" u    Using default value 1: b& t) O  T2 b$ n( k- `, @
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
. g! `3 m( F, X3 \5 p( A    Command (m for help): p
( V, \' ?; d  {( r; v! m+ l    Disk /dev/hda: 4294 MB, 4294967296 bytes9 W, n9 w! n- h0 A6 g# N) y* e
    16 heads, 63 sectors/track, 8322 cylinders
/ n, N' {8 o3 ^8 H# ~! G    Units = cylinders of 1008 * 512 = 516096 bytes' u0 n/ M( z2 e2 {; F. s
       Device Boot    Start       End    Blocks   Id  System8 C) h2 S7 ^( ~) J1 T$ q: X: r
    /dev/hda1             1      1000    503968+  83  Linux
+ c% r, Z8 J/ ~    Command (m for help): w
3 g# }/ h: D8 j/ n1 F    The partition table has been altered!+ E% c4 Z, u6 P; W5 f
    Calling ioctl() to re-read partition table.
4 k. t4 D3 E& u% q  O2 E    Syncing disks.
/ m  C5 ?* ^+ l+ A1 g    //格式化新分区, ?" `. s: t( p6 q
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)4 d  y4 y% H# R1 B0 G4 _+ |2 g) H1 d
    Filesystem label=
9 p7 z: k; k6 f5 V* D: j0 t0 m    OS type: Linux
* B  Q; k* l4 U7 o" s    Block size=1024 (log=0)" L$ _# i0 z2 r, R; K& o; N
    Fragment size=1024 (log=0)* s+ T$ T4 }; u# s
    126480 inodes, 503968 blocks
% q1 L9 u( m( N    25198 blocks (5.00%) reserved for the super user
% ~" @% Z: m  \. |    First data block=15 [: v4 s5 V/ N! K2 ?
    62 block groups
0 m8 s2 V7 q3 u4 c( ]    8192 blocks per group, 8192 fragments per group
/ T7 M+ V' k9 p. A. L( C    2040 inodes per group
" W: g  D0 k1 w2 O: [& h" ~, P5 Y7 x    Superblock backups stored on blocks:
: H' j% C/ T; A; Z            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409$ c% Z9 U7 I/ R
    Writing inode tables: done                            & \0 Z# `- Q, n2 h
    Creating journal (8192 blocks): done. G3 L$ b7 Z/ @2 ~0 b
    Writing superblocks and filesystem accounting information: done
; H; p0 c/ I5 V: n- x    This filesystem will be automatically checked every 30 mounts or
( L7 ?9 V% S2 q& F3 q" E    180 days, whichever comes first.  Use tune2fs -c or -i to override.
( F) c9 m  t, h1 l0 v. F8 a
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点2 W7 s) l5 Y+ R3 \! N" j
    /dev/sda3              3723848    705992   2828692  20% /+ c& |  c6 u6 X; ~! }
    /dev/sda1               101089      9274     86596  10% /boot
% K0 _( N7 N/ B    none                     14520         0     14520   0% /dev/shm% X" S; W2 Y% x6 B. I% I
    //挂上新分区
6 S6 \# H: ]& j/ g
  1. mount /dev/hda1 /home
    * b* c4 D+ i# J3 ~4 O
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
5 A0 _, x/ h  ?2 P+ W: T9 q    /dev/sda3              3723848    705992   2828692  20% /
0 n  ?0 T- ?4 J- u    /dev/sda1               101089      9274     86596  10% /boot- t9 x% `. e0 x' F' ?/ E. [
    none                     14520         0     14520   0% /dev/shm
0 f) P! t" A4 T7 n" w5 B) v9 C    /dev/hda1               488006      8239    454569   2% /home
: A0 v+ P8 G4 }5 a+ M1 o- g: c, l/ ^, n+ e+ g' D
自动挂载:
3 V" _- E" Z$ E. @
  1.           vi /etc/fstab' q- z2 B% Q# ^" ?
  2. ' G, J' y% v# y" V
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 07 k& x7 F. O+ Q( T; w& z/ N
  4. $ i- k  y4 F; {% L% ]3 M3 q, I3 w
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
9 h9 N5 w$ \1 u  f, u
  1.           mount /dev/sdb5 /mnt/ljp1/ \4 [8 x0 |5 F+ @/ i- _

  2. 2 ~% A/ [  w/ [. H! h$ u# E
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
/ B0 N9 ?6 f! d$ U

8 M6 A& A3 }5 w, _& ?* D, E! I! E+ \% D( C; a
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-8 13:36 , Processed in 0.023203 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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