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

 找回密码
 立即注册
查看: 2769|回复: 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)3 U* L, f8 I$ p5 I4 |
      or: fdisk /dev/sdc  (for the third SCSI disk)
! e  A; H  o% ?      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)" u2 b9 a1 N/ l9 t
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)' l. ~2 D2 r/ i
      ...- `, i- x9 J' C& a$ u
  1. df -k# t! G/ p- h, [$ N, R2 F1 I
  2. df -lh
    , J! ^: e7 O" o2 B
  3. 查看有几块硬盘:fdisk -l
    9 _/ J9 S; D! b. s) n! s8 z
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点  Z4 L' j, n8 d- D
    /dev/sda3              3723848    705968   2828716  20% /
3 ]5 r7 X, t2 @, q$ j3 h$ R    /dev/sda1               101089      9274     86596  10% /boot1 C: l! Z/ h- V) i" f
    none                     14520         0     14520   0% /dev/shm- B& ~' E" j" L2 R' Y' t+ r
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
& {* }+ d5 g5 T
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel9 a4 h7 |: n/ U& f
    Building a new DOS disklabel. Changes will remain in memory only,# S2 W& P0 @1 f  d/ `
    until you decide to write them. After that, of course, the previous, ^9 W9 J. q( N( s8 H& A/ h
    content won't be recoverable.
) V3 C# y1 C  b' s* Y0 f    The number of cylinders for this disk is set to 8322.
" F/ f3 P0 w7 \3 G    There is nothing wrong with that, but this is larger than 1024,8 @% f( s! E# t( S' `# m
    and could in certain setups cause problems with:
) Q/ D! R" j: H- O8 y* ]8 z+ B$ R    1) software that runs at boot time (e.g., old versions of LILO)% E5 f9 Y0 h2 j/ m% k
    2) booting and partitioning software from other OSs: E0 N6 y* f) ]9 s, Y
       (e.g., DOS FDISK, OS/2 FDISK)3 V% |3 V/ [! W3 k( `, O, Q
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
* k+ C6 f; }% x& ?" w    Command (m for help): p: P& ?9 u; }3 N( H; A6 @1 b/ p" L
    Disk /dev/hda: 4294 MB, 4294967296 bytes4 h& W3 _5 k8 I4 Q2 x
    16 heads, 63 sectors/track, 8322 cylinders6 t: c( c" w  j+ [- [) I; k% n
    Units = cylinders of 1008 * 512 = 516096 bytes
  o$ v) V8 e' x8 A       Device Boot    Start       End    Blocks   Id  System
7 D, d4 i0 x7 y% O. m( w0 ]6 w    Command (m for help): m  r9 N' p# ~. b& d0 J5 G8 l
    Command action" E, l, `3 D0 ?  w, n
       a   toggle a bootable flag6 l! \' {6 Y0 w0 k- H
       b   edit bsd disklabel( m! M4 @: O+ J! z  a* H  f; ^: Y( _7 [
       c   toggle the dos compatibility flag3 k. {) ?7 n8 p! T  M  x3 c3 h. }
       d   delete a partition# l, ~0 n, g  D1 ^# E& G
       l   list known partition types' P* Q. }( K+ _0 B& \7 U
       m   print this menu, R$ @) C0 Z$ T9 @2 _5 r4 H3 @1 }
       n   add a new partition
% e, K% j7 k2 g# F: l       o   create a new empty DOS partition table
9 K' x0 _; ~( y; E( B1 m       p   print the partition table4 `; R% j( u$ }! f8 G0 R8 e9 b
       q   quit without saving changes
; u3 e8 y1 F+ @" @. K0 y       s   create a new empty Sun disklabel
& Z% T# E/ l2 I: ?; L8 S       t   change a partition's system id
4 ~+ C2 _% R6 b8 O6 B. k. [       u   change display/entry units
5 O6 l/ d  F4 M. M( V       v   verify the partition table
, L0 _* N+ P4 q       w   write table to disk and exit8 i' ]$ c3 v7 J; V2 |7 [! T
       x   extra functionality (experts only)
# S: s3 R% q& S% ~    Command (m for help): n$ k# g% e$ v( e9 W, y% w9 m
    Command action
+ z- U$ j' t- J( a       e   extended
  B% C- W: [( a/ {) U/ ^       p   primary partition (1-4)
! G8 v5 ^# {1 N1 W& ]6 Y    p
& V' y8 N( K! f) V) }* H    Partition number (1-4): 1/ m& m( q7 C+ T- E# t
    First cylinder (1-8322, default 1):
3 g! @1 n) N+ D! J7 E    Using default value 15 V$ M5 V' P1 Z3 y
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G( L- z8 L2 n" Q: ^1 y+ P
    Command (m for help): p
  E3 ~  T/ Y( t& i) {    Disk /dev/hda: 4294 MB, 4294967296 bytes
5 b! C) f0 U; T9 v! l    16 heads, 63 sectors/track, 8322 cylinders" ]& a# W5 K8 }  m) m& q. k5 ?
    Units = cylinders of 1008 * 512 = 516096 bytes
; r' N2 f" U) ?% Z6 I7 s       Device Boot    Start       End    Blocks   Id  System
3 }; Q6 k4 w  ^6 b" j" D    /dev/hda1             1      1000    503968+  83  Linux# o( o# z- W  p' f8 q9 S* a8 X6 Q3 q
    Command (m for help): w2 Y* N  u) T4 {
    The partition table has been altered!
+ f/ k" o8 I. D* y; y8 J5 I" c    Calling ioctl() to re-read partition table.1 n5 W9 ~; F4 ^, K
    Syncing disks.
5 Y: d+ ]+ w) D# _! ]    //格式化新分区7 Z% j- i/ P; {
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)- C) t8 s! ?5 G/ V) X' v8 D0 G
    Filesystem label=( f! _* U0 k" A" Z  R$ [$ e* ^* b
    OS type: Linux1 D) {6 h5 R. j+ J/ f. ]( G* t" J
    Block size=1024 (log=0)2 P& ?1 E+ F0 b) t+ v$ a$ L
    Fragment size=1024 (log=0)* H. J0 a+ ~0 B0 `' ~3 \) D" E; ^
    126480 inodes, 503968 blocks, ^; ^, J+ {2 K  O
    25198 blocks (5.00%) reserved for the super user* f0 P1 j# l: l, P' ~  M, y
    First data block=1( T1 t( w! q1 ]3 {
    62 block groups
. n1 G* W2 r( |0 b) r( \: v    8192 blocks per group, 8192 fragments per group9 d  c3 R& H# n3 ^$ q, x* `
    2040 inodes per group3 m1 J) a3 H  `2 E2 d
    Superblock backups stored on blocks:
* G; u0 A0 z" [6 C! ?            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409( ]+ r/ g# e: M$ `
    Writing inode tables: done                            . N4 @0 ]9 i. u3 V
    Creating journal (8192 blocks): done
