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

 找回密码
 立即注册
查看: 2566|回复: 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 m* F& ^6 E% L. o0 J. O7 d
      or: fdisk /dev/sdc  (for the third SCSI disk)3 Z8 E  p+ T* S, t: P) u) L( L: h
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
, w4 [( a1 k  R$ H  M! {$ L      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
/ ^4 S: }# s! e3 |8 u      ...- F6 c$ c, O( \  t
  1. df -k
    1 s* [- C2 j0 ?
  2. df -lh
    ( g8 b9 ^( K- e! o5 \/ r) ^# j3 b. e
  3. 查看有几块硬盘:fdisk -l& Q; X2 W3 X3 A" T! Z
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
# B5 O" }2 u; Z# u% H' y1 S. H    /dev/sda3              3723848    705968   2828716  20% /2 m8 i7 k$ i! u: d9 j! G
    /dev/sda1               101089      9274     86596  10% /boot
; x7 t, t2 [8 q4 P( c$ K    none                     14520         0     14520   0% /dev/shm" r" m0 d/ ^0 r8 x
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
7 d+ e5 @! X" c9 W+ @+ u
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel% @7 L. _# C) h* T$ b
    Building a new DOS disklabel. Changes will remain in memory only,- Z9 E" b. e! ^
    until you decide to write them. After that, of course, the previous
7 N6 [: i3 r/ P% n; l# N    content won't be recoverable.
3 o, {+ K; c# p/ g6 K9 |    The number of cylinders for this disk is set to 8322.
) [4 ^1 `4 ~+ n6 }2 {    There is nothing wrong with that, but this is larger than 1024,; v( I7 A1 s! v0 J: m1 i9 k
    and could in certain setups cause problems with:3 @- [5 O& e6 v& w$ N1 ~% n3 F! v
    1) software that runs at boot time (e.g., old versions of LILO); x; `7 y$ i9 r+ q3 `! n6 W5 y
    2) booting and partitioning software from other OSs
& z( T% r, n, {. b       (e.g., DOS FDISK, OS/2 FDISK)( X- A& m+ |* g$ c- k$ q- `
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)) A) ^5 N* u9 m! _+ G
    Command (m for help): p
+ o+ y7 i8 T: J! P" |/ g$ X1 }    Disk /dev/hda: 4294 MB, 4294967296 bytes
! x3 W; m1 X  H3 E$ R* R9 D/ b    16 heads, 63 sectors/track, 8322 cylinders# v2 q" v0 v0 P: F
    Units = cylinders of 1008 * 512 = 516096 bytes
& z. z& |+ G: z# P3 c+ c       Device Boot    Start       End    Blocks   Id  System& `0 Q9 g0 H1 Q0 [& h
    Command (m for help): m+ o5 M9 B9 g2 Q4 y' r( r% P- @1 j
    Command action
5 }& l4 {' I( g/ s# K& E8 m/ V       a   toggle a bootable flag
( b7 N+ h  f6 E  T. B; V' c       b   edit bsd disklabel7 T6 D0 _0 H) I5 W, F$ w1 i  P
       c   toggle the dos compatibility flag& p, T) \, r+ F5 A4 Y
       d   delete a partition" L6 l1 k" Q  _. l+ e7 T7 v; D8 f
       l   list known partition types
5 c5 G4 }( w- D$ z4 @( W       m   print this menu7 J* t4 p, A& @% A
       n   add a new partition
1 G! o- z8 `- s6 m( \       o   create a new empty DOS partition table
1 [$ O  O) S6 n5 S/ M  l       p   print the partition table
. V$ V, J# N( c0 @+ f       q   quit without saving changes
9 G, X* V$ u% A$ U       s   create a new empty Sun disklabel
. w/ \. a3 U5 r7 M5 l       t   change a partition's system id# B, l: B% z9 L5 I- \; g* D7 V) L$ ^
       u   change display/entry units# I+ g4 U" ^) d* |% F
       v   verify the partition table; c. v! j+ `' l  g
       w   write table to disk and exit
  J3 K. j( s( I# u5 q7 R8 U0 E       x   extra functionality (experts only)* L' Y) e+ U: q4 k
    Command (m for help): n
3 Z7 y7 U9 Q. z8 z& q0 o" v    Command action1 E% C7 F/ `6 G) c' K0 ]
       e   extended* K4 z  c  F5 U* T; L/ p
       p   primary partition (1-4)1 q8 A3 {" [8 t4 @% r( Q
    p
" u* {  |& [# c    Partition number (1-4): 1
0 V5 Y1 Z- N8 C( ]' a+ }" g, P    First cylinder (1-8322, default 1): 7 k  D2 d, Q8 V
    Using default value 18 s- s  n. L1 O- h4 u1 x: v! D
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G9 Q, K% o' o, {, G5 L+ J" i
    Command (m for help): p
1 g  H  E6 b2 J8 s0 S4 k    Disk /dev/hda: 4294 MB, 4294967296 bytes4 x$ `7 R% u9 n4 L  n
    16 heads, 63 sectors/track, 8322 cylinders
8 a- ^/ L2 B- e    Units = cylinders of 1008 * 512 = 516096 bytes
2 ]1 e9 k. N9 v4 Q, l3 s8 k8 h8 A       Device Boot    Start       End    Blocks   Id  System
9 E5 b* }! ]: p    /dev/hda1             1      1000    503968+  83  Linux1 Q  u) r* U! o8 ]& i
    Command (m for help): w
, ~  F3 b, \/ Z+ t# ]    The partition table has been altered!
" X! R" M) t) v7 D    Calling ioctl() to re-read partition table.
* c% W" i* Y# X5 ^+ c    Syncing disks.  R0 |; U: o5 W, J( G( a
    //格式化新分区
+ A6 ]! y) W/ W% i0 C
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)! T6 @9 ?; X6 _: w8 t
    Filesystem label=
; w# T" J& S; v    OS type: Linux% h% k" l8 x2 K
    Block size=1024 (log=0)
, s+ }! E5 O- p2 s0 ]& `; ]    Fragment size=1024 (log=0)
) o8 S: s; K1 j; i* A3 t    126480 inodes, 503968 blocks
% ]8 K. `+ F! \. V* q  v9 C    25198 blocks (5.00%) reserved for the super user
$ P/ N" F7 h. v% O9 h- \. S    First data block=1/ t5 |8 Q# H( o; w3 a: e
    62 block groups. K7 _* S# m% b$ u6 }
    8192 blocks per group, 8192 fragments per group+ K( F3 e5 q- ]
    2040 inodes per group
/ \! b& G2 s+ f/ k    Superblock backups stored on blocks:
/ z, G; k& w8 F$ u  M7 V            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014092 d0 K! A; E$ ?1 w  A8 ~3 z
    Writing inode tables: done                           
0 y; s  V; o3 _, m  k( q: X    Creating journal (8192 blocks): done
/ |7 V# Q, _( J$ A    Writing superblocks and filesystem accounting information: done- r8 f6 D  b9 G' y( u& p. N) s* g
    This filesystem will be automatically checked every 30 mounts or
( x; @8 y  i! v# U    180 days, whichever comes first.  Use tune2fs -c or -i to override.0 L) j( ^. l% y$ ^8 r8 D% ]
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点' b9 F2 N# e" D, A7 _- D
    /dev/sda3              3723848    705992   2828692  20% /
9 V. y$ a! a7 c( H  b; L7 a8 e    /dev/sda1               101089      9274     86596  10% /boot0 G8 [' ?& ~3 B$ V2 V! w2 W0 ]4 k
    none                     14520         0     14520   0% /dev/shm
# c* Q6 A# s. o. O2 X    //挂上新分区
  e2 E0 v( K2 q$ K* v  X0 Y
  1. mount /dev/hda1 /home
    6 Y" N- ?. r+ X
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点! P1 n  [; I6 O" b' B) s
    /dev/sda3              3723848    705992   2828692  20% /
: a7 H: m2 j9 T' l    /dev/sda1               101089      9274     86596  10% /boot% S- ^0 M# x/ `& ]
    none                     14520         0     14520   0% /dev/shm+ y) J" K0 {7 p$ G2 {9 ~  S7 k
    /dev/hda1               488006      8239    454569   2% /home2 ?3 k* L/ C9 K; ]1 P6 z

! v) P& z+ i7 q+ O自动挂载:
# j; G* n+ p- R0 L5 b/ x$ |
  1.           vi /etc/fstab' Q4 D. O4 N4 `6 X5 ~
  2. + G4 Z* ]* Z# O7 Q
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0$ R8 d, S' ?, V

  4. 5 q" Y( _1 V4 }! J) W* j
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:$ o) {8 N/ |2 C; q% j2 u
  1.           mount /dev/sdb5 /mnt/ljp1# w: _' P$ x. d/ |" Y
  2. ' ]& e# ?$ d6 N& v; V) n! X1 v4 V4 m* ~- \
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

$ s4 m* d  z+ S% Y. @1 B% [9 S( I3 [" y- B/ d$ \1 Z
% l( [3 i' v- e7 x) A! Y0 {
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-15 20:14 , Processed in 0.016078 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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