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

 找回密码
 立即注册
查看: 2599|回复: 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)
+ X: l- q$ ?: ~( ^; G( x4 y3 p      or: fdisk /dev/sdc  (for the third SCSI disk). S" a, J: a" ?. b8 J. T/ s2 k
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
( y( W# k# k$ G7 O# F, P      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)& Z7 M: p7 H3 B% v; i* x4 K1 [
      ...
" A6 D* \- U: s
  1. df -k5 F, d& X2 Q) d- ^9 }3 j2 X4 e" B
  2. df -lh1 L6 R& O/ e& W+ Y
  3. 查看有几块硬盘:fdisk -l
    - s& w& a+ H' @; H( J
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
$ q" D  M+ Y2 v1 B* K    /dev/sda3              3723848    705968   2828716  20% /
2 e6 i' k" S5 |+ R: V$ w    /dev/sda1               101089      9274     86596  10% /boot" O+ g! a* s  v' f) p6 V! |
    none                     14520         0     14520   0% /dev/shm6 h+ ]! |, [$ s* U/ L# `2 G
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用" I) x  B9 p# c' K* s
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel/ Z& \$ t; q: u  Z" S" L2 l
    Building a new DOS disklabel. Changes will remain in memory only,
0 ], t% X: t! t* `( n; N4 f    until you decide to write them. After that, of course, the previous
3 O! t$ v9 c& G+ N9 s- p- a    content won't be recoverable.
$ X! ~8 N/ f4 Z" r" Q9 ]( E1 d; P( Z    The number of cylinders for this disk is set to 8322.2 w6 H0 G2 {1 @) o2 n
    There is nothing wrong with that, but this is larger than 1024,
0 e  [' B& y) I. I; u5 p) U9 d/ Y    and could in certain setups cause problems with:) d  F+ W8 i5 Y$ g; a8 a
    1) software that runs at boot time (e.g., old versions of LILO)
) C$ s& A+ B1 t; x    2) booting and partitioning software from other OSs" |  A+ Y6 [3 R
       (e.g., DOS FDISK, OS/2 FDISK)
8 I) D: Q3 u5 r& q" V    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)( F) S- y! `( `8 j! J
    Command (m for help): p$ x5 ^$ v  m4 D9 ^/ C% O
    Disk /dev/hda: 4294 MB, 4294967296 bytes4 L9 o# D" e; W* O6 a! K) ]) Y" A
    16 heads, 63 sectors/track, 8322 cylinders
5 b) {# t; I/ G- O( W) Q    Units = cylinders of 1008 * 512 = 516096 bytes: [5 P# `  I+ }+ O  {- v
       Device Boot    Start       End    Blocks   Id  System# P4 `( J) M/ x, e
    Command (m for help): m
' t+ d: V* W  _7 e    Command action
2 l3 N  ?: ~4 w* f       a   toggle a bootable flag# v: `& s( R% `! ~0 Q, M
       b   edit bsd disklabel
& }1 M4 H* p5 y* S$ s       c   toggle the dos compatibility flag: x' @! K7 c: v- S  b6 x
       d   delete a partition
. p* i+ n+ z( b; P       l   list known partition types# m  o( j5 Z' Z( `+ o: H1 ~3 L& ^* O
       m   print this menu
. x  B1 p. s# _9 r       n   add a new partition  X3 D$ F/ b& E. X, m$ y1 w
       o   create a new empty DOS partition table
4 \9 Y6 i; |$ P3 T: o       p   print the partition table3 |" i. I' s7 P* @+ [: \  J
       q   quit without saving changes' m& f2 v: ~% ?
       s   create a new empty Sun disklabel
, O  ]; O: r9 v2 L       t   change a partition's system id
8 E1 x- P, P3 J  Z6 B# b1 r- H       u   change display/entry units
; b6 R, N6 t- N4 L5 f, e       v   verify the partition table
, H* g9 ^# m$ G9 R       w   write table to disk and exit
' T  ?  y8 Y3 c8 f/ s. P3 G- i       x   extra functionality (experts only). b( q7 F8 A# k6 I
    Command (m for help): n
