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

 找回密码
 立即注册
查看: 3277|回复: 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)" C4 Y* e0 {# Q3 d& Y* b- z" i
      or: fdisk /dev/sdc  (for the third SCSI disk)( \8 \4 x- u$ f( d1 ?
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)9 p- `( z' ]9 i+ ?: v+ ~: X
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
" l' ^& s8 o/ h( M      ..." w6 P; d. F" p$ p' Q0 v
  1. df -k  T! E' Y7 n# g9 w) y
  2. df -lh
    . N) N2 O3 Z4 j  x( \1 c
  3. 查看有几块硬盘:fdisk -l0 w" o6 D  Q0 T9 a* w* q3 f
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点7 D: S7 X: ]) t
    /dev/sda3              3723848    705968   2828716  20% /
& g5 |/ o  a; ]" S7 S  t" n2 M6 W    /dev/sda1               101089      9274     86596  10% /boot
" v9 h7 K3 Q3 }    none                     14520         0     14520   0% /dev/shm( t; B( J/ _* e2 I( g
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
7 e8 z& u/ f2 P
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel& T/ f- |6 U* b/ V' H
    Building a new DOS disklabel. Changes will remain in memory only,9 r' U, h- |2 d( R- r
    until you decide to write them. After that, of course, the previous
) L% L6 u3 r0 C8 e( _/ [- T    content won't be recoverable.
+ S2 H, a! E. V5 q. \/ z    The number of cylinders for this disk is set to 8322.
2 v  \; F0 x# W' |2 S& `: C  G    There is nothing wrong with that, but this is larger than 1024,& i5 j1 Z* f' y0 J& u3 M# S" T6 j5 C
    and could in certain setups cause problems with:$ Z8 {5 c5 C3 @7 n6 ]
    1) software that runs at boot time (e.g., old versions of LILO)6 t# `0 j( \' S' ?4 p8 I
    2) booting and partitioning software from other OSs
7 t' k& _7 j% L) L7 _! z" b       (e.g., DOS FDISK, OS/2 FDISK)
9 [. P  g, }' i! c    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
0 i) S$ z, c) c; f5 x5 M    Command (m for help): p
: o9 v" `8 x) G5 o% Z    Disk /dev/hda: 4294 MB, 4294967296 bytes
6 Y- j9 M' f5 k8 R    16 heads, 63 sectors/track, 8322 cylinders+ X% K# }4 B! D1 _
    Units = cylinders of 1008 * 512 = 516096 bytes
: z/ c% b5 r  g- \7 j; s4 f       Device Boot    Start       End    Blocks   Id  System
, `$ G* E7 D& i4 _& y    Command (m for help): m0 ^4 M2 A6 w8 y
    Command action
! ^; f5 E  l; D1 G       a   toggle a bootable flag! a; N0 o# L$ G% J8 ~7 J
       b   edit bsd disklabel
9 P" I: H6 X  \$ N$ @0 x; a       c   toggle the dos compatibility flag
/ t. p- k8 N, _$ V- X9 |) n       d   delete a partition  V) Y6 m( `4 H3 U% G* I" c0 \/ M3 l
       l   list known partition types
9 B) N3 t# W6 |, h5 c       m   print this menu% ?3 _% t1 `6 a
       n   add a new partition
