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

 找回密码
 立即注册
查看: 2600|回复: 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)" `' F0 w- Y3 p4 Q" K" B. b* ^
      or: fdisk /dev/sdc  (for the third SCSI disk)9 W9 g- S/ d" ^% t, e0 Z5 d0 J/ e* F
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
, J& g# B2 _* r* s! H. N4 W      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
5 F7 n# @9 h7 {) Q2 ]& f5 s2 s      ...
2 j1 o0 g$ B8 A, j/ a+ U, k# L4 A; F
  1. df -k6 I5 S! j  l& V! J* c; a
  2. df -lh
    / F0 S  v/ t( }! p5 q, }! U3 p
  3. 查看有几块硬盘:fdisk -l
    4 r4 O$ w# L0 \/ h  U
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点; u' O# n" I$ y2 V: n8 {  L
    /dev/sda3              3723848    705968   2828716  20% /
* Y/ ?4 Q' }5 @; }& l$ U) a    /dev/sda1               101089      9274     86596  10% /boot
1 L, M% [, \8 m, [) E    none                     14520         0     14520   0% /dev/shm
" _4 P8 }3 T' q4 r$ D; t    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
0 D* z: a0 g. l7 {
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
( V0 G$ O9 ?4 E7 M7 n2 ^8 V% R    Building a new DOS disklabel. Changes will remain in memory only,. Z3 j3 b$ Y# \& Z+ a5 T
    until you decide to write them. After that, of course, the previous
1 L3 x+ ?* @5 G) H6 G/ x    content won't be recoverable.
& [) r2 W- A1 ?$ @8 o    The number of cylinders for this disk is set to 8322.
/ _6 f/ m( e( ~) x/ x2 f  g    There is nothing wrong with that, but this is larger than 1024,! K8 e- }# h: J) g+ V  B% D
    and could in certain setups cause problems with:/ M! ]: H  A3 g5 a5 X4 A
    1) software that runs at boot time (e.g., old versions of LILO)
7 Q6 }! W8 F8 m) J" t9 p, {) ]    2) booting and partitioning software from other OSs/ w3 {* ^7 @$ ?1 V$ b3 p) C/ i
       (e.g., DOS FDISK, OS/2 FDISK)$ v: _8 _9 l$ M8 S& k$ e
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite), ^$ P! D' Q$ o) Y0 v$ f% e3 g* n* Y
    Command (m for help): p
7 ?2 h0 @+ B+ \5 M/ q    Disk /dev/hda: 4294 MB, 4294967296 bytes
* c2 R% }* t$ F7 M# N6 ?* C1 |$ E4 l    16 heads, 63 sectors/track, 8322 cylinders
5 e$ a  G7 c+ d* G2 W    Units = cylinders of 1008 * 512 = 516096 bytes
$ C% E& o& I* Y4 z! I' E       Device Boot    Start       End    Blocks   Id  System
. j. ?$ @! l: }: X    Command (m for help): m1 U: C4 _6 S$ J5 T0 R
    Command action' t1 i% O  o& T! b
       a   toggle a bootable flag& V$ n" [! S7 ^; g  F8 O6 w
       b   edit bsd disklabel2 K9 ~' H; v( L6 ?8 ?
       c   toggle the dos compatibility flag5 o: ~2 G7 K9 \6 U1 b) H
       d   delete a partition
; I2 l6 @1 y, m; K( Q       l   list known partition types
( A% R7 i7 a* L2 `; b+ H+ k       m   print this menu  w4 N9 \. P6 ~$ q; M6 Q' k/ S
       n   add a new partition, n1 C$ u5 J9 E2 l  Q
       o   create a new empty DOS partition table
  u" K/ K% U- d8 i       p   print the partition table( T2 q. b# w/ q/ E7 y7 v
       q   quit without saving changes
6 e  B% F, p* y1 D7 x% \       s   create a new empty Sun disklabel/ G2 {  i- e" l9 c: N
       t   change a partition's system id
+ j: N9 D" g& Z/ {/ `( |  ^' R       u   change display/entry units; t+ Z! q: J) Q& T
       v   verify the partition table
  k* V1 L* L: E; n       w   write table to disk and exit
3 ?3 c8 ]% h5 E. c( q       x   extra functionality (experts only)
; x  V2 F+ |# Q4 t9 s- s7 r    Command (m for help): n
4 |, R. _$ ^7 }/ @1 X  ]    Command action2 ]6 K; O7 I+ T3 V- u$ Z% J
       e   extended
