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

 找回密码
 立即注册
查看: 2722|回复: 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)% h( i3 e6 Y: @1 h
      or: fdisk /dev/sdc  (for the third SCSI disk)* `; [5 X( M3 w* m, W7 ?$ x$ p
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
! t' J5 w# t. D6 i      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
: }  d) o( o; _      ...
  {# l: p5 f, [+ S, {, l
  1. df -k
    + q6 p3 K# E$ z4 K5 N
  2. df -lh1 N# y; k% ]% L& l1 u
  3. 查看有几块硬盘:fdisk -l
    0 t. O( a  ]4 i: O
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
( ?- q+ M- K$ L% C3 u    /dev/sda3              3723848    705968   2828716  20% /) N% ]5 {. U, D4 i- D# ?
    /dev/sda1               101089      9274     86596  10% /boot; e" k& ~6 \3 k  ]( n/ B+ ^
    none                     14520         0     14520   0% /dev/shm; v' R/ n( v5 |- w. r6 y8 v5 w. i' t
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
* V5 Z& T1 Y! ]% y; B  j; _
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel: |! q: Q' t% J1 S
    Building a new DOS disklabel. Changes will remain in memory only,  K  m4 L; A5 |. p
    until you decide to write them. After that, of course, the previous6 k; u0 T) o( C- \
    content won't be recoverable.
# k9 D. }. _3 j% C2 G/ I    The number of cylinders for this disk is set to 8322.
, T* T7 b$ }9 B" s    There is nothing wrong with that, but this is larger than 1024,( D& ]7 x4 u6 E9 \$ T
    and could in certain setups cause problems with:
5 W3 U+ ?/ O3 w5 z! q) |9 w9 D    1) software that runs at boot time (e.g., old versions of LILO)
4 V, R7 c- u) @: w    2) booting and partitioning software from other OSs
! ~3 E0 O( @. R& ~7 ?       (e.g., DOS FDISK, OS/2 FDISK)6 r1 @2 p' P; D5 u7 [
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
; W. c. S2 C5 v. W6 M    Command (m for help): p# G, p& {% W( i* r; g& |/ r
    Disk /dev/hda: 4294 MB, 4294967296 bytes/ W( c( j8 z2 X! |2 r0 O6 o
    16 heads, 63 sectors/track, 8322 cylinders2 s. U9 c/ A4 u/ I# B* w
    Units = cylinders of 1008 * 512 = 516096 bytes; _# ~7 n. ]0 l$ J6 d; @( o. ^
       Device Boot    Start       End    Blocks   Id  System
: w& d, w2 X4 g/ [    Command (m for help): m
# U) Z6 k- A( D9 L5 O& m    Command action7 h: X+ U% {! T$ V! C: ]$ d  L6 j5 |
       a   toggle a bootable flag
9 G# t& O5 Q/ Y       b   edit bsd disklabel( m& i* U) R4 V% P: n# f2 C- d. {
       c   toggle the dos compatibility flag
! |6 s! {- z4 Y- D( _$ E$ C       d   delete a partition
6 p4 Z# B! ]3 Q1 k; y8 X+ k       l   list known partition types
/ ]- X6 q$ c$ h" k8 Z2 a       m   print this menu
7 C5 Z8 z7 T& d& p       n   add a new partition2 a) C& K! S4 k7 d* x; ^7 D3 K+ n- e
       o   create a new empty DOS partition table
2 D* n6 v0 D, ~! t       p   print the partition table
! d& d- n* S2 t( P( c* Y       q   quit without saving changes
& P! B* J  ~/ i       s   create a new empty Sun disklabel& G: Z/ e% D) z* r6 F! m+ v/ S6 X
       t   change a partition's system id
  n: a7 h4 b* \: s       u   change display/entry units2 w4 r! b% K# W) l* u- J
       v   verify the partition table2 O3 P. j; M0 L% I/ F1 p- g( |4 l
       w   write table to disk and exit
! }3 L; v- z: S6 J       x   extra functionality (experts only)% m6 h" L! R! w' ]; l% M+ O
    Command (m for help): n
# a- o# I+ O. ^, b2 p4 B2 g    Command action
0 {( P! D9 w0 W. n3 b4 j       e   extended6 i4 x  [0 _9 r
       p   primary partition (1-4)
8 ^" S! U* u3 _+ d    p
8 b4 z9 f. J' L: p2 J2 H4 Z    Partition number (1-4): 1
& e+ `4 x  t1 [: z    First cylinder (1-8322, default 1):
, R4 ^7 r, b5 h' e+ q# l) g    Using default value 1, N+ P. P; K& R3 D, K1 M0 e6 ^" N8 ?
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G5 k4 k7 {3 R0 L& S0 L
    Command (m for help): p  I4 u  w9 M& t2 q& K% L
    Disk /dev/hda: 4294 MB, 4294967296 bytes
. c0 |, [( d1 F3 d* t( T% S$ O, r    16 heads, 63 sectors/track, 8322 cylinders
- N- l8 Q9 R! y0 B! I    Units = cylinders of 1008 * 512 = 516096 bytes  J& _8 x8 Y! R( {3 `4 q& f
       Device Boot    Start       End    Blocks   Id  System# R5 \' a* j) c  R$ F1 P: o, R2 K+ u
    /dev/hda1             1      1000    503968+  83  Linux5 ]* D+ C) L/ `+ U  k: U' P# o
    Command (m for help): w" [- |& T, D3 u+ P- U; ~5 I  U1 b
    The partition table has been altered!6 I% G  a, K6 L# E; M; U% x
    Calling ioctl() to re-read partition table.( S! V9 c6 P  d
    Syncing disks.
' Y) t/ M9 S# |3 f$ X    //格式化新分区
- y5 K  [# P& E! T$ h$ O! q& \
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
2 _$ _) B& i" G6 O& Y5 [% N  y1 |    Filesystem label=
" ^. @* {! [! x6 e' c8 u    OS type: Linux) i6 j' {' K! n/ U
    Block size=1024 (log=0)9 p4 y  l6 t2 D* q; P1 [
    Fragment size=1024 (log=0)
+ V) W- w+ e' ]/ r; E0 g" s! }: \    126480 inodes, 503968 blocks0 O5 v, ]% W. v# L. X$ i
    25198 blocks (5.00%) reserved for the super user" T3 D+ g0 u" W. T  k
    First data block=1
8 a' U& V9 e  Q+ X; E* y    62 block groups3 Q6 e6 U* [2 m) b1 y
    8192 blocks per group, 8192 fragments per group: l: z+ k$ o. q! [% T
    2040 inodes per group
* V& P/ M+ s  ^( @0 U( y8 c8 O    Superblock backups stored on blocks:
: T& s( f/ D/ F5 F) x0 }6 ^& I* g$ ^            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409( K3 d) o2 A7 J
    Writing inode tables: done                           
0 J5 h) O! h6 G( G/ t+ p" u5 n, A    Creating journal (8192 blocks): done: Z; i2 p* R) n7 S. t5 g
    Writing superblocks and filesystem accounting information: done
  t3 i/ O5 m- a. D; m    This filesystem will be automatically checked every 30 mounts or( e2 u( }2 N) d/ y4 B
    180 days, whichever comes first.  Use tune2fs -c or -i to override., ~4 b3 o& N" m( e4 }
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
8 Q  @% v; x1 z0 w$ Y    /dev/sda3              3723848    705992   2828692  20% /
8 q: X  H" P. ]; J. _; U' |    /dev/sda1               101089      9274     86596  10% /boot
* g, {. J* t4 a) d2 ]    none                     14520         0     14520   0% /dev/shm- o9 M: z7 L4 i, y, h( C
    //挂上新分区. Z9 o0 `7 m$ S! `2 ]7 ]( @# Z
  1. mount /dev/hda1 /home
    ( A5 L( ]; x  g+ ~1 E  M7 w) T& j
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点* p2 i9 W) P6 s  N' `8 R' i
    /dev/sda3              3723848    705992   2828692  20% /
* ?$ U, N+ H" C8 h5 b2 k    /dev/sda1               101089      9274     86596  10% /boot. M" O6 L' l3 i3 Q
    none                     14520         0     14520   0% /dev/shm8 K+ Q4 y- S; J/ h5 J) C3 D& K
    /dev/hda1               488006      8239    454569   2% /home
1 T6 v1 i: x) g4 N) [" J; J. B# Y3 i# G! A9 _# R
自动挂载:" B5 z, j! [$ Y+ V+ H+ M
  1.           vi /etc/fstab
    . T6 M9 q) j4 M7 d  j- c& J2 \2 P
  2. # N: N! E" M. ]( U9 M
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0) W9 e$ \9 Y0 z! }. ^0 h
  4. , }5 L+ P6 ^7 r) I" C. _9 Q
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
+ o( V+ ^2 N; a0 ^
  1.           mount /dev/sdb5 /mnt/ljp1
    . l+ l! O; B0 F- h% z
  2. . W* G3 W1 J3 x2 @8 F- H: b
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
4 E, O/ q$ q8 ]1 W% e
7 B9 q4 c& @, B& {2 K; D3 f* n( g* _
4 Y& U  b7 N  f+ E
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-30 18:36 , Processed in 0.009755 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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