! ], U! Q: S5 [! e. G( o% H$ m  ~    Command action' E0 s, x! U6 _
       e   extended9 n5 `+ b" R$ f( R8 B
       p   primary partition (1-4)1 J3 d' {. P7 \. Z+ t/ q; h
    p  p" q- M- i7 o0 M
    Partition number (1-4): 1- x# u1 I7 ~6 u- t2 C
    First cylinder (1-8322, default 1):
4 }+ q4 B2 t1 ?5 m- E5 ]5 ~    Using default value 1
' ~) Y5 p2 y! _2 R8 p: t/ Y    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G, X+ i  g0 H% n' c5 l& U! O
    Command (m for help): p
- Z: X2 y7 v4 \( _& z0 r    Disk /dev/hda: 4294 MB, 4294967296 bytes
! |7 R3 h/ r) S/ i    16 heads, 63 sectors/track, 8322 cylinders
* {  _  e; v' ~    Units = cylinders of 1008 * 512 = 516096 bytes
9 D& r  a1 P; z. V9 G1 |% K       Device Boot    Start       End    Blocks   Id  System
3 J1 x* N  t7 `/ K" ~    /dev/hda1             1      1000    503968+  83  Linux; k4 b9 k4 Y: `- H# ~8 O
    Command (m for help): w+ M! r6 A  ?1 o1 `
    The partition table has been altered!$ q( K" B; t6 V
    Calling ioctl() to re-read partition table.
! }- V# q( C  z! C7 [3 ^: ~4 Q    Syncing disks.; j+ q, f( v4 I) X. H
    //格式化新分区
* ~7 ^% ^3 P, t( R- O# [
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)0 H& u( S: O% S; _: w# [* {* F9 W
    Filesystem label=# p( o1 s. d- e
    OS type: Linux
+ h9 Z% D, ]3 f- U) J    Block size=1024 (log=0), X% P, Y. C+ A! B) c5 |
    Fragment size=1024 (log=0)! W- R( D/ D- W: ~7 ~; ?. g1 K
    126480 inodes, 503968 blocks% F7 P  `0 i3 R* t0 F! A
    25198 blocks (5.00%) reserved for the super user8 _- w+ f1 _" o, }
    First data block=1
, q' O# t) ~' f# H2 Z; b! g    62 block groups
, W$ i7 k9 @' Z8 M& W    8192 blocks per group, 8192 fragments per group
9 D1 j5 V. J  E: K0 [    2040 inodes per group/ T& D1 F- P5 I8 N; K! |# P
    Superblock backups stored on blocks: # H2 X# t& U3 j6 T, K. H, l  [2 y$ p2 m
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014090 i+ B. E1 ]& e& ?2 `, Z
    Writing inode tables: done                           
* h3 s! p0 E9 T6 v1 p& A    Creating journal (8192 blocks): done
5 J2 u6 S6 w! |: m$ \% u    Writing superblocks and filesystem accounting information: done- h/ A/ [, A% c) Q( U0 ~
    This filesystem will be automatically checked every 30 mounts or' R3 ?* n1 S- d# G3 d; R0 A. f2 ^3 F
    180 days, whichever comes first.  Use tune2fs -c or -i to override.  C. y- w! C3 |0 \9 L; L
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
; t7 |+ Y9 A, M% ]1 u( |    /dev/sda3              3723848    705992   2828692  20% /
* f6 y5 `; |; w; F; ]    /dev/sda1               101089      9274     86596  10% /boot. z" v+ x2 G8 _1 w
    none                     14520         0     14520   0% /dev/shm1 i  l+ x! e8 [! Z) A! {  T
    //挂上新分区5 [9 |, P6 K4 x  L/ x1 ~! z( a
  1. mount /dev/hda1 /home
    9 h& ^" o6 w" c3 @$ {0 d  Q6 `
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
+ {: K7 z6 k, A* L4 V/ \5 p: i    /dev/sda3              3723848    705992   2828692  20% /
1 F* C* Z( C: g+ v    /dev/sda1               101089      9274     86596  10% /boot
! s6 u4 v: z' @& H+ E! r    none                     14520         0     14520   0% /dev/shm& K, @8 z! I0 `
    /dev/hda1               488006      8239    454569   2% /home
4 Q) i* Q2 V. ^4 f: b! g5 l" [- q' x7 J+ I
自动挂载:
5 V* i, d. u( p3 y. l3 @
  1.           vi /etc/fstab
    ; q( c; i6 J4 j: q" i
  2. ) Y" S  s* h& }, t1 _5 d" W, f
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    8 J' s2 K% ?# e1 a# ?0 Z. ?
  4. $ a8 ?/ d% F4 U9 }2 b% F6 e
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:4 ]$ y: x0 \" m2 K  H6 n
  1.           mount /dev/sdb5 /mnt/ljp1
    $ k" n- i4 e0 C3 i. W& _% e

  2. 5 o" @+ y. N& }' t
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
% J. Y0 H2 Q' |2 I
5 M. l/ X8 @$ L/ V

1 F& C7 a0 |$ G  t! [- V( G
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-26 18:03 , Processed in 0.010881 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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