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

 找回密码
 立即注册
查看: 2759|回复: 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)/ t8 W& r$ X7 T( c( B' l- O. V  M
      or: fdisk /dev/sdc  (for the third SCSI disk)7 A! B8 ?/ l% ~2 L& s9 f2 a
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)6 P2 A: D# a6 m" m8 }9 G
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
- w/ \2 S' M: o2 w3 x! @      ..., H3 l, o4 X/ R7 e* X* ?
  1. df -k8 t( c3 L0 G6 \5 i! ~
  2. df -lh. J, E( S) @2 H/ i# }; s" U. Q5 F
  3. 查看有几块硬盘:fdisk -l: a) Y  k, H. R
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
; z9 o% M% g( G6 ^6 h    /dev/sda3              3723848    705968   2828716  20% /) Y3 j4 Y1 b$ u
    /dev/sda1               101089      9274     86596  10% /boot/ K! S% e3 E! {- R; g
    none                     14520         0     14520   0% /dev/shm
) m7 T+ Z5 ]& g. q    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
5 U- {# F0 ^& V8 Y. z
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
; z* Q) F/ }7 g$ |# \" l    Building a new DOS disklabel. Changes will remain in memory only,% E+ l% G$ S1 g  P- y$ d+ f9 P
    until you decide to write them. After that, of course, the previous9 c6 P( @0 P" `. ?2 s7 Z
    content won't be recoverable.6 E8 ^1 R% X3 Z2 q! T  N0 S$ |
    The number of cylinders for this disk is set to 8322.
: @. {' v- W# J    There is nothing wrong with that, but this is larger than 1024,
" x# _3 A  i: H6 K  o    and could in certain setups cause problems with:
/ Q2 r4 Q5 y3 W9 P! E% q  f    1) software that runs at boot time (e.g., old versions of LILO)
3 H2 N$ B  Q& b& ]0 y    2) booting and partitioning software from other OSs4 ^6 G9 f* J9 b: Z" z$ G& p
       (e.g., DOS FDISK, OS/2 FDISK)7 V. l4 B2 ~" |, W& l; P* l$ ?
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
9 S3 E# ?2 ]3 g7 Y7 f) P    Command (m for help): p% Y8 C+ v" k# h7 z1 @
    Disk /dev/hda: 4294 MB, 4294967296 bytes; ~& Z4 p7 \% E% Z& A
    16 heads, 63 sectors/track, 8322 cylinders
; W" L  L$ ^6 B3 y1 D    Units = cylinders of 1008 * 512 = 516096 bytes1 u# D8 I$ ~5 O* W
       Device Boot    Start       End    Blocks   Id  System
& F6 _$ W7 j; s" Y    Command (m for help): m
: T! s+ f( A" B: O9 `6 W; i    Command action$ ~9 z" O  ]4 g' ?! I7 r6 {8 i
       a   toggle a bootable flag
/ A- g; {1 z$ c# K; q       b   edit bsd disklabel
5 [* }2 j  [$ q3 s       c   toggle the dos compatibility flag
7 T% M! D/ u" ^       d   delete a partition
( u6 ?/ p* |1 t, s/ C       l   list known partition types
3 `' \# m. `2 y; m& n       m   print this menu" u5 y! q  d- s  R! ^
       n   add a new partition
! m* X/ x, Y# \9 J) P$ o! u       o   create a new empty DOS partition table9 {, S- C- p; k4 D0 s! Q" F! X
       p   print the partition table
/ B% u; s& n! R( Z       q   quit without saving changes+ j" \# G1 k% n$ @
       s   create a new empty Sun disklabel
9 ~2 ]6 G, u* a- B* h: f7 M, O7 L       t   change a partition's system id! ]5 z! Y# w* d# G! x3 _
       u   change display/entry units! W7 ]" e- _( W2 t, E6 y6 G4 x
       v   verify the partition table
& x/ D) t- T( R6 e- D7 K       w   write table to disk and exit
) R" o) E) j9 M/ V* L) V       x   extra functionality (experts only)
& }1 L7 Q! \. r    Command (m for help): n8 `( D5 G7 C: t" l
    Command action4 e& {& g# w6 Q" C* o
       e   extended
2 r! g. j4 [+ r. i       p   primary partition (1-4)5 a" D- b; b0 r) }
    p+ v2 L# E2 K. R5 |
    Partition number (1-4): 1
2 F0 Z0 C6 ~. c8 _1 R    First cylinder (1-8322, default 1): 3 c' `7 L  M3 c! K
    Using default value 18 l$ c: m6 _0 C1 S
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G, b* ?9 O, J& Y! o+ |1 X
    Command (m for help): p
