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

 找回密码
 立即注册
查看: 2219|回复: 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)
0 {: T* V: {0 N9 F4 k      or: fdisk /dev/sdc  (for the third SCSI disk)
0 S7 [' l3 o6 F$ l7 ^! }8 u      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)9 ~* M% b( Y# L$ C8 b" U2 o6 z  o
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
0 l+ z" o8 m4 q+ C- I, |5 [      ...
9 x7 ^: O3 P8 W; B) Q1 N; c2 _
  1. df -k( P0 x# o9 X5 `; c+ U
  2. df -lh1 n1 g! X9 ^' I5 O9 R' x
  3. 查看有几块硬盘:fdisk -l
    ) N: I$ ]" [3 a; C+ q- p- O
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点8 O' m3 y: Z4 z( j
    /dev/sda3              3723848    705968   2828716  20% // H5 A) O/ O" T1 h3 m9 i9 v
    /dev/sda1               101089      9274     86596  10% /boot
1 X: ^$ P, z( g9 m    none                     14520         0     14520   0% /dev/shm
/ X+ W! _* j! H4 x5 I    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用) W4 N4 n+ z4 I$ U+ @( O
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
0 ]7 e* H. @# j* H% `- ]" z8 A    Building a new DOS disklabel. Changes will remain in memory only,1 R& U. [9 s) q0 ^. d: l  C: F
    until you decide to write them. After that, of course, the previous
" h. X' @7 d& m' [! \    content won't be recoverable.+ ?+ `( k0 J6 t  {; R9 S
    The number of cylinders for this disk is set to 8322.
+ N# H) E7 @5 _$ C! q1 U- B    There is nothing wrong with that, but this is larger than 1024,
; W' e, A& V/ q# a4 T; t& O    and could in certain setups cause problems with:7 M" v' F7 d" d" F" w7 i
    1) software that runs at boot time (e.g., old versions of LILO)
, d. m" l0 G0 e; v! E( e    2) booting and partitioning software from other OSs0 X( _2 m8 l$ |/ ^- G7 i
       (e.g., DOS FDISK, OS/2 FDISK)
  n3 [5 z4 \0 @% C4 m    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)" E9 m' i5 D# H! @4 o
    Command (m for help): p; m7 c/ e$ A" M% l% q
    Disk /dev/hda: 4294 MB, 4294967296 bytes
2 A/ B  T) ^5 S: T! }" |; q' ?0 `    16 heads, 63 sectors/track, 8322 cylinders/ d' z  o3 Z  @9 X! {; B( g( w6 m
    Units = cylinders of 1008 * 512 = 516096 bytes
0 a" e6 I6 }5 d# v2 F" L) j6 [       Device Boot    Start       End    Blocks   Id  System6 Y% i5 a9 L( n8 O/ }/ I
    Command (m for help): m0 `3 x- }6 R. d4 h
    Command action4 \3 Q  _# [! x. a+ z% a
       a   toggle a bootable flag% H  y% g& r; {5 t
       b   edit bsd disklabel6 i  y8 |1 ?, j9 T* z( n9 k  j
       c   toggle the dos compatibility flag- g2 U' y. u. m- R8 o
       d   delete a partition# o& N2 M' A$ S9 p( |
       l   list known partition types) a0 j7 s+ d) h# v1 n0 W
       m   print this menu7 z$ R: y$ |8 y& o! K1 @" Z0 b
       n   add a new partition. d2 |$ L3 A. L: m5 X
       o   create a new empty DOS partition table
$ c- }/ S7 D& [$ |4 q9 e$ {6 P       p   print the partition table2 W" \2 V, h6 S
       q   quit without saving changes
* Q4 Q. s* A, Z' F3 |; ~" q& {       s   create a new empty Sun disklabel
0 k+ A/ A7 h  Q1 ^       t   change a partition's system id
. n8 t" P8 Z6 g* ~, |+ Z5 Z       u   change display/entry units
5 R) I6 `7 B- d: G       v   verify the partition table
* u* S* O! Y# a. K1 x; T2 u2 d. l       w   write table to disk and exit
/ q+ d1 ^3 l* J! }       x   extra functionality (experts only)2 j- a* l8 G+ g6 Z
    Command (m for help): n
. J( y( m' a: r9 e/ s8 q    Command action$ |- |+ e- O) N" m% F
       e   extended
% k/ k! C. X0 n. i; t) U8 Y       p   primary partition (1-4)& e' R& r: r- @; `6 o4 a
    p& q* c' y- ~% H3 }" B
    Partition number (1-4): 1. |  k8 q# Q6 H" H8 s
    First cylinder (1-8322, default 1):
- y6 b( }4 F. W9 M    Using default value 1: }6 V2 J8 q8 ^- Z& r1 g
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
( ]; K  c" }) s" h$ N& {7 @2 R    Command (m for help): p
  j7 h. ~) b: X    Disk /dev/hda: 4294 MB, 4294967296 bytes# h/ o  A1 e0 Z% ~: L
    16 heads, 63 sectors/track, 8322 cylinders
