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

 找回密码
 立即注册
查看: 2550|回复: 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)4 u: @& A7 \3 ?$ F0 J4 ~& L
      or: fdisk /dev/sdc  (for the third SCSI disk)( p8 t& J7 c: Y+ I
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
6 ?1 h. B5 d2 M/ \8 Q      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)7 M9 x3 i2 P& ?1 _$ F& n
      ...; [( F( T2 A1 _: V% m  H$ t
  1. df -k
    8 ^. g, I" u4 W, f) \% e, Z
  2. df -lh  a; \& V& H2 {
  3. 查看有几块硬盘:fdisk -l
    5 k, @2 E2 D9 o8 G& `0 r
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
3 W- e, O6 ^# D    /dev/sda3              3723848    705968   2828716  20% /9 K# |( M( ?& R# ^' w+ r
    /dev/sda1               101089      9274     86596  10% /boot. o2 a& A# R7 z% f  N$ M
    none                     14520         0     14520   0% /dev/shm
" |. w; {9 N) S3 \    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用2 K5 H4 M# R$ }3 d5 G
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel# q( h% e0 |* S/ _" `
    Building a new DOS disklabel. Changes will remain in memory only,/ q* r/ L8 [, A$ d/ }
    until you decide to write them. After that, of course, the previous
; i6 X, Z3 K" E  J$ t" s- w    content won't be recoverable.
$ G. W0 f& s0 \) `    The number of cylinders for this disk is set to 8322./ A. c7 r. z7 M3 z
    There is nothing wrong with that, but this is larger than 1024,. C/ K* _: |% ], i: }! i9 {
    and could in certain setups cause problems with:  ?' b, T8 u/ a5 `% U# R% t' S6 h
    1) software that runs at boot time (e.g., old versions of LILO)" `" a1 ~- M6 j; ]+ l4 i$ C
    2) booting and partitioning software from other OSs
