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

 找回密码
 立即注册
查看: 2574|回复: 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)& T9 m( d) z) `! G( Z; d
      or: fdisk /dev/sdc  (for the third SCSI disk)+ [" Q, x' ?  u) V1 c* v) `0 Y
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)+ ^& e2 d$ Q5 @
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)( `+ V, C5 D$ v7 q
      ...- v. E  ?! J4 Y' O/ [
  1. df -k- l1 ]0 _& a$ t0 Q! m5 A# G
  2. df -lh
    1 x1 m- T9 Y; {, e! h3 J! D6 z
  3. 查看有几块硬盘:fdisk -l# \1 ~! s- y) i8 B
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点9 E3 T: v+ r& v& n5 w7 G" f* Z" ~: j
    /dev/sda3              3723848    705968   2828716  20% /
5 e( K  L5 Y; k+ F- w4 L    /dev/sda1               101089      9274     86596  10% /boot
# P  v6 y' Q% k7 b; E, C6 U2 u    none                     14520         0     14520   0% /dev/shm. @2 Z" l7 c, e% o$ W
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用+ G( F7 s  @5 F- F
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel8 s3 c" H6 ?! `$ z
    Building a new DOS disklabel. Changes will remain in memory only,
0 Y) i! o& F+ w, k7 E) `! q9 Q    until you decide to write them. After that, of course, the previous
# a8 l( P$ R) g0 h7 d    content won't be recoverable.
4 u; A% t  L" x' t: ^& ^2 W    The number of cylinders for this disk is set to 8322.8 s' V, |& z. J4 R
    There is nothing wrong with that, but this is larger than 1024,' w+ G$ a+ X( G3 Q
    and could in certain setups cause problems with:) f* U* _% U3 z- y( _
    1) software that runs at boot time (e.g., old versions of LILO)4 q, O6 E+ F5 {% i- F
    2) booting and partitioning software from other OSs2 ]& L9 x* J/ U% K
       (e.g., DOS FDISK, OS/2 FDISK)! f$ v" ^2 ?; X9 B
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
- t3 h! o1 g, i    Command (m for help): p
5 d9 S, d/ L1 R* b0 b( [4 @    Disk /dev/hda: 4294 MB, 4294967296 bytes
2 \' f; a& l2 J    16 heads, 63 sectors/track, 8322 cylinders
; t4 x; E# z3 C( r    Units = cylinders of 1008 * 512 = 516096 bytes/ b3 i0 ?/ |! D# Z
       Device Boot    Start       End    Blocks   Id  System1 B3 M! G6 X) I3 j
    Command (m for help): m% Y0 ~1 @- c* v+ c5 c- Z* e1 f
    Command action
7 R9 t; @# S8 F9 C+ [8 D( o       a   toggle a bootable flag4 [" S; y- X0 c8 [/ e
       b   edit bsd disklabel# E, k2 R! C+ B6 Q% J
       c   toggle the dos compatibility flag9 v6 N: y8 k+ U
       d   delete a partition  A' T+ j* i2 W& j% C
       l   list known partition types
- q9 |( f: ]* D6 D4 G       m   print this menu
5 _4 M; Y; u9 u4 [1 c4 \! M1 B       n   add a new partition
% X7 G& v/ a' A, ^0 G* r! x       o   create a new empty DOS partition table$ M: v& V9 B& n* ^: S4 s
       p   print the partition table
2 C( r: G7 \1 W1 ]       q   quit without saving changes
0 [9 j: s5 I$ ?) u0 I; @  \       s   create a new empty Sun disklabel
' R  r* q) G* E3 S2 S0 V5 N+ K       t   change a partition's system id
: ~+ M& R# ]9 ^, Z) K& w3 D1 v- l       u   change display/entry units
1 |& m0 h. r5 j3 U2 Z       v   verify the partition table
  i5 J- D/ a* d  m1 P% o3 P       w   write table to disk and exit
4 E5 G+ G. |  m3 S3 e" S1 D# B, |       x   extra functionality (experts only)& K9 u5 H+ j+ C# B$ X1 {7 w
    Command (m for help): n( p9 m9 P0 N: f8 S1 i
    Command action# Z* u/ G5 H. V5 }( E1 [. d
       e   extended* K* u% v4 S- X
       p   primary partition (1-4)
/ y0 [1 W6 {' B7 ~    p% A  Q# ^+ c5 l3 S7 w2 `3 ~
    Partition number (1-4): 1/ F) ?1 n; u6 c- c4 b
    First cylinder (1-8322, default 1):
