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

 找回密码
 立即注册
查看: 2702|回复: 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)
7 ?8 d0 e# s0 `. F2 O9 k  E      or: fdisk /dev/sdc  (for the third SCSI disk)$ g( |$ w& L. N* W# c! x
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
9 |3 r# v7 o% m; J/ Z6 [      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
/ @' E' h6 v( F2 ]      ...
) C) Q1 C9 b7 G/ \0 z
  1. df -k5 ~. I5 T+ }+ Q& O6 z1 F0 l! L& P2 i
  2. df -lh; l( p9 E5 {. s: x: C2 r" v# q1 Q
  3. 查看有几块硬盘:fdisk -l/ |# F+ Q' W! W$ ]7 N. T
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点6 k. y4 t% p1 J$ e2 f; F" f: }! H
    /dev/sda3              3723848    705968   2828716  20% /" b6 z) i2 E1 j. T
    /dev/sda1               101089      9274     86596  10% /boot
& D& w% C2 I( j+ B' j# J1 B3 E    none                     14520         0     14520   0% /dev/shm! A; H  V/ J0 \9 R& z% E2 y; ]! _
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
: e1 l! G7 C& a6 C& K, l
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel' S! x6 O1 D# [* N% a! K' i
    Building a new DOS disklabel. Changes will remain in memory only,
& V% D: I3 X' p! Q3 x    until you decide to write them. After that, of course, the previous
' ^, _7 K4 x% m& z- Y    content won't be recoverable.
( o" k& \8 A  O4 K1 ?% \    The number of cylinders for this disk is set to 8322.
! G# _+ H4 \- B+ D    There is nothing wrong with that, but this is larger than 1024,
# R" U! q9 d6 |2 `. |/ l4 ?0 C3 p3 U    and could in certain setups cause problems with:
( v/ j8 w/ ~6 U. ]8 a% i$ u) n% u    1) software that runs at boot time (e.g., old versions of LILO)
# s4 t) S+ _+ Y. D  k9 ^    2) booting and partitioning software from other OSs
3 c0 W  Q- W# a) u6 _, `, W       (e.g., DOS FDISK, OS/2 FDISK)8 x9 o5 [/ I* J3 p' E; {
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
8 k3 f! J" b0 o2 B  ^2 o% U8 \    Command (m for help): p
$ C4 n1 H' s. @/ j6 c    Disk /dev/hda: 4294 MB, 4294967296 bytes! t$ \6 B* I* ?
    16 heads, 63 sectors/track, 8322 cylinders% C; a' i; q( H1 U) T
    Units = cylinders of 1008 * 512 = 516096 bytes
5 R' D% v0 Z( f6 G0 a8 l8 ]       Device Boot    Start       End    Blocks   Id  System
0 p4 }( H; E! X* O% q( ]    Command (m for help): m
5 U5 O" ^$ s6 @    Command action. b7 q% _# N! f8 ?
       a   toggle a bootable flag% O5 u: N& i, K2 ^
       b   edit bsd disklabel2 L8 e# B0 P0 ?; |
       c   toggle the dos compatibility flag8 n5 ^% d  q9 ^" D2 n3 Q
       d   delete a partition
( N* `- c2 _& b5 B- \       l   list known partition types
6 a! d7 ^) u1 @, l- Y* v& ]       m   print this menu
4 G$ N! @, d: c       n   add a new partition
' `# r9 l( W9 Y2 D# Y$ y       o   create a new empty DOS partition table" \0 X" ]2 E* H
       p   print the partition table/ U+ ^, r# O9 f) i7 ^
       q   quit without saving changes
  K5 u7 |6 k' ^) r6 q4 J) u       s   create a new empty Sun disklabel5 V1 y- m) Z' n6 d1 F$ w
       t   change a partition's system id: x4 h2 J( ^# ~$ {4 n5 ]
       u   change display/entry units
% \) F; t: O7 k. h       v   verify the partition table
  l4 D8 d6 y0 t1 p* ]5 Y; m2 V       w   write table to disk and exit$ A/ ^% _. N5 @/ l9 y$ z. o
       x   extra functionality (experts only)& P0 m7 O5 L6 Q
    Command (m for help): n
+ ]4 B5 D& h! ]3 d1 v    Command action8 W$ j+ w9 X9 ]8 H, w; {, Z# D
       e   extended0 X4 c6 m$ B  T" A- l
       p   primary partition (1-4)5 i- f6 V+ @% F1 N
    p
4 g/ l' N7 g( ?' [    Partition number (1-4): 1
; w& C$ x& B' E: P6 C    First cylinder (1-8322, default 1):
7 t5 G7 x  @, M( t  E0 M3 _) y    Using default value 1+ G7 O1 i; M: `& ]8 z4 C
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G, j0 c9 z  Y1 ]8 F
    Command (m for help): p
) O0 B* r8 I* }0 G0 i" x    Disk /dev/hda: 4294 MB, 4294967296 bytes
/ N1 i' S- Z" z! i% }+ d2 Z    16 heads, 63 sectors/track, 8322 cylinders
5 S1 k6 f& k6 Z! T    Units = cylinders of 1008 * 512 = 516096 bytes
! I/ O5 N8 @$ P4 c       Device Boot    Start       End    Blocks   Id  System& I& }2 T. [/ l5 ^, {
    /dev/hda1             1      1000    503968+  83  Linux+ u. ]: M& I5 O
    Command (m for help): w
( m' R( ?) Q5 V: }    The partition table has been altered!
- J( J: l; G7 }7 x3 ^    Calling ioctl() to re-read partition table.- V6 R8 I6 T4 c7 g6 y0 D
    Syncing disks.
$ a# B% @0 |4 ^+ Q$ T" q    //格式化新分区
7 t3 F+ s$ R& D( z$ l
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002), o6 ?/ g7 A, f, H/ j) c5 n# V4 _
    Filesystem label=" d. l3 ]4 \0 l- z0 z
    OS type: Linux  i; R! H3 j9 a. u3 z
    Block size=1024 (log=0)
$ A6 Q( o6 y5 f0 i    Fragment size=1024 (log=0)% M8 z# K% W$ l: [
    126480 inodes, 503968 blocks
+ q" [: E9 O- L! M/ X    25198 blocks (5.00%) reserved for the super user
- x$ A2 u. `4 q7 s: _    First data block=1$ ~, v0 B0 {6 n0 \: q  N* I
    62 block groups2 `/ V. R" s1 J. m) p( M5 w
    8192 blocks per group, 8192 fragments per group
2 ^9 V6 h" g/ o. c2 ?    2040 inodes per group/ A( s9 S& w5 G3 F
    Superblock backups stored on blocks:
0 v( [# {+ j" \1 T" D' o# ~            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
' B  r0 z4 q, `, h0 a    Writing inode tables: done                            % @3 F/ n7 {' y# S4 r
    Creating journal (8192 blocks): done
& z, s  k" h8 p: R- t    Writing superblocks and filesystem accounting information: done
" ^' R* f1 s) a( Q2 T$ o    This filesystem will be automatically checked every 30 mounts or
5 @- s* l  b3 F* g    180 days, whichever comes first.  Use tune2fs -c or -i to override.
" X; Z( o! z0 m  H6 Q# S. m6 E+ }
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点4 c. `" ?* `8 n0 h
    /dev/sda3              3723848    705992   2828692  20% /' ~* g1 K! \7 t
    /dev/sda1               101089      9274     86596  10% /boot
/ |/ B) Y: E, U1 D% L5 X/ @$ \    none                     14520         0     14520   0% /dev/shm
. t" s! s4 O/ P; ^    //挂上新分区
- Y  x; L1 A# `* e5 a. M4 Z
  1. mount /dev/hda1 /home# ^, r! b2 M" O  {
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点" \4 V' O9 j: T
    /dev/sda3              3723848    705992   2828692  20% /" @- n4 t& g, f1 L: e1 o9 p
    /dev/sda1               101089      9274     86596  10% /boot
5 w' D' {  j% L; i' g    none                     14520         0     14520   0% /dev/shm
% s! W% |- b3 I/ S" _: P    /dev/hda1               488006      8239    454569   2% /home
) }! n3 J$ q& x' L
  t6 }2 `1 i! f自动挂载:, @. Q0 |5 l) G; S, f
  1.           vi /etc/fstab
    . p+ H5 Y- h" L- E

  2. 9 E0 M( f8 |& O
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    ' g" l! f  c7 B' }+ P/ g  H
  4. ' y& C8 z, U5 B; f) V/ K3 G1 N
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
2 Z$ q# P% |" Z+ f$ ?6 u6 @2 v
  1.           mount /dev/sdb5 /mnt/ljp1: \, C$ r1 V$ A' O1 j# c6 O2 ]" ^( t. H
  2. % R! e3 h. z/ x8 [- R5 p. ]& L
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

2 s, X3 J! g& n; ^2 B0 N0 x* X: U+ a* _
. V7 U2 O) c& t, E! |+ v
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-21 14:21 , Processed in 0.007004 second(s), 10 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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