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

 找回密码
 立即注册
查看: 2825|回复: 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)+ ~/ g9 A6 h+ W- I  h
      or: fdisk /dev/sdc  (for the third SCSI disk)% u9 u( ~+ S# N( J$ _2 ]" a
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
- q8 z6 @- K8 D; ~/ J- O  p      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)3 i/ U- h  a; t8 T
      ...
* a$ Y8 q) r/ }+ ]2 s2 U
  1. df -k
    6 B" x5 U3 q  J0 Z$ e" ~! y, O
  2. df -lh
    0 v5 Q  s" D* k/ {5 K6 o) k
  3. 查看有几块硬盘:fdisk -l
    0 R/ n( L0 w0 {  @1 }
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
3 Q1 H& h% v9 O( z    /dev/sda3              3723848    705968   2828716  20% /" d  F" [% }, z9 e0 k4 v4 u& E4 Q
    /dev/sda1               101089      9274     86596  10% /boot4 Y9 S( }6 g4 z9 [! K
    none                     14520         0     14520   0% /dev/shm1 L. H, a9 I9 N( ]
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
- K* O& j! R& V1 _1 q" W$ S
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel5 G& z+ b7 m( g: X- F  {& B0 J1 j
    Building a new DOS disklabel. Changes will remain in memory only,3 U% K2 L, `# `
    until you decide to write them. After that, of course, the previous' {2 u$ v4 \0 q- f$ Z# j5 V
    content won't be recoverable.- h/ R& L6 T  ]6 ~" H2 r
    The number of cylinders for this disk is set to 8322., ~5 n' z2 E2 o' Z) x  H
    There is nothing wrong with that, but this is larger than 1024,
# }& y7 z% a) F; P8 M2 Q( d# `& l, c    and could in certain setups cause problems with:
4 d( C% f! y# e. s( z    1) software that runs at boot time (e.g., old versions of LILO)
  H1 j. {( o9 S, e/ P9 ~    2) booting and partitioning software from other OSs
. V2 F' t( G. g7 }1 R; \" s       (e.g., DOS FDISK, OS/2 FDISK)
8 [* n) K3 h. z    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)6 W7 c* ]$ e* R8 V# G
    Command (m for help): p
: r. @# h2 p$ o# k  j    Disk /dev/hda: 4294 MB, 4294967296 bytes; T1 O) U5 l# M$ F! u; S2 m- R
    16 heads, 63 sectors/track, 8322 cylinders! F) @, q2 b0 m( k
    Units = cylinders of 1008 * 512 = 516096 bytes
) {" Y# q4 B) ^( k$ X& t       Device Boot    Start       End    Blocks   Id  System1 ?* X: [1 }! C  [
    Command (m for help): m
" \; a8 N* E3 K" v0 L2 n& b    Command action1 |+ s# E% l5 N6 r: [, }
       a   toggle a bootable flag9 T( {$ r- w7 @. ]/ b
       b   edit bsd disklabel0 E8 `( [0 T: C1 {. V
       c   toggle the dos compatibility flag
* Y, H; e7 G2 q+ I5 `       d   delete a partition
0 x9 f$ D: i/ ^  s       l   list known partition types
" F* E9 l" z/ J5 I) t/ i       m   print this menu
  A$ [4 h  G+ Q       n   add a new partition! ~2 M2 O3 y$ v  {) h
       o   create a new empty DOS partition table) p7 b( ^' a  n4 A6 v0 I
       p   print the partition table$ c* G9 Z, g6 }* A
       q   quit without saving changes
4 S2 E3 Y1 E$ Q8 j       s   create a new empty Sun disklabel
& |5 d6 C  t; L2 d8 ]: s) o       t   change a partition's system id# F1 @4 v$ ?# A2 U0 u
       u   change display/entry units4 @2 h9 y/ H" O3 V: f
       v   verify the partition table" V+ N% W$ I# L' a, d
       w   write table to disk and exit- V1 ^2 f) L$ m1 M. ^* ~2 G% B
       x   extra functionality (experts only)+ q2 P$ p& ?. ]# M% \7 e
    Command (m for help): n
0 {6 R0 g0 @- F4 Y8 N    Command action
+ J! a  l1 _2 S) R       e   extended
$ w2 u* ?2 l" ^1 ?7 X0 X       p   primary partition (1-4)
: U- M! A9 z! Y3 C6 f5 H    p# N; ~) M+ L0 w; S
    Partition number (1-4): 1
