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

 找回密码
 立即注册
查看: 2797|回复: 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)
' l/ W( Q9 b4 U& `      or: fdisk /dev/sdc  (for the third SCSI disk)1 U, Q5 i5 }9 T' o* h
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)  n# W9 l, K3 t, E* L# Y- g7 C3 \. Z
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
  W, y- O8 h- y, M+ U- ]      ...
2 ~/ F2 {, m, j  q
  1. df -k
    7 l0 ?/ @* f* G$ j" e
  2. df -lh
      Q2 {% z4 e& a; t% }' O, m, z6 u
  3. 查看有几块硬盘:fdisk -l
    ) D: u# h# Q% P1 r8 R+ Y/ b
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点2 u, T* s) _) h8 S( H% K# b( N
    /dev/sda3              3723848    705968   2828716  20% /; ?: ]+ A& q4 T; O' J6 i! W: a
    /dev/sda1               101089      9274     86596  10% /boot3 A4 u1 }' @" @9 L
    none                     14520         0     14520   0% /dev/shm" C& S* C) a" e
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用  `0 {8 O4 @2 X# K4 [" c
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
+ Y- d" K& S' m9 i" ]2 R    Building a new DOS disklabel. Changes will remain in memory only,9 l7 `" a( e) l0 u
    until you decide to write them. After that, of course, the previous4 ~; |" P8 O* c
    content won't be recoverable.
1 D: o( F  `& X2 x- t9 C, q' ~/ ]    The number of cylinders for this disk is set to 8322., K3 `7 ]1 L: W1 U4 H- o3 j1 {7 l
    There is nothing wrong with that, but this is larger than 1024,
3 z/ t; u4 k+ c/ J. p& s    and could in certain setups cause problems with:; |2 c# S5 X1 s5 x' P( A) H. k+ s
    1) software that runs at boot time (e.g., old versions of LILO)
8 i3 }; @5 K4 r- v    2) booting and partitioning software from other OSs/ }8 p% Z( k! j9 x
       (e.g., DOS FDISK, OS/2 FDISK)% R$ r8 p2 u% w$ f/ @- S1 [" k
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)) }. L8 {1 f& h1 n
    Command (m for help): p9 G# U3 k7 M2 ]9 j) u$ f: e
    Disk /dev/hda: 4294 MB, 4294967296 bytes
; \9 P* B1 c4 N    16 heads, 63 sectors/track, 8322 cylinders
. l, U+ V+ H, p+ k1 r- y  T7 h' A    Units = cylinders of 1008 * 512 = 516096 bytes1 [% y, s7 [- ]( `
       Device Boot    Start       End    Blocks   Id  System
( l6 r2 A# t6 H& M  W6 V' N4 v    Command (m for help): m* @- X, i# A& B8 B7 U2 o2 x( t- k
    Command action
. I' g4 ?6 K/ b: {6 a       a   toggle a bootable flag
4 N- ~' w( X' X  v  u( P- k       b   edit bsd disklabel
) X: B% t; @2 g& H7 W       c   toggle the dos compatibility flag
7 m8 E7 E- J4 g& U! s" q6 I       d   delete a partition+ J1 c$ i  H% N/ V) S
       l   list known partition types, b% p0 X. v: S1 ^  B0 s
       m   print this menu* S& g3 Q' E% n7 v. X
       n   add a new partition
: ]) S8 S+ C+ ^, V7 I7 n  z       o   create a new empty DOS partition table0 w2 o1 s0 S' M* v$ k( W7 C
       p   print the partition table
# G) O; T# {9 b+ |/ C! }& \       q   quit without saving changes5 N8 j3 _1 E- H2 f
       s   create a new empty Sun disklabel
  m$ X0 d  c- v' B2 m0 \; J       t   change a partition's system id
# ~/ R7 _5 X1 J* T$ x       u   change display/entry units: d3 W, j6 N; K4 \$ f: p$ Y! n
       v   verify the partition table
3 @: h* m, \7 Z* [) F& l7 j# `0 {       w   write table to disk and exit
" F1 M' l% n0 H( o: @1 K2 p       x   extra functionality (experts only)
7 |. U6 b' ]  H+ [; s3 L    Command (m for help): n
& U6 E$ S" @8 o1 N    Command action  A2 \" P4 H1 R9 n! r/ \7 a8 L/ W. M
       e   extended
0 f! k0 P5 ^1 e" I3 O# X       p   primary partition (1-4)) ?$ w, ~0 j+ F" {- ?
    p- Y1 _  N: S) d! l
    Partition number (1-4): 1