1 T& Y9 s0 [% C3 U    Disk /dev/hda: 4294 MB, 4294967296 bytes
) M5 P0 y0 Y8 @6 U    16 heads, 63 sectors/track, 8322 cylinders
  N& q( n% j  W+ {# N5 v    Units = cylinders of 1008 * 512 = 516096 bytes
& b7 S" Q0 r, g       Device Boot    Start       End    Blocks   Id  System/ o8 `+ G4 I" y) _# B1 }3 A/ H
    /dev/hda1             1      1000    503968+  83  Linux: X$ r( s/ S. Q
    Command (m for help): w7 _' q3 U+ N, X' d6 v4 B" a
    The partition table has been altered!
. V" v1 h2 S; P& c9 L    Calling ioctl() to re-read partition table.
# ?2 H% a8 o, F# |3 A6 g    Syncing disks.' |2 Y8 \* u2 w3 C9 F
    //格式化新分区; q+ \$ N3 j2 |: x
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
7 W0 f2 Z. G8 }7 C; F    Filesystem label=
; {2 r. B. \# o    OS type: Linux2 h" \2 I. R# \
    Block size=1024 (log=0)
8 z+ w% u/ o# a, U    Fragment size=1024 (log=0)# _. F% Q7 f) U* k
    126480 inodes, 503968 blocks0 n# F0 t5 Q' M6 S+ A9 [& p3 ~
    25198 blocks (5.00%) reserved for the super user
# h# u4 |) q! d/ C    First data block=1' S; _5 g$ b8 j+ }' J
    62 block groups
9 W9 X/ }" n& b    8192 blocks per group, 8192 fragments per group
! e* T1 x, g& [; c    2040 inodes per group4 |& X: t% I1 f5 G1 M" e3 ?+ e
    Superblock backups stored on blocks: / U/ ]/ I& M* d, T( d7 {5 z- l
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
1 W2 h* Q9 I  G6 Q% }    Writing inode tables: done                            7 s) x( {0 z' d3 m! D: Q
    Creating journal (8192 blocks): done
3 o# @/ X5 P" z0 ?2 g    Writing superblocks and filesystem accounting information: done
! K! C8 ^9 N9 }- }2 a  t4 b- n6 d    This filesystem will be automatically checked every 30 mounts or
$ b! C; \1 l$ o) U( R3 d    180 days, whichever comes first.  Use tune2fs -c or -i to override.5 B0 T' v5 v# v3 {( n5 m+ w
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点( A$ G/ }( }; m" Z* k2 p
    /dev/sda3              3723848    705992   2828692  20% /6 r9 S- Q: L* U$ j$ k8 f
    /dev/sda1               101089      9274     86596  10% /boot, @+ \! S* q/ [0 S. t6 O5 [
    none                     14520         0     14520   0% /dev/shm
6 h( J9 z- H( z- F3 l    //挂上新分区
) x, x& n! w1 G* Q
  1. mount /dev/hda1 /home! g6 T1 k) T$ f
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
! o: S+ c2 x" O, W" e8 c2 I    /dev/sda3              3723848    705992   2828692  20% /+ k; I9 o: ]! |  Y
    /dev/sda1               101089      9274     86596  10% /boot* N+ Z" |% I9 r! s- {
    none                     14520         0     14520   0% /dev/shm2 d( R+ @1 c' Z  V0 O
    /dev/hda1               488006      8239    454569   2% /home
9 N( ^' c6 \7 W4 p- T% ?. M  _) r3 C
自动挂载:
- e1 H1 p/ Y& k6 h  a" H. h
  1.           vi /etc/fstab
    $ z, e7 ?; ]2 J. P
  2. : c7 ^7 a& I5 P8 d( l
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0' w* @* `6 V& ~, _1 D5 p- ?

  4. 7 W/ h# J8 b9 @8 C
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:$ p- ~0 w. `1 e3 N2 W- o2 S* P
  1.           mount /dev/sdb5 /mnt/ljp1
    # g% P3 H7 y+ G' a$ z
  2. # [, y9 l* Q) d( b
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
9 h* e2 q. V' C) ]7 g) `2 _. T- h5 c
  E. F: G& c9 W+ i
7 _* L' F( C" U
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-10 10:57 , Processed in 0.010807 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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