: z; a5 P/ [4 Z4 ?# d* m       o   create a new empty DOS partition table2 Q; l- W) M. K
       p   print the partition table
, e, _: [6 m" D0 S5 ]* v5 g       q   quit without saving changes/ P! ~2 R% `5 Q1 b. O7 t0 p) O# F
       s   create a new empty Sun disklabel
9 b& P2 h( s, a8 \) c& Y; k       t   change a partition's system id# g" O- m6 q2 k! j
       u   change display/entry units
$ i$ D5 b5 F0 n$ Q) |       v   verify the partition table
/ I, E2 i# r+ Q6 Z+ H       w   write table to disk and exit; X: t8 c: C. L8 Q" T' d
       x   extra functionality (experts only)
9 Z% n/ e8 Y. \6 [    Command (m for help): n
) K; z! c# Z  H( R% V    Command action; r/ f7 \. q& R( \) f
       e   extended
7 Y7 _: A9 r$ r( i; h       p   primary partition (1-4)
7 n0 C, @; F9 }0 V4 W# |* p/ v    p
; ?" \. F  H8 s: F    Partition number (1-4): 1
( C% u5 ]1 a, h9 f( l' b0 t    First cylinder (1-8322, default 1):
7 Q) o$ T- f8 D1 q' X' A    Using default value 1
, L9 }( T+ [/ A" T+ L* r    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G( q$ }4 e  r* r2 ?/ {1 u7 ]7 X
    Command (m for help): p+ E4 @: u2 R1 P6 t9 z
    Disk /dev/hda: 4294 MB, 4294967296 bytes9 a% Z3 h$ G+ d4 C
    16 heads, 63 sectors/track, 8322 cylinders3 g2 a2 y! f% T0 Y: U1 y
    Units = cylinders of 1008 * 512 = 516096 bytes* w7 p1 _4 J) ~1 \4 c* l& p' T$ c/ c+ ~
       Device Boot    Start       End    Blocks   Id  System7 F3 Z  j& R4 E" m
    /dev/hda1             1      1000    503968+  83  Linux2 t5 K( V  S) A1 _% f7 L
    Command (m for help): w& N; Q( _+ Z8 y
    The partition table has been altered!) r- r. h5 K4 d9 H" k, S$ o
    Calling ioctl() to re-read partition table.
' m, J6 Q  X( W3 ]! E2 [2 |    Syncing disks.
' P  G7 b$ z8 P, H. F$ @    //格式化新分区/ C" f4 R2 U, X/ Q% H5 N
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)2 o) n% w( V6 H6 z- V0 F5 q! |- r
    Filesystem label=4 ?. S6 {* Z3 ^" h
    OS type: Linux) G- H4 ?% K; `
    Block size=1024 (log=0)
( ]6 G1 U; z, k% |/ _    Fragment size=1024 (log=0)
/ ]( F  j5 J% G! @! w4 g    126480 inodes, 503968 blocks" d0 `+ {9 n  U0 f
    25198 blocks (5.00%) reserved for the super user
& B: N$ N: Y: p  h( j    First data block=1
* ~6 l& E8 b3 |3 G9 Z. ~( E5 X    62 block groups- i9 Y8 \2 H) f; g
    8192 blocks per group, 8192 fragments per group4 f5 _6 R: P3 i
    2040 inodes per group
" M8 b6 x( w; A. P% @    Superblock backups stored on blocks: 8 m$ X8 f5 Q) j
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
0 x1 f2 K* p6 [4 h+ b& [    Writing inode tables: done                           
6 q. I6 ^; Y0 |) O7 `    Creating journal (8192 blocks): done" ^+ P9 v1 S) n3 m; B# y
    Writing superblocks and filesystem accounting information: done
+ ^6 s9 [; v0 R4 z    This filesystem will be automatically checked every 30 mounts or
; k. g% A9 f& ]# B& n7 |    180 days, whichever comes first.  Use tune2fs -c or -i to override., {/ f9 H7 G2 S1 s
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
# |  k9 u  C6 x- v    /dev/sda3              3723848    705992   2828692  20% /
2 N- T4 E  d# O1 Q* C4 w- _    /dev/sda1               101089      9274     86596  10% /boot# Z+ i/ \5 \1 S2 w2 q7 H
    none                     14520         0     14520   0% /dev/shm6 L8 ]: J3 O2 {4 T$ Q
    //挂上新分区% e2 m) ^( M+ I) k
  1. mount /dev/hda1 /home; ?" e; X% u* ^  a+ n
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点1 Z: |! S2 Z3 |% J3 h5 J
    /dev/sda3              3723848    705992   2828692  20% /$ L7 \9 j! M! \( P8 P# m
    /dev/sda1               101089      9274     86596  10% /boot: w. g0 H" d! o: V4 Q$ R# i) c
    none                     14520         0     14520   0% /dev/shm
9 q) K# x; b  b* Y& S; S/ `    /dev/hda1               488006      8239    454569   2% /home
9 O; _" c) c7 `/ W! a
* ~$ [! W9 l8 z" E& i自动挂载:, p9 Y. X1 c; [& K
  1.           vi /etc/fstab
    , g- H2 p( h" a1 R! W
  2. " r) N; a) Z" B
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    ) z3 H% i, i: ~/ S/ J0 m

  4. ( k8 o( L- \9 }3 ?8 l
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:# ~) S; K) E4 Z# _5 _
  1.           mount /dev/sdb5 /mnt/ljp1  k6 @. {; j- W/ D& E) w

  2. - h, u; t+ }  A* g- [6 k
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
3 g1 p: x, }( g$ r; {' N% q

8 s( {+ S5 D0 [7 m( H) {; U. M6 s$ \8 X* w! |/ q
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-9-4 17:36 , Processed in 0.027004 second(s), 6 queries , Redis On.

Powered by Discuz!

© 2010-2023.

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