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

 找回密码
 立即注册
查看: 2821|回复: 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)
, |2 n, J3 W2 E2 U4 t      or: fdisk /dev/sdc  (for the third SCSI disk)& g7 p+ @# N+ L* ]4 C3 {$ V- y% P$ i
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)1 J! L$ h2 U$ B0 x6 T; @2 ^
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
$ K  o' a3 X1 l$ v      ...
; L, _( d) d: W8 T) v
  1. df -k- ^5 i# O' d$ }  s4 T
  2. df -lh) }: t0 w6 V4 g1 i2 K! _3 e* }7 [
  3. 查看有几块硬盘:fdisk -l
    9 k$ n! O) Q2 }, H) Y* C6 O
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点+ Z1 j2 ^! D) ^5 ~8 r
    /dev/sda3              3723848    705968   2828716  20% /6 F5 {- F- U0 r
    /dev/sda1               101089      9274     86596  10% /boot8 b" O' l1 [' d: W4 b
    none                     14520         0     14520   0% /dev/shm) u0 N$ h$ D4 W7 h3 {
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
* O6 e; e6 A9 d3 o0 z2 K, S/ x
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
) r. |) |0 |8 _    Building a new DOS disklabel. Changes will remain in memory only,
5 A8 i: f7 t5 \' x+ j, k    until you decide to write them. After that, of course, the previous
( _0 K( d8 z+ K$ M- u    content won't be recoverable.& Y4 R) y* N9 r  ^9 ~( I
    The number of cylinders for this disk is set to 8322.
1 ~' \( A) F$ C! f  R$ c1 K    There is nothing wrong with that, but this is larger than 1024,, Z6 E7 B! [1 O: ?1 W3 l, \7 t+ w
    and could in certain setups cause problems with:  J  P; K# n8 E; D4 k2 h
    1) software that runs at boot time (e.g., old versions of LILO)! q5 ?5 S+ K% V0 C- p
    2) booting and partitioning software from other OSs
) ?' a& t; }. s& E( I) }       (e.g., DOS FDISK, OS/2 FDISK)
$ D1 a' m: ^' Q! W    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)8 O& B& [6 x" b* Z
    Command (m for help): p0 d* P% h8 M9 V, R6 L
    Disk /dev/hda: 4294 MB, 4294967296 bytes4 n( C' ?  a# l1 U4 e) l
    16 heads, 63 sectors/track, 8322 cylinders- \. O3 O4 X1 G0 Y" c! e" a" O& i! P
    Units = cylinders of 1008 * 512 = 516096 bytes, ?9 |8 a$ o: B* m* C5 T& h, s( a# C
       Device Boot    Start       End    Blocks   Id  System9 k" B6 }- t. \' B2 E
    Command (m for help): m
( T: E) n0 [5 ~# \. }. ~7 p    Command action( K! Z7 e# e7 X8 N
       a   toggle a bootable flag
9 E. x4 p( A5 s' I0 w+ B; i       b   edit bsd disklabel
! e+ k9 F. a" n3 ~4 ^       c   toggle the dos compatibility flag1 ^' |8 M: ?- L, p4 m# t6 F
       d   delete a partition
7 ?# l9 x6 `+ ~" A" b0 |       l   list known partition types: e" n! R7 z  L  w3 R7 p7 _
       m   print this menu% o$ A" Y8 y, ^4 J. ~
       n   add a new partition
; l( H' A* L  T. v       o   create a new empty DOS partition table
- w; P+ d6 B- l( }; k' J       p   print the partition table
* w' @7 b7 L: A- s2 Z9 `       q   quit without saving changes
& y' h6 p+ {2 d1 z  ?       s   create a new empty Sun disklabel
5 l4 s, ]; [# n  S% o1 f2 p       t   change a partition's system id
$ |  O; |8 c, h. _4 Y  n+ ~       u   change display/entry units
# k2 f4 ]: W) G+ g( Q# [0 P       v   verify the partition table+ e" n: x5 p3 y" r, S8 C: S
       w   write table to disk and exit- ~. ], r- _2 J; F3 w
       x   extra functionality (experts only)* F9 D! K! D, j  `9 x+ R8 ~% c, Y
    Command (m for help): n
% Z& O$ z) W8 a4 Q8 G7 W+ c; Y    Command action
7 `) W# T) V5 {3 E! n' l       e   extended
5 D% Z% I$ l( U       p   primary partition (1-4)
6 B; K. e3 ^/ X0 Y3 b    p
! N/ j2 e( t- W* C  j    Partition number (1-4): 1$ P* B3 J+ u4 c4 V+ S- o6 ^
    First cylinder (1-8322, default 1): : G5 [% b5 @5 |
    Using default value 1/ y0 `6 j; |0 L8 ~' g
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G3 t1 m" y) ?, Z$ X, ~% ~3 N! M
    Command (m for help): p
: y! z0 w" u: c    Disk /dev/hda: 4294 MB, 4294967296 bytes
9 q" k7 ]3 Z5 t9 X( H; X9 X: Q    16 heads, 63 sectors/track, 8322 cylinders% q4 ?7 {8 N, p  o
    Units = cylinders of 1008 * 512 = 516096 bytes
+ L3 x9 X2 @2 _9 J6 W0 m       Device Boot    Start       End    Blocks   Id  System4 f4 O8 x" k9 |0 A7 p
    /dev/hda1             1      1000    503968+  83  Linux8 W/ M0 t0 V" c! ~+ m' K" a
    Command (m for help): w/ Q% H2 ^! L3 {% Q
    The partition table has been altered!
" a3 n- G2 t" M, k% r    Calling ioctl() to re-read partition table.
" a1 r* m" \5 y! J# {- F1 Y    Syncing disks.
/ q3 w) l; V/ j" D5 M; Z2 ]$ a3 u8 f    //格式化新分区6 D3 G5 i4 M; W. v& R  u
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)7 g% d# ~5 x: Y) r& e) L
    Filesystem label=
/ P) [+ ~8 s: \& O! o$ I( h; W    OS type: Linux! u& }" S" a' k6 v4 k6 f$ e$ _
    Block size=1024 (log=0)
! A- Q. O1 B$ n+ s    Fragment size=1024 (log=0)) d" Z* ?, o$ \: {* Z) f7 U2 \
    126480 inodes, 503968 blocks( f3 I! v! }* W' F9 p( l
    25198 blocks (5.00%) reserved for the super user1 V. M( w% {, ~& G, S0 v
    First data block=1; R6 W0 Q" T  e# s, Y/ Z; @
    62 block groups
1 x3 a! g' m: x2 c* T    8192 blocks per group, 8192 fragments per group
$ K6 e) s+ k- R    2040 inodes per group
5 d  x% ~3 l0 [5 w    Superblock backups stored on blocks: ( \8 E- g8 Q5 i2 Y1 f
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014095 n7 U# t" t8 b: m5 {& t5 {
    Writing inode tables: done                           
* P0 F  G9 B  E+ x1 [" u    Creating journal (8192 blocks): done
# m& c% C# p) ]0 b# E    Writing superblocks and filesystem accounting information: done
  _! q1 H3 T( f1 k$ D    This filesystem will be automatically checked every 30 mounts or
7 \3 z9 F4 @5 ^    180 days, whichever comes first.  Use tune2fs -c or -i to override.
; ~! a, B( Z% L) [
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
+ N' I1 Y/ e7 B% d0 o    /dev/sda3              3723848    705992   2828692  20% /7 X5 I3 O( A+ T' I
    /dev/sda1               101089      9274     86596  10% /boot( e* y/ L' m# r6 V/ A
    none                     14520         0     14520   0% /dev/shm
7 y9 ~6 Y( R, L. e. {2 h9 w+ ?    //挂上新分区, G5 ?* o9 m0 t, X6 F" O
  1. mount /dev/hda1 /home' _# M- z1 ^# d/ P5 G" V& b. f- R, L$ y
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
+ _0 }. F% @  D! m    /dev/sda3              3723848    705992   2828692  20% /7 b. c: q: U0 y. @/ D
    /dev/sda1               101089      9274     86596  10% /boot" N, B4 j  H- i* x/ Z7 y( F' O$ z
    none                     14520         0     14520   0% /dev/shm# T6 b4 r( j- R6 X; Y6 f$ U
    /dev/hda1               488006      8239    454569   2% /home; p1 q1 x/ m& i8 ^$ X! I4 e

$ J: _. T% r8 n自动挂载:
( p7 n5 i" e, I; i
  1.           vi /etc/fstab
    0 d$ }1 N8 [; }" `$ j
  2. - U7 c9 X3 C- [/ x" d* h1 [/ b' Q
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 00 ^/ m2 M* z- S, g, K  f

  4. * y! m* q0 W8 \: L3 d
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
% m+ }6 A, I* ~6 Y
  1.           mount /dev/sdb5 /mnt/ljp1' y* e& o' C, H2 ?

  2.   k4 w; e) K2 M
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

& C* d+ K: J$ V- `" {- T& k6 r5 e% G% @; U: U

8 I1 \$ L+ [5 [0 B* J' ]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-21 03:30 , Processed in 0.013020 second(s), 20 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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