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

 找回密码
 立即注册
查看: 2672|回复: 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)
8 L0 Y' N9 D& q      or: fdisk /dev/sdc  (for the third SCSI disk)) X1 b. H' y1 c. v7 E1 q
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)$ \: u8 c' I. ?, H4 _2 n6 _0 ?
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
/ Q4 P: G  X. V: s* n      ...+ v) \$ I: [+ H4 x' ^0 z4 _  B* D* B
  1. df -k' D* |, H) |$ o/ h3 D- O9 t
  2. df -lh. u* Y1 H, ^; V6 X( {# n7 `; Q
  3. 查看有几块硬盘:fdisk -l* X" ~7 b- q* ?+ s+ Q; ]
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点- W# B, Y. X8 `" @  T
    /dev/sda3              3723848    705968   2828716  20% /( ~) R5 `/ M7 [3 i! r5 I9 H7 M' h0 G. o
    /dev/sda1               101089      9274     86596  10% /boot' [  y' I% ]4 C9 V1 r1 X! F0 {
    none                     14520         0     14520   0% /dev/shm0 h0 p+ r7 N; p
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
( Z6 @6 w2 V+ c  e5 x2 w8 O
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
. ?- R9 E: Q: y9 @' [    Building a new DOS disklabel. Changes will remain in memory only,
5 ~5 j1 f2 v+ I( Y: d9 Q) |    until you decide to write them. After that, of course, the previous
+ y" c( V0 g; m) w2 J4 d    content won't be recoverable.
0 `  f# C& z! E/ m2 }1 ?5 n! {    The number of cylinders for this disk is set to 8322.
) w- b; e  I! ~0 ?" E4 Y    There is nothing wrong with that, but this is larger than 1024,& L. c1 U' k& E  [5 J" E
    and could in certain setups cause problems with:6 f! g1 }) F+ X2 i' L
    1) software that runs at boot time (e.g., old versions of LILO)