8 |3 |1 H! h% v    First cylinder (1-8322, default 1):
8 G# Y5 T( ~# G( N9 E: Z    Using default value 12 Q" y/ O9 ^! a& V- W) }
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
3 ]/ ~" ?0 u1 L% ?5 m" u! Y& s# t    Command (m for help): p' j0 q2 A+ F2 w# {6 U1 R  w
    Disk /dev/hda: 4294 MB, 4294967296 bytes. ]- a/ f4 ]: n
    16 heads, 63 sectors/track, 8322 cylinders% F* S/ _' M9 Z' D
    Units = cylinders of 1008 * 512 = 516096 bytes
! b% H) e' w) U: o7 F# u) T       Device Boot    Start       End    Blocks   Id  System- S1 K0 ]. Y3 w- q6 j/ q% |
    /dev/hda1             1      1000    503968+  83  Linux! X) l; n- p2 s
    Command (m for help): w% g0 u5 ?# A! g
    The partition table has been altered!/ q0 g; r6 r# w( k, C% @! [
    Calling ioctl() to re-read partition table.
# z" B/ V) V+ ^5 x    Syncing disks.3 N/ Q) p- F' U- @  D- V9 Z
    //格式化新分区7 H" q7 y+ b, F* w( l; N
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)# o7 z5 s( w6 j5 X. z, D2 m
    Filesystem label=, g  V- E2 \3 o2 M. H3 q
    OS type: Linux/ m! a7 C" @( M# V" n5 x
    Block size=1024 (log=0)) K& G6 ^) O9 @9 O: E2 z  n
    Fragment size=1024 (log=0)
# n! \( b9 C# R5 {- @    126480 inodes, 503968 blocks
2 C2 |- d& r7 @7 G% H/ a    25198 blocks (5.00%) reserved for the super user
: g* e  Y: G& M$ S2 B    First data block=1
* ?+ R* m( u1 x% M! q    62 block groups
4 M4 U1 C6 d& L+ \$ S2 c) P. m    8192 blocks per group, 8192 fragments per group
' E. w  }& Y# r) c    2040 inodes per group6 ~- I+ }/ Y: v) j( o7 |
    Superblock backups stored on blocks: , P4 x2 K9 b. m! [+ _* l4 O
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
! s% m0 C! F& N    Writing inode tables: done                           
& ?! y4 ]7 H$ G& u1 e    Creating journal (8192 blocks): done1 m# P4 y8 y3 `
    Writing superblocks and filesystem accounting information: done+ @) v7 O( w2 z$ [( Y' ]. v& l8 Q
    This filesystem will be automatically checked every 30 mounts or$ p: j" I- O5 e0 {7 i( M5 L/ `
    180 days, whichever comes first.  Use tune2fs -c or -i to override./ `5 W2 A0 F( W# C6 _# E0 {! X
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
9 x4 E8 T6 r3 f- g    /dev/sda3              3723848    705992   2828692  20% /
6 U7 D1 a6 _* G2 D    /dev/sda1               101089      9274     86596  10% /boot3 l$ A# a2 u- M0 k* f# l
    none                     14520         0     14520   0% /dev/shm
; @  K; {+ }. m. S- R$ R    //挂上新分区4 b6 Z6 F7 a0 B8 O0 K+ }/ t
  1. mount /dev/hda1 /home
    - K# V/ S9 ~( Q3 W0 b  n
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点! X& @% R  x- d0 O' p
    /dev/sda3              3723848    705992   2828692  20% /
. h3 Z, ?; K  [! t! w9 `+ k: y    /dev/sda1               101089      9274     86596  10% /boot
  h. ]  b! B0 q0 m+ |; D) x    none                     14520         0     14520   0% /dev/shm/ f' P- |- }1 @  ?. w
    /dev/hda1               488006      8239    454569   2% /home: T' T; ^. q( O$ ?  \, i

4 N6 c+ B' @+ b* Z! G2 l* g自动挂载:( s7 Z  P7 v/ n& T/ X
  1.           vi /etc/fstab
    * v3 ^0 y- W3 c. X( v& Z. K9 |

  2. / t# ]9 O. H- W5 L: h
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    4 C  f2 Q# _9 x4 O0 Y

  4. 6 p) Q. K  D8 J
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:9 c! [  q; H6 ^1 n% |
  1.           mount /dev/sdb5 /mnt/ljp1
    ) k& S0 k7 Z  N+ w
  2. * L+ T! m% t1 d6 |# a+ g+ u
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
4 [" L! q: }1 |% D) k7 e

) o6 `: R" Z- f# u1 K0 b! N  s5 y& Z4 [. w$ s$ g) r. l$ k
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-17 04:19 , Processed in 0.010740 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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