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

 找回密码
 立即注册
查看: 2669|回复: 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)
* S* V) p1 @) N; I5 C, B      or: fdisk /dev/sdc  (for the third SCSI disk)5 u6 }1 T! r% E: K! Y
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)8 _5 v4 V9 T& J2 q6 c# W5 ^
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices), \: A; e6 m9 }6 V' R9 J1 I" N  c
      ...3 Q1 a9 v+ F$ j! b) p
  1. df -k$ `5 ^% Q2 P+ C
  2. df -lh9 x: N4 \" n9 g% w( L
  3. 查看有几块硬盘:fdisk -l. I' f% ?& V' ]: j; X) V0 q
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
4 N* S4 E( f# h7 T" y% b    /dev/sda3              3723848    705968   2828716  20% /$ s# A& q, M. L! ?6 m7 H
    /dev/sda1               101089      9274     86596  10% /boot
6 m# P" z0 L+ a2 y- e' _    none                     14520         0     14520   0% /dev/shm
7 C$ p, H5 q( }6 O- ]    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用: b3 g2 z, ]8 V9 P% j3 c
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
6 Z, g% _' n8 g3 q. C" Y' i    Building a new DOS disklabel. Changes will remain in memory only,
; B% ^* U' ?9 h# l. C    until you decide to write them. After that, of course, the previous
* y# H& _0 ?% s! \7 W/ n    content won't be recoverable.$ d! q9 K; V/ R  v- o  y$ p- M
    The number of cylinders for this disk is set to 8322.
) ~7 p$ T8 _" g6 m    There is nothing wrong with that, but this is larger than 1024,1 E! |! c1 e& U" U1 o- g" e
    and could in certain setups cause problems with:
: x# q8 ]2 c8 U& C( y$ d( J) \% r    1) software that runs at boot time (e.g., old versions of LILO)
& R" Z; a: J+ n$ D7 E* q1 J    2) booting and partitioning software from other OSs
6 g: [: X0 F8 L! \) {( c       (e.g., DOS FDISK, OS/2 FDISK)
* ]3 W& W" f) }: m1 d9 w    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
. ?. |0 a' ~6 [6 L2 e! R5 p$ q! h    Command (m for help): p
% a! B, l7 D& {* @) ?    Disk /dev/hda: 4294 MB, 4294967296 bytes
# |4 e- O( t1 k2 u0 v    16 heads, 63 sectors/track, 8322 cylinders
0 k7 {/ y8 x# r7 \" c$ _    Units = cylinders of 1008 * 512 = 516096 bytes
$ P) T$ W( w  N% e2 H' \  w0 R" q5 H       Device Boot    Start       End    Blocks   Id  System4 m2 s0 ~+ W, {: y+ L
    Command (m for help): m
, y8 I5 `/ Y7 _    Command action  ~2 ?* d& C/ r6 Z! f: w, R
       a   toggle a bootable flag