0 `. g' Z; j! z' j  p- o6 }0 G; j       (e.g., DOS FDISK, OS/2 FDISK)
  E) d. q& c; h  k: l    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)6 ^  T! i3 F3 L; {7 f2 b
    Command (m for help): p9 z% |% ~7 z: Z
    Disk /dev/hda: 4294 MB, 4294967296 bytes
0 x3 u9 U( h, y0 F    16 heads, 63 sectors/track, 8322 cylinders; Q9 B: B0 E( w' P, j3 D; P3 a
    Units = cylinders of 1008 * 512 = 516096 bytes3 x- R# R; y- h0 e0 O0 a
       Device Boot    Start       End    Blocks   Id  System/ K/ _$ Z* ]/ T4 L
    Command (m for help): m
5 U2 O; ~2 d. J3 ]    Command action
  ~7 [( u6 t; S& {       a   toggle a bootable flag
" ?0 i: [$ Z9 a0 D4 V% i       b   edit bsd disklabel
$ x0 |2 g$ V# O! \       c   toggle the dos compatibility flag
; D9 \3 c1 Y' a9 m3 N1 g6 L* O       d   delete a partition; g, l+ q; v- {# U; D* g
       l   list known partition types
$ ?% j4 S* V: Q/ B       m   print this menu7 o2 W) ?8 A: I! \
       n   add a new partition
8 r, D# ]7 B% _  r$ X. J       o   create a new empty DOS partition table8 ]( n8 x. I* Q/ O$ ~
       p   print the partition table
: ~& g% Z  }& b0 O6 m       q   quit without saving changes
; {; A/ x5 w4 _3 v: I2 I; ^- x- i       s   create a new empty Sun disklabel
0 H0 m) z) g9 d* ?4 z; [! j       t   change a partition's system id
( w! b0 S; C0 f3 T9 }& `/ h       u   change display/entry units
( o: z6 \4 a+ W. b, U& N       v   verify the partition table
$ [7 t' K& \2 w8 ^& ]       w   write table to disk and exit& |1 C+ A, V8 B+ `% I8 h+ \
       x   extra functionality (experts only)
/ L% U* i8 k1 L2 I9 v: o    Command (m for help): n6 l) @( L: B' W2 ]( S
    Command action; H, _  F; ^; d% x6 M' d9 E
       e   extended. Y- p  @4 Q1 R4 O, [! S. n
       p   primary partition (1-4)
3 E& h2 s& o% L, l7 ?    p
/ F! ?5 ]- B% [! Q* v    Partition number (1-4): 1' L% M2 [! `5 r; X
    First cylinder (1-8322, default 1): 1 L0 v  P6 m& N: O# R
    Using default value 12 l5 x. b1 L  s1 ]9 L+ s( p
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
/ \9 i. j% C# g8 T    Command (m for help): p. v3 U6 ^6 I5 Q5 T. L. n- I
    Disk /dev/hda: 4294 MB, 4294967296 bytes
4 L9 u  t: e( s) j$ W, s5 e    16 heads, 63 sectors/track, 8322 cylinders
( g7 p& `' e' A* g    Units = cylinders of 1008 * 512 = 516096 bytes8 R+ x* L) I% l! e; W4 M- M/ B# w
       Device Boot    Start       End    Blocks   Id  System1 ]- a/ n# R; o2 d3 l4 ?2 x# F" y3 B
    /dev/hda1             1      1000    503968+  83  Linux
- N  @, d4 W1 v    Command (m for help): w
' u$ p: U9 W7 V    The partition table has been altered!5 t. c6 B/ \. J' h! g
    Calling ioctl() to re-read partition table.
$ u+ |, ?( D- P( L    Syncing disks.  d! |" a7 R/ h
    //格式化新分区: D4 |7 I1 U1 q. M  S/ m0 r
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)( x* `3 p$ D' ~+ l3 b
    Filesystem label=3 @, ~! E9 K$ c: R# y' a: l
    OS type: Linux
4 O" G3 g, a/ p$ ^    Block size=1024 (log=0)
! x) I* t, k; o' c    Fragment size=1024 (log=0)% X: w8 S$ Y6 |. h
    126480 inodes, 503968 blocks
2 `1 L2 }7 r( a  O& M    25198 blocks (5.00%) reserved for the super user
, k6 t$ c( o( M# X6 _    First data block=1+ F" a5 _9 A6 [) m# K0 e# l
    62 block groups
) H* z) a, t1 o. M& `    8192 blocks per group, 8192 fragments per group5 p9 R9 j- U2 ^0 Y1 m7 E' u
    2040 inodes per group
7 T7 n% }$ L# A% X2 r6 w$ @; P% N    Superblock backups stored on blocks:
- b' o$ U; K6 Z" k% n            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
/ j) C9 x0 D# u# J. z, G# O    Writing inode tables: done                           
9 n/ N  [; L9 i* }' O3 i+ N    Creating journal (8192 blocks): done
+ h, t6 C% `/ `6 O/ A    Writing superblocks and filesystem accounting information: done
  d7 t- _, y1 B    This filesystem will be automatically checked every 30 mounts or+ {% {, O; [! S; `
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
5 K0 a& l: P; j6 j6 U' q
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
+ z% j/ @1 b& ]0 i" R. w1 J    /dev/sda3              3723848    705992   2828692  20% /
6 p5 q- n3 k: p- X5 X) H    /dev/sda1               101089      9274     86596  10% /boot. u1 ]1 K7 M; T3 K4 r6 [$ o3 M% H: K
    none                     14520         0     14520   0% /dev/shm
% c& C" U. Q5 Z( J) M1 X/ L& j    //挂上新分区5 g  M8 q6 s+ J% b1 M4 O. J
  1. mount /dev/hda1 /home7 T! s/ B& y" ?" _
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点8 R9 d) N, V! I/ n" ^
    /dev/sda3              3723848    705992   2828692  20% /2 x6 F% v4 G- H/ G
    /dev/sda1               101089      9274     86596  10% /boot
5 V9 b$ _2 v$ O8 z+ A- |( w8 C    none                     14520         0     14520   0% /dev/shm5 E) ^% [/ b5 _& G+ W4 B- w# u1 z5 _
    /dev/hda1               488006      8239    454569   2% /home- V' ~0 J/ U# G$ p. X4 S
7 |# \; V5 Y, M7 `; s
自动挂载:% X) Z7 Y' M& W2 x2 {
  1.           vi /etc/fstab
    / q& X1 o9 P" C! ]9 i

  2. # J& N% S! B+ A; P! O
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0! b% r2 C, X/ B0 R7 K+ @0 K

  4. ' t' j9 `, h& C8 E
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:  N' L5 }' _% C2 }( r
  1.           mount /dev/sdb5 /mnt/ljp1. N+ J4 O7 X; G" R3 q) ~3 M% X0 `7 H

  2. ) I& c: T( L6 A1 L' R; e7 n  i$ n
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

2 h# k1 r- b0 a1 e
- v  v  a( S: ?
6 J8 q7 U+ {$ ~0 Z
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-8 18:04 , Processed in 0.032974 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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