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

 找回密码
 立即注册
查看: 2598|回复: 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)) {) R$ E1 M+ i( c- ?! v
      or: fdisk /dev/sdc  (for the third SCSI disk)
6 J3 ^- F* @6 W) W  F: }      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)4 y+ v& l/ F- W2 I7 t
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)  M% A0 I' h0 L: i
      ...
! g+ _) h( ~* Q6 b5 L' ?
  1. df -k/ k8 l# N( e) Q) n6 p7 z  Y3 o
  2. df -lh
    1 P( L2 J/ w7 Z+ L7 X) g3 a* f: D
  3. 查看有几块硬盘:fdisk -l
    / j! |  x5 `5 }# }+ j' e6 i& x
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点" q! H9 |+ m. F0 Z
    /dev/sda3              3723848    705968   2828716  20% /
$ h' e# [7 g4 \; J3 R9 ?    /dev/sda1               101089      9274     86596  10% /boot
! k6 n; i8 Q, A4 `- l6 k9 }    none                     14520         0     14520   0% /dev/shm7 m8 r: T4 F- p! f6 S: c( C
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用; S. N5 l- U  E* ?0 D" g. [( D% Z
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
1 D7 p- r  k2 ~% h6 J  V    Building a new DOS disklabel. Changes will remain in memory only,
+ C  O" a! g4 b% j) _    until you decide to write them. After that, of course, the previous
9 `3 S3 V3 j1 I, |1 h+ f. Z    content won't be recoverable.( z/ N8 w" W2 h
    The number of cylinders for this disk is set to 8322.
. A9 p& S$ A: R9 c6 h    There is nothing wrong with that, but this is larger than 1024,
7 ?5 z7 N2 @, W0 M/ z    and could in certain setups cause problems with:
% ?9 w3 g; w$ l; p5 w3 X    1) software that runs at boot time (e.g., old versions of LILO)
/ O" d/ F- I. n0 W  n    2) booting and partitioning software from other OSs- A% D! j, F+ F5 q' t" j5 C5 M
       (e.g., DOS FDISK, OS/2 FDISK)9 p  e$ b  `1 H+ ]6 u7 N: O- P8 c3 ^
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
; j: N  _; w( h    Command (m for help): p6 L5 @& o5 ]% N
    Disk /dev/hda: 4294 MB, 4294967296 bytes
" M- ?( A4 N# Y# K! ?6 h3 ?    16 heads, 63 sectors/track, 8322 cylinders' @8 j# ~  x9 X5 @4 P4 P9 b0 C
    Units = cylinders of 1008 * 512 = 516096 bytes
& d+ M7 r, W6 Y3 y, s# D* {       Device Boot    Start       End    Blocks   Id  System: W8 ?. `6 o5 t% Z
    Command (m for help): m0 J5 N2 N+ B2 O, ~# z; r4 J
    Command action
7 v4 h8 K, P# a. a' z, S0 R       a   toggle a bootable flag
+ H: Y8 j0 w: C) t" A       b   edit bsd disklabel
3 d: x1 ^$ I$ f: {7 Z9 w       c   toggle the dos compatibility flag
: w, S2 H; v! K% R! e       d   delete a partition
. ^2 u1 i! ]; X       l   list known partition types3 t  j8 L4 Z! m8 Z. E& Q! M9 G
       m   print this menu
/ Q/ T6 O+ o( h! I/ ?& ~: x1 B       n   add a new partition
7 C! v$ t; P* k6 {( A: d# }6 B       o   create a new empty DOS partition table
- K7 R+ t& P4 o; c: N       p   print the partition table; N' \( ~8 ?5 C2 }( Q& Q
       q   quit without saving changes
0 }) y( a$ I( X2 @& z( v9 }       s   create a new empty Sun disklabel
  v0 s/ N5 Y, i8 ?       t   change a partition's system id1 h. a' z/ [% v/ T$ ]
       u   change display/entry units+ w. r' W9 E# B+ X5 V0 Y0 Q
       v   verify the partition table5 ]# N, d+ m! B. L6 z) M
       w   write table to disk and exit8 r5 A/ ]  L% ]7 S# M/ E
       x   extra functionality (experts only)
