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

 找回密码
 立即注册
查看: 2608|回复: 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)
; o2 k7 B$ N6 P7 R      or: fdisk /dev/sdc  (for the third SCSI disk)
: t& W4 x8 e" K      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)! Y6 o" F. x  f% l0 {
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
# f( [% H/ N1 G# D7 X" C      ...8 e& l$ }% P5 [% A3 \# Z7 o
  1. df -k3 v3 \6 C: B, Q! Z
  2. df -lh& W/ y- L2 @6 Z
  3. 查看有几块硬盘:fdisk -l4 {# }9 R  Z' n, X9 U7 {
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
* t% I2 D6 I5 P" s/ ~0 m- ]! b& Q    /dev/sda3              3723848    705968   2828716  20% /. w9 R# |2 N8 F" V
    /dev/sda1               101089      9274     86596  10% /boot) M6 s' t* N* i, m: T3 ]* U/ B
    none                     14520         0     14520   0% /dev/shm1 L/ \4 e% h* \- D+ {7 m) r% H# F
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用; |5 \$ v; N- D' R! }- g
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel2 M0 c" M! [! [3 d' w
    Building a new DOS disklabel. Changes will remain in memory only,
6 k  d: _( Z) M7 b  R    until you decide to write them. After that, of course, the previous
% `% o9 J3 r# d8 u4 y7 C2 n  }    content won't be recoverable.
/ `/ _' W5 v0 l0 l  Y4 ~( r    The number of cylinders for this disk is set to 8322.. m6 O  _9 u  z6 K5 Z, @9 G! ^
    There is nothing wrong with that, but this is larger than 1024,7 @% c4 X0 i9 K5 q2 W! b
    and could in certain setups cause problems with:/ e- Q" D$ R9 B" t
    1) software that runs at boot time (e.g., old versions of LILO)6 Z0 M  F9 V1 ~
    2) booting and partitioning software from other OSs+ E: t1 W! [2 @. a4 l6 F
       (e.g., DOS FDISK, OS/2 FDISK)
# J4 m# \) h- c    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)$ C! P. l. A; g  o, @/ \# n
    Command (m for help): p
7 C  K3 q0 E4 E3 M    Disk /dev/hda: 4294 MB, 4294967296 bytes
, G% U' J8 M9 _1 S0 T) h2 ~    16 heads, 63 sectors/track, 8322 cylinders
6 t: U) j0 {7 T0 c$ j    Units = cylinders of 1008 * 512 = 516096 bytes! n* T3 @# G2 o2 C
       Device Boot    Start       End    Blocks   Id  System4 j& K2 P! Q+ \# k1 J
    Command (m for help): m
( E: @1 _* @# J. f, N3 _    Command action
0 C& K, K& J4 z. F5 s$ w       a   toggle a bootable flag4 h3 I% @$ f6 K' [
       b   edit bsd disklabel! N$ g. q7 n8 T. s( Y$ C0 s( g
       c   toggle the dos compatibility flag
* Y2 F8 F. t9 g$ M8 v$ P! J       d   delete a partition  u. [- I1 k: _, w5 W1 N
       l   list known partition types' d) h; P/ D5 w% ^: f$ k
       m   print this menu
0 E1 Z* d, }+ f% e       n   add a new partition9 n9 q  |0 g' E! b
       o   create a new empty DOS partition table4 {/ o# S; ^8 v( R
       p   print the partition table
5 c) |8 c- \5 O- G       q   quit without saving changes$ S) ], w  S) M" \$ o3 w, F; k/ M/ Z
       s   create a new empty Sun disklabel& N; M4 v1 c' d- w% _; B
       t   change a partition's system id( c+ a5 o6 d3 _) m0 t
       u   change display/entry units
3 v5 F6 X' ~: Z" Z% L$ w       v   verify the partition table
* W1 r* [8 j0 ]* u       w   write table to disk and exit7 @/ {! D. o$ f% R0 \( h' n
       x   extra functionality (experts only)
# J. c0 G  R7 Q& c2 j6 W  V    Command (m for help): n
3 j1 L. Y' h9 {3 B! @) b! l    Command action# I& w+ C  P8 o5 z
       e   extended1 Q1 A. D" q/ t
       p   primary partition (1-4)6 [# H8 Y% q* s
    p
# ]& K/ [& p$ [0 C    Partition number (1-4): 1
3 O4 w* ^5 I& Q2 p; X    First cylinder (1-8322, default 1): - l# U, f8 p: \" P- @
    Using default value 1
/ y4 l4 l6 D3 D6 C; X    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G! u; `" y5 l# B% p2 N! w/ k
    Command (m for help): p
; c% R. L, q( N: O/ I" D3 ?    Disk /dev/hda: 4294 MB, 4294967296 bytes
. n4 n$ b/ h6 f2 L( L; X3 p* e    16 heads, 63 sectors/track, 8322 cylinders$ Y$ {+ o3 |/ r! \. R  d
    Units = cylinders of 1008 * 512 = 516096 bytes
. e1 {3 v+ N. ]9 {+ R       Device Boot    Start       End    Blocks   Id  System
. i( d3 W& n" s! L; ^# ~/ g    /dev/hda1             1      1000    503968+  83  Linux  p: Y# c: w1 |1 r# K6 J" q
    Command (m for help): w
" `3 M! ?) N( N4 L, i. H    The partition table has been altered!
3 w0 d! ^1 x; _% e" f# ^    Calling ioctl() to re-read partition table.5 H% |1 ?' r, |5 R* T
    Syncing disks.
" q& v7 O  t4 x3 M1 O: A. f    //格式化新分区+ ]' \' ^- ]6 \- {; m6 s
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
. e1 m. p$ y3 ?; q$ l+ |& W1 n    Filesystem label=) d1 s+ D% y& x% X* I! D' g
    OS type: Linux) G8 U4 U: m) J: j$ u) f# @
    Block size=1024 (log=0)