+ B0 i3 m! j, e" Y# J; ^0 x' t    Using default value 1
" M+ _6 k" n! l* w% W) Q5 h  c) d    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G5 x! C6 o3 O5 _$ P4 }; R5 ]$ A5 d7 Q
    Command (m for help): p8 o7 t. W! o* k5 z& S
    Disk /dev/hda: 4294 MB, 4294967296 bytes7 c5 N- D" A9 D& `( U. A( b# U2 E
    16 heads, 63 sectors/track, 8322 cylinders
0 f6 _0 C8 n% }- @/ K6 H: s    Units = cylinders of 1008 * 512 = 516096 bytes+ }- N; w! O" ^) n: V( X; k
       Device Boot    Start       End    Blocks   Id  System
" N0 T# o) i1 H! A, L, @    /dev/hda1             1      1000    503968+  83  Linux5 S4 h- `- p4 x, a2 B! d
    Command (m for help): w0 a3 T9 s2 R5 m; V) ^
    The partition table has been altered!" ]: f# c+ o2 w& U5 t3 _9 ^- P
    Calling ioctl() to re-read partition table.- `& s% y2 @- r5 u" c$ |0 R
    Syncing disks.
, t$ X4 F3 J2 ^4 ~8 t5 s    //格式化新分区2 d& a. q, |/ M/ y; n' E
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002): I! ^' p" \, K2 s
    Filesystem label=
) n  K0 y8 q2 i/ I- l1 n    OS type: Linux% U* }3 E- M* R4 g/ l8 \
    Block size=1024 (log=0)& u, T% C4 Z( {0 f4 I) @
    Fragment size=1024 (log=0)1 m! B  L/ K( M. f4 G9 n8 ]
    126480 inodes, 503968 blocks  n7 n* R1 q( v, N9 K9 p
    25198 blocks (5.00%) reserved for the super user
3 s/ x: O3 ^6 [) Z) e    First data block=1
% M8 w2 h& C9 H9 E    62 block groups8 y$ i, P2 R! k/ h! @. u8 i* o# H
    8192 blocks per group, 8192 fragments per group
/ m) S% N  B% R: K: b  h/ v7 S    2040 inodes per group
: j! c6 ?. k, ?# Q    Superblock backups stored on blocks:
, S% @0 L9 P) _  {* ~            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
8 Q3 L$ F0 t# v. p! J( m    Writing inode tables: done                           
0 x8 H% ]/ l2 U8 v    Creating journal (8192 blocks): done
) M2 C3 O& u5 z$ Z& D% Q# }    Writing superblocks and filesystem accounting information: done
% d$ C6 S8 ~- X4 K    This filesystem will be automatically checked every 30 mounts or
+ @. R. f6 Q7 _: B" g    180 days, whichever comes first.  Use tune2fs -c or -i to override.
3 g2 B: @2 W' @7 K: Z
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点+ X: K' f( Y* J' t/ J& B
    /dev/sda3              3723848    705992   2828692  20% /
' B6 U3 k$ `) j  V9 T& x( D    /dev/sda1               101089      9274     86596  10% /boot# Z3 H( s& j5 m6 j( m9 }
    none                     14520         0     14520   0% /dev/shm2 ^7 H( n$ A* ~0 `+ d- _
    //挂上新分区4 H( [* \: |, ?" [+ |  ?
  1. mount /dev/hda1 /home
    ! j( y% y4 u/ L$ ^; v/ B
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
% i6 H& Y' a# _, e    /dev/sda3              3723848    705992   2828692  20% /
8 e( G" ]# O5 P# N( c9 V    /dev/sda1               101089      9274     86596  10% /boot
, r) Y- A6 h: a0 a    none                     14520         0     14520   0% /dev/shm
: C+ G4 e1 j0 f  L$ d( q# D    /dev/hda1               488006      8239    454569   2% /home8 g- |7 y$ b8 [8 q7 T4 N( {

) Q2 A3 C2 z. ]& {自动挂载:
* x$ C* t% |5 M; `- ]3 {' E8 T
  1.           vi /etc/fstab$ _6 U( m, w6 A& x
  2. 9 E9 t/ G* X2 ^" r8 S& \/ i  k
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    ; T5 Q9 ?8 a" b% @8 }! e8 E. J& E

  4. 5 p" o' K4 n0 W
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
5 A2 n/ @7 E1 E% F/ S9 o
  1.           mount /dev/sdb5 /mnt/ljp1& l' S* i8 f+ T) `
  2. ( }& P  o  L7 A9 R
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
7 t- X! {+ P$ W$ q" _, i# b: P
  K3 ], e6 w7 r5 s$ e+ O& c
: F* z8 J& p2 @& p. v( X& V" G
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-20 06:38 , Processed in 0.036632 second(s), 10 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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