( o; O9 A9 B, t$ F' ~    2) booting and partitioning software from other OSs
  N+ ~# b8 m! e9 U5 j6 w       (e.g., DOS FDISK, OS/2 FDISK)
# D* b0 q6 h- x! c) H    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)# z7 V8 p3 Z/ {
    Command (m for help): p3 ^; G- z" u) O3 c4 T! {8 [
    Disk /dev/hda: 4294 MB, 4294967296 bytes' h- G, b0 C/ Z
    16 heads, 63 sectors/track, 8322 cylinders+ |" T/ l! L3 E1 S5 h
    Units = cylinders of 1008 * 512 = 516096 bytes, l4 `/ `' @1 M$ x9 }
       Device Boot    Start       End    Blocks   Id  System
6 T  E: J4 {+ w/ p2 n( L$ `7 g    Command (m for help): m
/ ^, B/ m6 T' W0 h- y  J( H    Command action  w" ?- n$ z) i- n6 [
       a   toggle a bootable flag! l% \' ~6 t3 w' I2 E
       b   edit bsd disklabel) E! ~' c8 K$ F7 _  l- T) _
       c   toggle the dos compatibility flag* o1 T, s4 r, C% ^$ j* w5 t/ y) N
       d   delete a partition8 @9 C9 Z7 S$ y
       l   list known partition types) _/ x- E; j, w. s" @
       m   print this menu: O" N% }+ j/ i' X5 ^- S
       n   add a new partition) }' ^4 f: e0 a5 ^- H
       o   create a new empty DOS partition table
- V' o/ R6 ?8 c       p   print the partition table! k/ h8 P1 M! a1 ]& {3 _0 P  G- @
       q   quit without saving changes$ j/ K: a, B; _! [1 R9 Z* ?. h
       s   create a new empty Sun disklabel
, K8 L6 S' _" W       t   change a partition's system id( R0 F" o4 V% F& `
       u   change display/entry units
: q" V4 f% T6 ]4 p4 ~- K# b* A       v   verify the partition table9 Y5 Z& R( W2 k( S5 y4 ]- s1 y
       w   write table to disk and exit
( H5 b2 j) Z" W       x   extra functionality (experts only)
) n! [9 I7 P7 q: Y4 k1 ^% K    Command (m for help): n
' u6 B4 j" D! v5 b    Command action4 V( u3 S$ E( c
       e   extended
+ R8 Z9 ~' ~' Q/ H8 w- m       p   primary partition (1-4)
  W5 B; Z+ _& E* e3 f3 ?+ [    p! i( T) E- i3 S
    Partition number (1-4): 1
1 @. i2 [  F' q- O1 |    First cylinder (1-8322, default 1): ' T+ M" d  ]: z/ ~; U( w
    Using default value 1; _2 K: w+ @/ @" g6 N' R0 z, x7 d
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
% ]. T% z7 M: ?* M- Y    Command (m for help): p
9 D; E4 a+ A/ g6 {    Disk /dev/hda: 4294 MB, 4294967296 bytes
6 c$ {3 N8 F5 A! e6 n    16 heads, 63 sectors/track, 8322 cylinders5 a  Q7 g" ?" [* i1 j6 W. q
    Units = cylinders of 1008 * 512 = 516096 bytes' Z. {8 G) l* o* t$ P. L: {% _4 B
       Device Boot    Start       End    Blocks   Id  System- d/ O. K) u: A' h7 r( _
    /dev/hda1             1      1000    503968+  83  Linux
( k; V* f- Y) f4 d4 Z6 ]$ O7 j# u# ~; ?    Command (m for help): w
4 Y/ Y9 B* `) |4 s7 R2 t( f    The partition table has been altered!, O" \) h. h. ?7 E6 ?6 K
    Calling ioctl() to re-read partition table.
0 Q8 x4 S8 @) u    Syncing disks.' H7 k+ B/ z& d7 s0 Y4 W* V, Q# @
    //格式化新分区
  {- U7 D$ r: j  l  l0 x
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002): _7 o0 Z  k& j4 }2 V
    Filesystem label=
5 P& F1 K4 J' u- O+ @    OS type: Linux' D9 e* G2 K8 A$ K: F
    Block size=1024 (log=0)8 h7 D/ U# g+ l7 e7 j' u  Q
    Fragment size=1024 (log=0)
4 L* c* g0 B$ ^9 k' U    126480 inodes, 503968 blocks
1 u( V, M8 e# ?; J+ Y6 ~    25198 blocks (5.00%) reserved for the super user
0 B3 e' g; y. O& d" ~6 j( a+ j9 p    First data block=1+ x6 G4 W0 E' B$ Q
    62 block groups1 h4 m6 i( O  ?
    8192 blocks per group, 8192 fragments per group( f4 V( L( z8 r; U, _9 o
    2040 inodes per group3 N% s! \$ j/ |+ b2 K
    Superblock backups stored on blocks: & K  |& a6 Y- ~+ E+ E
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409( I! p$ ~5 A9 a6 v5 \# K- C
    Writing inode tables: done                           
1 Q7 e4 ^7 \. b; u' k! W$ s- l    Creating journal (8192 blocks): done
; S; {2 F* Q7 ~. U    Writing superblocks and filesystem accounting information: done; L! q& ^. |; J9 H% A
    This filesystem will be automatically checked every 30 mounts or
. _; T; ~; G9 v) R: T    180 days, whichever comes first.  Use tune2fs -c or -i to override.8 `7 s8 R. L' _- b9 y
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
# M2 S, b) Q# n+ f; y6 Q6 v. I; P    /dev/sda3              3723848    705992   2828692  20% /
5 g9 J1 A! J0 `5 M5 g: J    /dev/sda1               101089      9274     86596  10% /boot
/ `; u2 y7 O3 y7 p9 P' h" M    none                     14520         0     14520   0% /dev/shm& |9 ]# v+ q# o
    //挂上新分区
8 o( }4 c2 S+ r: j& F2 D; s; _" e
  1. mount /dev/hda1 /home6 C9 e" B/ P6 \4 o  y
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
" \- z2 G5 `- _- B9 K0 W    /dev/sda3              3723848    705992   2828692  20% /; ]* i9 E) d0 q8 N
    /dev/sda1               101089      9274     86596  10% /boot
! d" ]& m" \+ E: Z, r2 m    none                     14520         0     14520   0% /dev/shm! R4 p* I7 d4 V" f; S6 m
    /dev/hda1               488006      8239    454569   2% /home! z0 G8 X* T6 S  P% O- h' i1 f7 S: p
7 L7 s1 p4 T# N1 e8 g. [
自动挂载:, D6 u3 {# Z  K
  1.           vi /etc/fstab/ l2 \( H$ y+ ]
  2. # c% Y1 E* f1 A. V- G, M5 p) |6 {
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 06 M" K; }1 A6 F0 q0 Z/ j

  4. & d% `  F9 L4 |7 V+ x
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:; v3 S1 h. F+ O9 Q& f* X7 G. ]1 @
  1.           mount /dev/sdb5 /mnt/ljp1! @$ q% U9 q0 q( K1 H- Q, L+ F( z
  2. ) {- Y  g5 p; U6 b* z4 o; y# s! a
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

$ R+ i8 x. }5 X2 t: y, L5 n' X8 S, ]) \9 F. \

$ P2 Y/ X# w( Q9 m, E) w9 E+ X
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-11 22:31 , Processed in 0.015739 second(s), 6 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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