( ~2 k5 ~  I( o8 U- p! @/ i    Fragment size=1024 (log=0)
8 u) w4 u+ s: ?! X    126480 inodes, 503968 blocks$ L1 a3 J& W' F
    25198 blocks (5.00%) reserved for the super user
9 I( r, O, [$ F, g* j  p5 g1 N% J: J    First data block=1! _# D0 Y2 R9 ?
    62 block groups( |6 e# U. ?( X2 X" ~* `
    8192 blocks per group, 8192 fragments per group1 v/ F0 X" p" S9 I( S  h* A% B
    2040 inodes per group! k% p# k7 ^2 W! H- V! y: I5 q3 l" c
    Superblock backups stored on blocks: . {  Q! R" q/ s9 ]1 a8 f
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
: N' J6 O# `" R( M; e7 ]/ P& V    Writing inode tables: done                            0 r: X1 Y5 O4 X* S
    Creating journal (8192 blocks): done
$ ~1 {! C; v5 w  }+ c- R9 d    Writing superblocks and filesystem accounting information: done
5 M, h- C% \1 S: s    This filesystem will be automatically checked every 30 mounts or  a' W: L+ Z+ j2 F
    180 days, whichever comes first.  Use tune2fs -c or -i to override./ ^4 A. I2 {' h
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点% i2 W- o6 \; l6 s8 s) R" E& }6 f
    /dev/sda3              3723848    705992   2828692  20% /& u  n) A+ ^; C, B' ~
    /dev/sda1               101089      9274     86596  10% /boot5 o9 X% G# S: A5 E2 L) D- y2 j! F( y
    none                     14520         0     14520   0% /dev/shm/ V6 C8 S. Z) a4 W( m, I
    //挂上新分区+ U3 z, Y: |- X; q- K# R% ]
  1. mount /dev/hda1 /home
    $ ^2 c: `  b2 ^5 ^9 O# ^: j
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
4 {! h( ?2 ]* r    /dev/sda3              3723848    705992   2828692  20% /) T- }$ @( [/ R7 i6 j# q5 U1 V: u
    /dev/sda1               101089      9274     86596  10% /boot" m2 R6 g: J# T7 O) P' z
    none                     14520         0     14520   0% /dev/shm
& n7 T, C& j4 M' d5 u! W1 P# [    /dev/hda1               488006      8239    454569   2% /home
; s, E" X% y8 X% |- i  V/ h( O- T5 _) F# j; @
自动挂载:
" d6 o; H6 L& Y* I8 F7 J) N
  1.           vi /etc/fstab" f9 \# w3 P  y8 m7 a
  2. 2 l/ D5 E1 B3 x1 W! `% f! y9 M) e1 u
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    ( M* s( j0 e% L# q: ]4 U

  4. ( W: Q/ c& q1 ^
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:& i" Q, y: f0 J; T. r5 b: J6 {
  1.           mount /dev/sdb5 /mnt/ljp1
    3 _8 M; X' i* p  }
  2. " T, C! {7 p. x% P+ C5 @
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

( Q* g, B1 j$ ]3 }9 w: b; H4 Z3 l: R

: ]3 R8 h9 d6 E0 u
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-28 20:00 , Processed in 0.038537 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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