6 }& [1 T7 O9 f    Writing superblocks and filesystem accounting information: done5 P1 X* ]% o! l1 H
    This filesystem will be automatically checked every 30 mounts or: J& v# T8 j3 y" r
    180 days, whichever comes first.  Use tune2fs -c or -i to override.& a9 F6 g9 T  Z5 ]' k
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点( D" }1 f; `1 l( @4 ^+ k: _
    /dev/sda3              3723848    705992   2828692  20% /* m9 }6 {: E1 S
    /dev/sda1               101089      9274     86596  10% /boot7 q1 a* ]1 M: O  U
    none                     14520         0     14520   0% /dev/shm
2 d6 G  g7 k% L& U5 e$ ]    //挂上新分区
1 j' X8 t) @' Y1 G9 W5 L& f+ p
  1. mount /dev/hda1 /home
    5 l5 X) a$ c5 e. `3 T" x' |1 _+ H
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点5 O& i* k3 D; b( _5 f; O
    /dev/sda3              3723848    705992   2828692  20% /* \: m4 Y/ Y' I9 `  `
    /dev/sda1               101089      9274     86596  10% /boot
; g) K, U0 f' l    none                     14520         0     14520   0% /dev/shm
# }$ e6 Y" C/ K+ |1 k    /dev/hda1               488006      8239    454569   2% /home8 j  ~) X3 U8 N
6 V4 x( ~7 _# G) z
自动挂载:
7 N- D! a0 u9 g
  1.           vi /etc/fstab. K, [9 E/ X% K  d8 h8 Y9 b+ d

  2. 7 H, Y- h' g" F
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 01 \" h- o2 P3 c# n" n, a9 f% c
  4. 0 {# C' o. Y, L; H) u3 V
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
; B! o1 ?% B6 V1 N' F8 V9 f/ R, n* _
  1.           mount /dev/sdb5 /mnt/ljp18 y) n# D1 b( r% f/ B6 o

  2. ! X7 z! i! W& @
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

) E. O6 S6 }% U2 I+ i! Z
' L/ i5 a8 O% d0 y
/ M7 N8 M0 W1 Y2 B  Q7 A
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-12 10:25 , Processed in 0.012582 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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