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

 找回密码
 立即注册
查看: 2762|回复: 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)
9 D  ~0 F) P9 o8 O' Z: B      or: fdisk /dev/sdc  (for the third SCSI disk)
% T- {/ K# X5 a- y/ A1 b) G      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)6 s+ s7 O3 S9 p! P% a
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
8 H( h, A0 W( v( q2 p      ...0 r" Z% w! _8 o3 Z: y. z* _
  1. df -k$ r8 p. @8 q$ v1 {) f3 c& r
  2. df -lh
    1 p9 ?# H1 Z8 B% ^0 V/ M, U
  3. 查看有几块硬盘:fdisk -l
    * N, Q! n4 N' q
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
0 h* O/ E0 z! s0 t/ r- e0 H- l    /dev/sda3              3723848    705968   2828716  20% /
9 i7 m+ I( C" B! ]# q" O    /dev/sda1               101089      9274     86596  10% /boot9 F- s+ C/ Y7 @7 S* ~& e/ Q
    none                     14520         0     14520   0% /dev/shm
2 |% Q- t' K" y    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
- w: U$ f) i$ h! z
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
# C  b" q9 F5 b8 A! l) @1 \4 `* d    Building a new DOS disklabel. Changes will remain in memory only,' x* Y- W# n7 K- Z) ?" L' f2 X5 L
    until you decide to write them. After that, of course, the previous( N; b* {. l+ I& P1 r7 T  d
    content won't be recoverable.8 t5 _2 ]% K$ o! G( T
    The number of cylinders for this disk is set to 8322.2 }" @, U& O8 k4 H
    There is nothing wrong with that, but this is larger than 1024,
3 E- B6 y5 B. |/ r+ I    and could in certain setups cause problems with:
  e; b: V+ Q2 y: ^. J, S    1) software that runs at boot time (e.g., old versions of LILO)
- O  X1 f* w. i2 y" p    2) booting and partitioning software from other OSs
) X* L* m  M" Z, I7 w       (e.g., DOS FDISK, OS/2 FDISK)
  j0 \& w0 N/ b    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
. t7 d: b: d7 N9 h5 I    Command (m for help): p9 W, V$ j7 i+ N. E
    Disk /dev/hda: 4294 MB, 4294967296 bytes
7 N$ @) A  o/ p/ s    16 heads, 63 sectors/track, 8322 cylinders9 o+ G7 B- t$ O) g+ @
    Units = cylinders of 1008 * 512 = 516096 bytes( ~+ O: P+ y. n- h# z$ f" {6 T; {
       Device Boot    Start       End    Blocks   Id  System4 B2 K0 j1 p; m; c! Y  U( o
    Command (m for help): m
; Z6 S" H6 Y- A1 o    Command action8 b+ s2 w7 v0 R
       a   toggle a bootable flag
7 V+ \; t4 f) N. j# _       b   edit bsd disklabel9 e7 `8 O  m: Y% H% I. R
       c   toggle the dos compatibility flag
# ~8 W. ]' s( @       d   delete a partition
7 g$ ~- u! K$ D# ~: q7 B       l   list known partition types
. E' r( t. Z7 C! d% Y4 j; @. L       m   print this menu
3 D3 _" w  K& r7 Z       n   add a new partition! r/ N0 E+ \; [
       o   create a new empty DOS partition table
9 ~* K2 v3 B+ z% Y4 o) W       p   print the partition table$ t. d- u7 c/ u0 X& [2 e- Y' u" m9 c
       q   quit without saving changes# l8 z5 A. e- i( i6 ?; ?
       s   create a new empty Sun disklabel
  F% a' Q+ I7 [2 X- l% T       t   change a partition's system id
" v5 S$ x+ C6 R% B$ K! q, w       u   change display/entry units
- w# B& R: S" A- e8 N. q! O% B       v   verify the partition table, @" O( q3 z. M! N
       w   write table to disk and exit! O# G+ v' a5 t8 u0 _( V
       x   extra functionality (experts only)
# }% l1 N/ E- s+ k& P3 G    Command (m for help): n+ H5 @: f; y; d. s& }3 E& r
    Command action
, y0 Q- i2 K- Y* K) K       e   extended
1 d0 o7 S& l& y+ W  |7 f       p   primary partition (1-4)
# x$ Z2 b: X8 Y5 i    p/ z# x5 Q7 b' b: }& Z, C
    Partition number (1-4): 1
* ^6 G* n" V3 k5 \# V8 ~# P6 l& j+ O    First cylinder (1-8322, default 1): : M0 I0 f4 x/ f$ v. J
    Using default value 1; p* a4 G& S" d$ S8 L' w
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G7 ^( k, @6 c7 L( b
    Command (m for help): p4 @4 j7 N& T! Q( V1 l" r1 F& s  J. i
    Disk /dev/hda: 4294 MB, 4294967296 bytes; b# z, W  |/ o0 z+ Q
    16 heads, 63 sectors/track, 8322 cylinders2 V5 h6 H& q2 d1 C$ P1 _' X
    Units = cylinders of 1008 * 512 = 516096 bytes
# w# o* j/ M0 b' h0 l( E       Device Boot    Start       End    Blocks   Id  System  r" B  g7 D' W8 `# X  T; I$ v5 c
    /dev/hda1             1      1000    503968+  83  Linux/ ]/ l2 [( e' i6 \
    Command (m for help): w
4 c3 ]8 V1 T" j) {: L0 c* g    The partition table has been altered!
2 m3 r1 O! T; t4 ?+ ?- o# P    Calling ioctl() to re-read partition table.9 T$ Y: i+ {% o
    Syncing disks.
' a! [4 \8 ~) h8 X; X- E7 v: K! a    //格式化新分区
6 P1 r2 h; [& \9 i- v/ a4 ^. F
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
# H8 n4 `4 _; N: W+ C    Filesystem label=& s7 W" y2 T6 @0 l7 `
    OS type: Linux7 U  g  X  B8 O; Q# C9 ^2 b8 J: ]
    Block size=1024 (log=0)
2 C/ K% X' |0 N3 M& r    Fragment size=1024 (log=0)! }$ Z  D& u3 O$ i5 Q
    126480 inodes, 503968 blocks9 G* |5 O8 Q) w- ]) v% Y4 B
    25198 blocks (5.00%) reserved for the super user
8 |: M4 W2 W8 q. A8 x: k/ y1 \    First data block=1$ |0 |8 a$ X' c, k' y( ?5 u0 ~
    62 block groups' k/ U  P, r# b2 K9 [( f2 m) d
    8192 blocks per group, 8192 fragments per group
7 j# a  ?# l. B    2040 inodes per group3 b6 o  m# y2 H! r$ p6 ]  u# @
    Superblock backups stored on blocks: ' n- I" d' F9 s& U$ P5 y8 G% C3 ^; g
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
  V- Z2 l4 e' h/ i* f+ @  W% q    Writing inode tables: done                           
/ w2 _: U% \0 h) Q! m    Creating journal (8192 blocks): done5 }, }3 t8 w: k  e3 [
    Writing superblocks and filesystem accounting information: done- m4 s  G) T. u( e% S+ y1 U
    This filesystem will be automatically checked every 30 mounts or* H9 Z3 w8 U3 C: G% N2 V
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
7 C; `& S. {/ \' p
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点* {8 ?) V  M3 E$ H5 V, c
    /dev/sda3              3723848    705992   2828692  20% /
) U+ k, i0 E$ A/ E% M, `. p* h: i; g    /dev/sda1               101089      9274     86596  10% /boot
/ h" Q: K9 g! |9 n    none                     14520         0     14520   0% /dev/shm
+ T+ n! X/ K$ z2 z0 c  O& {! L    //挂上新分区
' H2 K& r5 ~9 z! I8 A: t( D* P7 @3 L
  1. mount /dev/hda1 /home
    3 K9 H1 v/ D* a8 R# O' K: m# ?$ |
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
% d; A7 z. C/ S    /dev/sda3              3723848    705992   2828692  20% /
1 u! N% A3 |0 J    /dev/sda1               101089      9274     86596  10% /boot, j$ ?( _; d& u5 t7 S
    none                     14520         0     14520   0% /dev/shm" k. @- Z  x8 L) b: j: w2 Z% f3 C. S
    /dev/hda1               488006      8239    454569   2% /home+ Q1 Y( ]2 ^: ^* X9 ]9 `

  {# A/ d- O9 O/ ^" ?自动挂载:
, n; s7 j- z% H
  1.           vi /etc/fstab* r) Y/ K, C7 ^/ `6 x

  2. 8 i6 e3 \- P7 n
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    8 Z! s7 [% U& _7 D. }

  4. ( `4 f4 `# a/ `* u" l
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
  V# W9 |& e7 k  I" |  k/ E: B, b
  1.           mount /dev/sdb5 /mnt/ljp1
    9 J( _2 H8 n% f! F* z
  2. ( Q1 {2 e4 ^+ S0 h6 w
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

3 q; L2 J# m  o' e3 v! O1 u4 X
' E! d9 F! Y& {
* m2 m, g, @3 p" `& |
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-11 07:28 , Processed in 0.027950 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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