" T  x3 n; n8 `1 l+ ~    Units = cylinders of 1008 * 512 = 516096 bytes0 _; }* @+ R* F1 I- e. k
       Device Boot    Start       End    Blocks   Id  System6 Z/ V9 v) y+ F/ u4 P
    /dev/hda1             1      1000    503968+  83  Linux
. N4 U6 q- N+ E3 z; w4 a    Command (m for help): w
) t2 ]7 h$ ?2 U9 W    The partition table has been altered!
' N' T+ q/ R4 m  @6 W5 Z0 g( v3 H    Calling ioctl() to re-read partition table.8 m; H( G" c4 Q$ ]% I/ _! c
    Syncing disks.3 n, [) U; D. p. h; M) {- S8 P
    //格式化新分区# j  U: @. P$ W5 y: D- W# `
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)2 U' P* W# Z% j0 J* e. b
    Filesystem label=
, O" _# @2 _# G- L* J1 z    OS type: Linux- Q5 r' `3 K% @0 S' K8 O9 L
    Block size=1024 (log=0)/ ?4 t8 X: K% y6 k+ p+ e$ m
    Fragment size=1024 (log=0)& `% Q# R) z/ L, `  f2 h( a
    126480 inodes, 503968 blocks& H& A) ?2 r3 {  _+ o
    25198 blocks (5.00%) reserved for the super user
- H( h5 v- D' S    First data block=1; m1 v( M% q: J8 n, Q% ^# H
    62 block groups
+ l% l$ q7 D$ b( z. k: c% A    8192 blocks per group, 8192 fragments per group: y1 B( d* b* p6 Y. ?1 H1 D
    2040 inodes per group8 Z8 u3 U+ C) [( e8 e2 G2 V  y+ s( j, Q
    Superblock backups stored on blocks:
( I& {0 a3 I$ b' `7 E! \            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014091 W. R! R" T6 X
    Writing inode tables: done                            ) R3 l: j8 H2 v1 t  T
    Creating journal (8192 blocks): done
6 R6 _2 G4 y4 u9 t5 r# `0 B    Writing superblocks and filesystem accounting information: done
+ B; X9 j: ^6 L( ]7 A* U- G    This filesystem will be automatically checked every 30 mounts or. a$ t# {$ ^4 p
    180 days, whichever comes first.  Use tune2fs -c or -i to override./ |5 h! ~) _% r4 T& n
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点4 `% O+ [) F1 L$ W& I
    /dev/sda3              3723848    705992   2828692  20% /, F4 c% h8 z5 X
    /dev/sda1               101089      9274     86596  10% /boot  Z3 u7 F2 V. I! ~; ~7 H$ ]* e
    none                     14520         0     14520   0% /dev/shm; @8 S0 o2 U9 G8 Y: I
    //挂上新分区
* G7 f" B6 y" }  w* K" V
  1. mount /dev/hda1 /home
    & o/ i: q4 _& k
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点& V7 n: |9 l! ^* R  m
    /dev/sda3              3723848    705992   2828692  20% /* Z' U. j5 ?0 @5 d4 c( d
    /dev/sda1               101089      9274     86596  10% /boot
" j) Y$ g8 Z: {& C! ~    none                     14520         0     14520   0% /dev/shm
4 M& V% _; Z) ~* t9 A    /dev/hda1               488006      8239    454569   2% /home
, p- B% @% D# Q0 m7 o8 i4 F# T* _4 d
' v1 p4 y# z/ f+ u自动挂载:* n; ^1 c# r) u7 ~8 X' ]4 q( S
  1.           vi /etc/fstab
    1 D/ |  q' n; A! n* M" h! ]

  2. ) a; a' C  ]' R5 s( b- \
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    ! k3 a" X, c, U0 s' c' j8 P
  4. 5 P9 [' N8 c4 J- W& t2 l
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:& F, Y: k+ m" o9 H+ ?
  1.           mount /dev/sdb5 /mnt/ljp1% r! e5 T% ]. ^' g& a9 u! U0 d& B

  2. ( W- R$ ^1 f& s& U% F
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

1 ]4 @& B- P: F! R; l1 l( W6 g3 g7 }4 V$ B0 W5 ~

( p$ [( V% c2 M+ r) @& ~/ V- @' b
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-7-2 09:19 , Processed in 0.031266 second(s), 6 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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