% S+ U7 B! F; L% l    First cylinder (1-8322, default 1):
* ^& N7 v, y' o1 ^) W7 p. e    Using default value 1
/ p+ c% f" T, C3 D0 Y; T; c: a    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
' @/ x! c9 C' F/ a+ x. |0 f. A. A. ^    Command (m for help): p' _' n3 T9 L5 {6 r- D5 W0 J1 j
    Disk /dev/hda: 4294 MB, 4294967296 bytes9 R# R: X0 ?" J: [5 U/ |
    16 heads, 63 sectors/track, 8322 cylinders
9 b# S/ x0 L5 o% W    Units = cylinders of 1008 * 512 = 516096 bytes8 Z7 r9 G( g, [
       Device Boot    Start       End    Blocks   Id  System6 |/ @* ?5 {/ j; c9 t
    /dev/hda1             1      1000    503968+  83  Linux
) h' c. B9 N- o4 \5 Y& h    Command (m for help): w, J9 M$ P! G8 c& m0 q) `3 g3 r" G% m
    The partition table has been altered!
) a: z' F8 G. S  l: \: S    Calling ioctl() to re-read partition table.
( ^( T. x/ S) w' H& d    Syncing disks.
' \" t. z9 r6 t4 }    //格式化新分区
4 N  _9 `" r5 S/ |- q6 ]) n
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
  W4 }( o! H9 j+ j) u    Filesystem label=
" `* \, N+ T' e    OS type: Linux% v, f" D  K1 A
    Block size=1024 (log=0)
+ M8 U! B  c; c# w1 f    Fragment size=1024 (log=0)
8 }' w7 i, t" W1 ^: D/ t    126480 inodes, 503968 blocks
3 X1 f0 K' e! H. c! Y* U    25198 blocks (5.00%) reserved for the super user% b: E. R1 H, q; ~# L
    First data block=1
" N8 m$ N$ ^( O$ {0 O9 G- t" a    62 block groups
, z3 R! ^+ i' z2 f    8192 blocks per group, 8192 fragments per group
5 B' X/ b; I/ g. u" Z& g( {- q9 n    2040 inodes per group
7 Q( c. P# p7 O    Superblock backups stored on blocks: 5 K1 j5 A* B* n% r. L9 O2 u
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
0 B9 _5 W/ B, z' F! r& L    Writing inode tables: done                            ' r) m, I7 s8 ^
    Creating journal (8192 blocks): done
+ [  I/ D. G+ `9 H    Writing superblocks and filesystem accounting information: done: }6 x7 }  {# H3 x
    This filesystem will be automatically checked every 30 mounts or
0 t% m- F/ S2 I+ ]/ D    180 days, whichever comes first.  Use tune2fs -c or -i to override.; S+ K. B& b7 I1 V& V% I/ B
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
4 }3 N- }$ b% _" A) E1 _' V    /dev/sda3              3723848    705992   2828692  20% /
6 y, f5 l, u& S% ?# }; A1 m" x/ \7 b    /dev/sda1               101089      9274     86596  10% /boot
! L: I3 e# F0 g& Q) o! W* [! W    none                     14520         0     14520   0% /dev/shm
# j/ N! G5 O. x) w$ m; Q    //挂上新分区
7 y3 l% E) r4 p1 V$ t
  1. mount /dev/hda1 /home2 C3 l  }% p0 }
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
* [1 R+ ]" X% F$ T0 ~7 E& Z( @8 J" n    /dev/sda3              3723848    705992   2828692  20% /
' L, ~- u* }. t1 {6 X( D9 b    /dev/sda1               101089      9274     86596  10% /boot! G" T5 r, o' s2 `7 ]4 ^
    none                     14520         0     14520   0% /dev/shm6 a+ ?7 ~' F( f* S
    /dev/hda1               488006      8239    454569   2% /home
: j) a6 {- F5 ^6 K  R' ]7 x, v. E0 k. B6 z
自动挂载:. }$ V7 ?9 D% u/ W# R4 _/ ?* k; x
  1.           vi /etc/fstab4 B4 H; ^1 a2 E" m4 j

  2. 7 n* Y5 `' N, G
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0. H6 x2 p" a( t; M4 c0 w: [) ]$ G
  4. / v  B# D8 _. z( a
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
/ i1 n$ D) A- x9 c3 n
  1.           mount /dev/sdb5 /mnt/ljp1: o, F0 h; \2 g

  2. 2 U! R5 D! `6 Y# g  `
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
( ]7 A1 O# N; o2 w2 C2 B

" J* u9 H# e4 z# O& V( ~  \+ g7 c
. h! Q) @2 `8 c5 }. s; n5 f
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-21 17:34 , Processed in 0.013855 second(s), 6 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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