& b5 ^: u0 U6 v& W0 w( J1 ~0 V    Command (m for help): n( B# I; Z- [+ h: _4 G3 R
    Command action
/ }5 D$ k# d5 ~       e   extended
! [( ~" l+ ]6 N2 {4 E+ ]       p   primary partition (1-4)1 g! Q# ]* b# Q: v) O
    p
- ?2 o7 i/ k* |0 C# z- U    Partition number (1-4): 17 R: p  O4 l! @3 e( ]! p
    First cylinder (1-8322, default 1):
: w1 M3 I' Y; M6 F    Using default value 1; f; a: l! o2 s9 f
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
3 P+ E0 |1 m, W2 F    Command (m for help): p  s( n1 S6 ~: _1 k) c
    Disk /dev/hda: 4294 MB, 4294967296 bytes; H9 ~; F+ B9 {7 A" n* `) c
    16 heads, 63 sectors/track, 8322 cylinders
/ r4 a% m) h- w4 F( l+ f    Units = cylinders of 1008 * 512 = 516096 bytes
% @; x# e' }# f$ C8 p' H       Device Boot    Start       End    Blocks   Id  System
  n7 X  ^$ m  F% R) ?    /dev/hda1             1      1000    503968+  83  Linux
/ A9 S! }  o$ N* k5 z    Command (m for help): w
5 v. i+ e" @- ^3 k( w; |    The partition table has been altered!
; U- l* @2 `- @$ k) M; ]/ |# Y( }    Calling ioctl() to re-read partition table.' W$ J1 n8 U: d+ L% c# x
    Syncing disks.6 @. B( P- J" v* x5 B
    //格式化新分区
0 o1 f, t' t! e4 G
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)7 K; e( ?- K0 t1 I7 `5 ?) E
    Filesystem label=
) ~8 f# ^8 N+ ^. o) r- N& A    OS type: Linux
- Y; l% q7 n& n$ x" W! G    Block size=1024 (log=0)
  V' o% y1 p( v% X# x/ o# w" J    Fragment size=1024 (log=0)
/ Y% c: L5 ^' `( q    126480 inodes, 503968 blocks, W& t# `; l1 N' g' U& S# ]% }
    25198 blocks (5.00%) reserved for the super user
! }5 \  T/ Q! Y6 J) V    First data block=1
& S0 c  U) @8 B! K+ Q. c+ q    62 block groups
0 T' j! b/ C& M  O4 Y9 O    8192 blocks per group, 8192 fragments per group1 ^, @+ z5 T* f, h" n$ H2 u! J
    2040 inodes per group( j! T9 d$ Z5 D' z/ a- F' ~7 m
    Superblock backups stored on blocks: # T# I" R) ^7 n" u0 {
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409" H. J( l, g# H: b3 u8 P
    Writing inode tables: done                            7 R9 @6 H2 n8 z! b
    Creating journal (8192 blocks): done/ g3 J' v( u( k1 J7 A0 [& Q4 F/ ]1 j
    Writing superblocks and filesystem accounting information: done2 t6 V% e: Y% N
    This filesystem will be automatically checked every 30 mounts or0 T2 v2 Y  {6 g4 P, V/ b: P
    180 days, whichever comes first.  Use tune2fs -c or -i to override.3 O( r1 l6 N5 ^1 L% x
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
3 s) o+ W+ ]+ a. p2 l2 C# r    /dev/sda3              3723848    705992   2828692  20% /" e+ l- i. b8 x
    /dev/sda1               101089      9274     86596  10% /boot
3 K3 N- q( }$ B& p7 R) H3 U    none                     14520         0     14520   0% /dev/shm
; z6 ~0 ]4 J; U( n4 Y* a8 ]  k$ l, b# ]    //挂上新分区
( E6 p9 I5 W! O9 W# ^
  1. mount /dev/hda1 /home
    " Z; l6 ~& ~0 n; U9 ~2 d
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
7 L  @- k  Y2 z8 c7 j3 u: @    /dev/sda3              3723848    705992   2828692  20% /: ?  i) N2 U4 m# n9 B0 A6 V
    /dev/sda1               101089      9274     86596  10% /boot. Q; K' O  L- @$ q2 n' |
    none                     14520         0     14520   0% /dev/shm" n/ U  g) x; x0 h4 \1 |
    /dev/hda1               488006      8239    454569   2% /home( m' I& D! a) s* s, T# \0 y
9 B4 W7 R' }" V1 p7 F1 `" l
自动挂载:9 R9 @3 w) r! w# S) \2 y, }
  1.           vi /etc/fstab
    " |) d+ L4 g0 T, q0 L/ A+ C

  2. & G3 _* j$ m( Y5 g
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    3 d# {1 K3 ~1 a. w* H$ y1 D2 @7 a

  4. 0 Z1 `# n% z; ~# J3 _) s1 ?
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:  ]" e+ c. t% A1 }; F1 G1 W; f
  1.           mount /dev/sdb5 /mnt/ljp1
    7 G) m6 n& ?/ a" o  N
  2. + O( r9 O$ f* Y+ G7 }, c. r
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

+ `7 Y9 N- z$ [( R. k
8 y# l9 q; {# m0 X: U# z, a. p( w3 u7 l) O2 e0 G* I# |; J
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-26 10:53 , Processed in 0.027751 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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