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

 找回密码
 立即注册
查看: 2638|回复: 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)" }; J3 `* `% x/ [+ q, h  ^
      or: fdisk /dev/sdc  (for the third SCSI disk)
& ]% b/ f$ }' B  A% g3 W3 c      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
5 ~! f, d) h" R; \2 L0 }$ n4 v8 d      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)! I: N4 q# @% u9 V$ [
      ..." X9 u3 h& K  w
  1. df -k
    : b5 B' C- W9 N3 w, y
  2. df -lh" ~3 v6 L5 y* g! t: j3 V
  3. 查看有几块硬盘:fdisk -l2 M+ N' W& I8 f+ n
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
& A5 g0 z. l( l+ ~6 Y( l    /dev/sda3              3723848    705968   2828716  20% /# ?% Q6 \; T# I0 i$ a
    /dev/sda1               101089      9274     86596  10% /boot9 X2 f1 w/ g7 [# ^1 j9 N6 W: `& l
    none                     14520         0     14520   0% /dev/shm
# S" ?2 U6 o, q& ]4 L6 c    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用* H( j' `$ }: x8 u
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel$ t$ {  A+ n3 n5 }, g9 Z7 ~
    Building a new DOS disklabel. Changes will remain in memory only,) C7 t# S$ ~2 q
    until you decide to write them. After that, of course, the previous
2 ]) x2 |; g; D    content won't be recoverable.) W8 M( k8 u8 f
    The number of cylinders for this disk is set to 8322.
4 e+ O, c1 S! J    There is nothing wrong with that, but this is larger than 1024,
4 U% X0 [4 q) t! L8 Y7 C3 b: N    and could in certain setups cause problems with:
9 p4 ^5 C% K" m% C, w    1) software that runs at boot time (e.g., old versions of LILO)# s3 X/ O% ]- R% ?  b; m1 M+ j
    2) booting and partitioning software from other OSs
+ p! N; ]; u6 \, ~. b' E( [       (e.g., DOS FDISK, OS/2 FDISK)2 V1 M6 x: O5 z2 c6 c
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
) n+ J8 C/ a! }/ H3 F8 v: n+ Z6 X    Command (m for help): p
! }4 \* m1 u0 O8 S. b; o( J    Disk /dev/hda: 4294 MB, 4294967296 bytes( `- K5 E- [0 t& y" k
    16 heads, 63 sectors/track, 8322 cylinders8 {# i  l8 ?& z' F
    Units = cylinders of 1008 * 512 = 516096 bytes; [, N& \0 Y$ t; V* G
       Device Boot    Start       End    Blocks   Id  System5 [' ]" P8 a/ ^
    Command (m for help): m
3 s& y' w+ u7 L    Command action" X, F3 y2 H: E6 x* W
       a   toggle a bootable flag0 p, N+ q1 N5 B* r4 ]& V' O
       b   edit bsd disklabel
) V; M' E2 V3 u" q0 k/ b- _       c   toggle the dos compatibility flag6 x5 g/ h7 j" W+ h
       d   delete a partition" y% V, o% s# U
       l   list known partition types% L' Q/ r7 p' g! h$ M3 o# `1 X
       m   print this menu2 D! q1 p$ d4 e$ V9 v; ?( p
       n   add a new partition
1 p: a9 W8 K( i$ x' t9 A       o   create a new empty DOS partition table
, O( N0 b) {) B7 v* j       p   print the partition table
7 d2 a# k* R3 ~! ^& W: ^+ P       q   quit without saving changes
% U4 q/ z; q+ ^& P; K1 r       s   create a new empty Sun disklabel& t' j( d# A$ g. x$ v" [2 }
       t   change a partition's system id) N. G6 m+ X; E+ D
       u   change display/entry units) v) X, l) ]& w) T
       v   verify the partition table
' G$ W& w$ m. T% R  U2 u! n/ I       w   write table to disk and exit# z! M) E; n& k0 C; t6 J
       x   extra functionality (experts only)