2 m2 \/ x; [4 e) o6 e# f7 y( c       p   primary partition (1-4)
, v& p5 c$ g8 q/ H# M; k; X    p
. R; ~  e8 a  n$ H/ I4 A* l    Partition number (1-4): 11 M3 E+ L$ e9 x5 y* `. ~; ~
    First cylinder (1-8322, default 1):
3 H$ N" e& P: d& L( ^    Using default value 1
$ a  S4 j" c4 A8 _1 e9 G4 l, S  I    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
% K3 y* l( }  r) a    Command (m for help): p
3 y% a1 ^0 _+ y# q    Disk /dev/hda: 4294 MB, 4294967296 bytes
! S$ _7 P7 }' P5 F) D    16 heads, 63 sectors/track, 8322 cylinders5 ^/ M8 e  X- R9 x8 a3 k. x
    Units = cylinders of 1008 * 512 = 516096 bytes
4 a' V! V& [4 B( }6 A* O9 {9 M0 Y. A       Device Boot    Start       End    Blocks   Id  System/ o5 O6 M8 k) e
    /dev/hda1             1      1000    503968+  83  Linux7 w" u) c) ^1 ]& v2 ~( C: Y
    Command (m for help): w
4 m) h) }* d: r: |; \& U9 B    The partition table has been altered!
6 r" F& T2 p/ P) K) N    Calling ioctl() to re-read partition table.) ~+ M) ?% K0 ?$ n8 y& J7 v+ ^# t2 e  [
    Syncing disks.
6 M2 O# L9 `$ E    //格式化新分区
* Y. E$ s0 {  a: ?
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
' S: ?6 J2 V; d0 Z. R" D+ n9 G    Filesystem label=
1 T% v1 [9 K/ S% ^    OS type: Linux. H" G" C; v7 X& v/ Z: K
    Block size=1024 (log=0)
5 W8 {4 k5 }  g3 Y( E+ n! D% U    Fragment size=1024 (log=0)
$ |" q6 y+ L; c, b3 z! }9 N$ ~  G    126480 inodes, 503968 blocks
. \9 ~+ [9 O3 K6 K) j    25198 blocks (5.00%) reserved for the super user
1 E9 d( V7 i' R1 j& x  y    First data block=1& _$ L, Q; @, E0 u& ^% S7 o1 O
    62 block groups9 o$ u' x" {' l- q3 q. B
    8192 blocks per group, 8192 fragments per group+ ^) ^' Y8 m& ?( M0 r
    2040 inodes per group4 t8 k" v9 u* u. o; B
    Superblock backups stored on blocks: * ^- n: X' ~0 H- a
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
. V  ~( g! J4 t6 s    Writing inode tables: done                            & y9 c6 Z( o7 A% X% N. O
    Creating journal (8192 blocks): done
) ^5 n- v; Z& W3 L. _# c- a$ K    Writing superblocks and filesystem accounting information: done; a' p3 U8 A- V; `" Z, O
    This filesystem will be automatically checked every 30 mounts or' S- a, g) _  ]0 Q0 {. g. Q
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
! t5 y. k. @- T6 x# v% j6 t/ z
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
' k) F" |9 G* B, A5 Q    /dev/sda3              3723848    705992   2828692  20% /
5 x) ~' E% y; Z    /dev/sda1               101089      9274     86596  10% /boot. {5 h  G% p5 |4 o( ~5 l' O
    none                     14520         0     14520   0% /dev/shm; `% {: L" s& V; I/ H( h  t
    //挂上新分区) ^1 @8 \5 e3 Z
  1. mount /dev/hda1 /home
    - a5 r! X% p+ Q# u0 k( I
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点% H6 H& d. E" L+ V" o, D3 U
    /dev/sda3              3723848    705992   2828692  20% /
+ K# }  ~/ g- q1 v4 R    /dev/sda1               101089      9274     86596  10% /boot
$ j! r  @* ~; G( d    none                     14520         0     14520   0% /dev/shm$ G; l1 t! V; C: P0 q8 @+ [
    /dev/hda1               488006      8239    454569   2% /home8 u3 w5 U) U  I& R$ B

1 \" p, P, {, h: `自动挂载:
6 H5 H, j! U8 v, d, W
  1.           vi /etc/fstab
    ! d) a6 n* R1 Y
  2. 0 O+ a: p: @( {4 l
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    ( J: p; t0 x+ I9 K- S, t
  4. + j0 O5 _2 R* _# I
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
4 [) ?% _0 q* j  y# j1 W( c9 @
  1.           mount /dev/sdb5 /mnt/ljp1
    # A4 P5 K& h/ p7 ?4 O9 F9 F8 {

  2. / c1 u( ^* S0 W( T* l
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

& Z3 M+ p3 Z+ n" v8 Q0 a2 m7 Y
0 w9 d0 u) h5 [. {* Y  ^( d
$ _" N$ L% D! T
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-26 21:11 , Processed in 0.036255 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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