5 t4 s) B- a. ^! b' U       b   edit bsd disklabel
% l( H0 k8 u  K5 ?9 C       c   toggle the dos compatibility flag
  T6 s- p  @! b; d2 s       d   delete a partition3 M& N3 A& m. N3 p, j5 C( s% c) Z
       l   list known partition types6 U7 R% t& v, g" F
       m   print this menu
0 s+ g& [# f, P+ a# j- v+ f       n   add a new partition
, I, c. l6 g9 X8 c  C       o   create a new empty DOS partition table
; S7 v2 [: S& k& m4 I7 I4 b. @       p   print the partition table
* ], g- W/ P8 K% h7 p       q   quit without saving changes, Q. A3 x8 b: u) l
       s   create a new empty Sun disklabel' L9 q( @2 l1 \* [
       t   change a partition's system id: v. }) @9 F7 t% x+ T
       u   change display/entry units
2 S; [* D8 x% T. C6 j       v   verify the partition table5 t9 E" m4 I6 {2 Q" M, I
       w   write table to disk and exit
: _4 \( P9 g: e3 u. s7 J. L. v       x   extra functionality (experts only)
( ~0 O5 ?0 ~3 x( m' ^  Z/ L    Command (m for help): n
! l7 h# }. N) J1 s    Command action
( v' e9 l5 _5 S       e   extended
$ J: O& ?  g& a4 d" S       p   primary partition (1-4)2 C6 K0 H! k/ r# [
    p
2 P2 L0 }1 Z' ]+ l9 z    Partition number (1-4): 1
! L, P, m/ {3 |( T0 B+ \- ?    First cylinder (1-8322, default 1): / [# P7 U8 A2 g% z+ [1 n: h/ u
    Using default value 1
1 n+ ^" c8 T; n3 W: N6 A% `    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G0 v$ G% B! e! ?
    Command (m for help): p
5 N- M  w$ |0 _9 J3 }    Disk /dev/hda: 4294 MB, 4294967296 bytes
6 ^: D9 z( ]7 Y* e7 f( ]: a1 t    16 heads, 63 sectors/track, 8322 cylinders3 n8 M7 j% Y1 A9 v: }. c7 h* M- T
    Units = cylinders of 1008 * 512 = 516096 bytes: p; z  @3 \  S8 Y! z+ ^5 t7 x
       Device Boot    Start       End    Blocks   Id  System8 g  [0 Q2 k4 b! V2 l' M
    /dev/hda1             1      1000    503968+  83  Linux* S6 x$ p3 I% K3 s
    Command (m for help): w
4 Z! b; c# M& E* ~, P9 G    The partition table has been altered!; e/ J/ T0 h+ {+ v5 |+ d2 Z
    Calling ioctl() to re-read partition table.$ G% N. O4 |2 H8 O
    Syncing disks., t  C, R; C! ^: l2 r
    //格式化新分区
9 z% T# _( a3 D7 u$ k+ X" C6 B
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
, [  t, Q' {6 P5 g    Filesystem label=4 [  {7 @( |7 l- M: Y7 D" b' H, S3 Q
    OS type: Linux
. q8 b% s' X2 `- R5 o5 r    Block size=1024 (log=0)
& O2 x. p1 G" G( o! O8 U8 |+ k$ Z    Fragment size=1024 (log=0)
1 H9 n* [% M% u& M/ j2 Q    126480 inodes, 503968 blocks0 d2 W6 X, t9 M' o1 `  {
    25198 blocks (5.00%) reserved for the super user, c7 ~6 K4 m0 i) r& i$ T  q
    First data block=1
7 G8 k1 ?! z6 [" f5 W# \9 \    62 block groups
  d9 y( L4 f/ @  d" d$ p    8192 blocks per group, 8192 fragments per group
6 X2 `/ l5 X0 v8 M    2040 inodes per group
- [# [7 U7 h7 t) B7 C- m7 s    Superblock backups stored on blocks:
& m6 \2 i1 v. }            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409; i; C0 r6 a7 B0 |& ?! ~( _( \
    Writing inode tables: done                            + `& I/ I/ I* [
    Creating journal (8192 blocks): done
6 _' q& r( ]( }1 i. f3 V' x    Writing superblocks and filesystem accounting information: done8 K, y8 n3 `0 d" a
    This filesystem will be automatically checked every 30 mounts or
. G' y' L% k0 o# y    180 days, whichever comes first.  Use tune2fs -c or -i to override.6 F$ t, P# _$ ~
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
0 V  S, A) d# j3 S" t  E* W5 E    /dev/sda3              3723848    705992   2828692  20% /
# B+ J* R# F* e4 L  ]    /dev/sda1               101089      9274     86596  10% /boot7 I% j! A% E: j9 t& e
    none                     14520         0     14520   0% /dev/shm  A' ^! E9 |8 K# J$ Q9 r& t
    //挂上新分区
+ `2 L5 C0 O+ \% i, @3 w' `% N
  1. mount /dev/hda1 /home
    4 t# }# I3 t3 L: W" Q: h
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点0 s2 e/ T- z; ]( O3 X
    /dev/sda3              3723848    705992   2828692  20% /
; O3 t& C" i: h3 V. t$ ]9 e    /dev/sda1               101089      9274     86596  10% /boot* h& [' `$ r& P
    none                     14520         0     14520   0% /dev/shm
5 `9 j( _% o; Z0 t5 O/ `( r0 i: R    /dev/hda1               488006      8239    454569   2% /home2 A; U1 W# S/ Y& x- f( p" u. Z

' y$ r7 u7 w% }自动挂载:8 u3 q7 i' F% B6 E" J; z1 X) ]
  1.           vi /etc/fstab
    4 G$ B7 `) z( [: o) M' j
  2.   t0 f0 ^; U# U+ `2 d7 O
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    * ~. y1 e" r$ D& y; t$ Y

  4. 0 k* P: E% {4 P, s3 J
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
5 g1 {, x4 a) V% @) V# C( P3 ^
  1.           mount /dev/sdb5 /mnt/ljp1
    2 `' [: j2 n3 J; G! i

  2. 2 q5 P5 ^# f- U/ r4 @# \
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
$ M* ~  J6 A* j1 N4 U

. u+ L" U/ x5 r1 L4 I1 W8 D
2 N) u$ d. l5 Y4 b% }5 U
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-11 14:44 , Processed in 0.018685 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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