& A) Y6 D6 t/ _/ V2 p* q    Command (m for help): n
9 }0 @  `6 t- C! m6 E    Command action
4 T+ q2 Q) H) ?+ P# B/ c       e   extended
/ J; V; T0 c* f) s% }. I  {       p   primary partition (1-4)5 d( Q/ ~3 f2 ^1 B2 V
    p; B- Q4 J% _5 X" [' e+ ?* i
    Partition number (1-4): 1
1 |8 ^) O: K1 \) T    First cylinder (1-8322, default 1):
) y5 e& D: E# W2 m& [    Using default value 1+ {2 U+ j6 Y) g. {  M2 {
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G& j5 \$ u. k' q7 V  C, H
    Command (m for help): p! E9 t: ^  U# N4 S7 a; d- v/ ]0 {
    Disk /dev/hda: 4294 MB, 4294967296 bytes
/ R: w. E: d: q$ x( ~    16 heads, 63 sectors/track, 8322 cylinders; Z0 P! K( z; y4 n
    Units = cylinders of 1008 * 512 = 516096 bytes
: i9 X) d2 [5 z/ \! y" h  w- r0 k       Device Boot    Start       End    Blocks   Id  System4 w8 J# D  ]* g' w% X/ G- B' i
    /dev/hda1             1      1000    503968+  83  Linux& C) }; ^* d$ G& m! I
    Command (m for help): w# j9 C6 x& Z9 P( X
    The partition table has been altered!
0 d, P+ e5 X/ m    Calling ioctl() to re-read partition table.  T5 g1 m* A  Y/ {, M
    Syncing disks.- m1 s5 h+ N. x2 B" j  w6 u
    //格式化新分区9 J: B4 R+ X  ^# @
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
0 e4 V0 X3 M" `' k* Y. b: _    Filesystem label=
% A3 A( w, Q0 B, L    OS type: Linux% E1 Q/ }' b/ c- K( ~' W0 L% l' Z
    Block size=1024 (log=0)- }- f" L: a/ b" c
    Fragment size=1024 (log=0)
, T* a# O( O5 k+ H    126480 inodes, 503968 blocks3 C5 I9 u8 [3 M, ~# j  i/ l
    25198 blocks (5.00%) reserved for the super user. H# I& r( y/ x: f) O: ~/ S) J
    First data block=1
; F0 [3 L& u' I  t( I    62 block groups9 a) z; S# i' H" a2 n& g
    8192 blocks per group, 8192 fragments per group  S! D$ R1 D# M1 z$ p* V7 P
    2040 inodes per group% y; Q7 B6 ^- C; \8 F& J& F: e
    Superblock backups stored on blocks:
: N- C5 T; D' p7 r% o0 o            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014099 Y1 @- |1 F: R! S# D. c
    Writing inode tables: done                           
. b" m( U8 q7 e0 J" ]6 W( J3 s" i    Creating journal (8192 blocks): done
' P& w9 t% d* {    Writing superblocks and filesystem accounting information: done
& A$ o2 Q6 d2 }- `+ M  g7 J    This filesystem will be automatically checked every 30 mounts or6 A7 `% \! ]5 q3 h7 D% M
    180 days, whichever comes first.  Use tune2fs -c or -i to override.$ [2 l. Q: B* S1 j, @
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
) U' @, ?2 O1 C/ j0 w1 ^/ `. \3 [    /dev/sda3              3723848    705992   2828692  20% /6 [2 \: @  `) }: Q! Q
    /dev/sda1               101089      9274     86596  10% /boot
) m% C: n- j9 C    none                     14520         0     14520   0% /dev/shm6 S( v5 o4 C: ]- {; w
    //挂上新分区- ]; `1 G, Y1 O5 x$ [2 _
  1. mount /dev/hda1 /home
    1 h1 |' _& X0 s2 l3 H% I' M
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点' `4 U, T/ g5 V. H; h0 E( q
    /dev/sda3              3723848    705992   2828692  20% /' f- j, L) n3 v. u: [2 d% T  V) Y1 K
    /dev/sda1               101089      9274     86596  10% /boot) n/ B9 U/ Z& d/ n0 }/ S, I
    none                     14520         0     14520   0% /dev/shm- J- i* {& G: H
    /dev/hda1               488006      8239    454569   2% /home' G3 P) F! t- z2 ?* A7 j
' d+ ^+ J$ I" r  V% Z. B  o8 U  C
自动挂载:
. c. `% v9 \, c
  1.           vi /etc/fstab) c4 B& q" e0 g$ L; ^3 G

  2. 0 P1 O) w. i4 a% \' J
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    3 T( u' K0 C# t  B7 W  s$ n
  4. 6 Y) }7 B- L- b: c8 u+ m
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
+ p( {. {2 ?& H/ u% ^+ W- d
  1.           mount /dev/sdb5 /mnt/ljp1
    & y* l$ Z! P  E! H% y" W( H8 U

  2. : r% J! i5 N2 m+ [6 t* O: I
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

- o- s4 Y# e6 V: a4 t
( G" Y" y$ C' x. t. T
5 R: C6 K, d" `3 r0 S/ z
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-5 00:19 , Processed in 0.036941 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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