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

 找回密码
 立即注册
查看: 2581|回复: 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)( e$ O: V4 m4 j' r# d
      or: fdisk /dev/sdc  (for the third SCSI disk)
7 n8 t& s$ d  ?; ^1 d5 s      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
. H3 Y' i5 ~) N7 F* t* Z+ Z      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
' _. {0 a& K$ J# w9 j# Q      ...$ D! l7 L1 V9 q; B! u  @, }
  1. df -k0 v, ?6 E& k2 j# G# i
  2. df -lh
    " X; T) |) Y7 F2 N: b' [2 H
  3. 查看有几块硬盘:fdisk -l- ~+ Q2 c( @* B' d* P3 }
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
& M$ o" @$ k9 ?9 j5 S    /dev/sda3              3723848    705968   2828716  20% /
! z1 m; J: [/ }7 i. O9 f- Q    /dev/sda1               101089      9274     86596  10% /boot
2 u( F2 T0 S) e* H, R    none                     14520         0     14520   0% /dev/shm5 R8 ]9 l1 h$ Z8 {2 j
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
% H/ b" H# q; o
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
0 h  a) X7 V* [7 g4 E    Building a new DOS disklabel. Changes will remain in memory only,
2 m2 ^* t$ R1 R4 L! e  r7 Z    until you decide to write them. After that, of course, the previous5 e- m6 g( N7 _0 g( _
    content won't be recoverable.8 r  w, T0 Q5 H- k
    The number of cylinders for this disk is set to 8322.
4 X' e4 i; i& {" g    There is nothing wrong with that, but this is larger than 1024,
# {4 h: U; ]' J$ A5 y; @4 z    and could in certain setups cause problems with:
% E" q+ c- R% l0 J1 _' v0 |    1) software that runs at boot time (e.g., old versions of LILO)
& \4 u: W9 R% G; |' b: f    2) booting and partitioning software from other OSs" E* _9 g0 @/ H3 @6 M! u7 F
       (e.g., DOS FDISK, OS/2 FDISK)
+ @4 r/ {5 W! o, R' T5 m    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)# `- Y2 w. O2 Q/ B3 O! S! c6 ]
    Command (m for help): p
) {4 ?, A* q' w3 {4 I    Disk /dev/hda: 4294 MB, 4294967296 bytes
) |" }( e0 q- T    16 heads, 63 sectors/track, 8322 cylinders
* s6 Y2 m% E3 u8 |( v9 e    Units = cylinders of 1008 * 512 = 516096 bytes1 o3 N" |/ m1 T) y5 w
       Device Boot    Start       End    Blocks   Id  System1 F! o1 Y( o3 p. z7 g1 w# T
    Command (m for help): m
2 q: Y( v& ]& V* X- u( y* k0 B    Command action: P7 x  x1 W! Y9 L% Q
       a   toggle a bootable flag  z( Q  l! F+ F$ L6 h4 J6 p
       b   edit bsd disklabel" }& r) |4 _% S
       c   toggle the dos compatibility flag2 D" X, e5 `6 [
       d   delete a partition
- e. X: l1 R% \; s9 a0 Z! V/ i       l   list known partition types
* i" z) {& Y6 A& h( H4 H- k       m   print this menu" ^% e9 `1 b+ x" O) Z8 K" r9 u
       n   add a new partition
' C; h( z5 t8 k       o   create a new empty DOS partition table6 a" L/ j; r9 Y% @( x. N' m
       p   print the partition table1 j: Z( X8 ]9 h) W' S$ p
       q   quit without saving changes/ m" I* ?8 H7 X0 r8 W$ W8 d
       s   create a new empty Sun disklabel
. o% i5 k9 I0 T( v- l# }1 s       t   change a partition's system id2 G& k- n" J. k9 a& _# J& D
       u   change display/entry units
7 b. |; ~8 P: {2 X! \$ E       v   verify the partition table
( C0 [0 b, F" s8 H4 G       w   write table to disk and exit" n- i; Y5 G# g: L8 a; M, |! b
       x   extra functionality (experts only)
; B' @& l2 o/ a/ {% I    Command (m for help): n* w- K8 z! a3 a" J. O
    Command action; c- j" X  r% ~+ c0 t: E
       e   extended
4 Z9 U2 |2 ]0 `. a  ?. _6 M       p   primary partition (1-4)
% ~2 I5 _* b. v% |    p
2 S+ D) v7 H1 d1 f    Partition number (1-4): 1- V( Q/ F1 Z5 r7 s8 x& `
    First cylinder (1-8322, default 1): ) x& v/ P+ A$ B
    Using default value 14 r/ ?3 _8 C: \+ E0 d
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
5 l! c6 a% w- V* D3 R    Command (m for help): p
, o4 u# U( W9 L    Disk /dev/hda: 4294 MB, 4294967296 bytes
1 `: x0 A  F: |  C    16 heads, 63 sectors/track, 8322 cylinders
4 n% g8 Q! O( K# B& d) n- s    Units = cylinders of 1008 * 512 = 516096 bytes
' M& k, N5 T* {' ]* \5 D9 A2 X9 v       Device Boot    Start       End    Blocks   Id  System0 N6 c  s& `$ ~: \
    /dev/hda1             1      1000    503968+  83  Linux
0 S5 Y! t3 Z% r0 z/ r  I    Command (m for help): w' |' `* F! M7 {: u* K; d! N# D
    The partition table has been altered!. ~' h3 o. E' c7 ?
    Calling ioctl() to re-read partition table.
6 q% D3 j0 ~9 n! C7 K3 G    Syncing disks.6 |. {0 S8 X, D+ r. e: c4 p
    //格式化新分区+ q% F# I' i/ Q$ S9 P9 @4 V, i
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)7 g( E+ y, ]3 @, \' H+ V$ w
    Filesystem label=
0 @$ f) S* U" T    OS type: Linux
! j1 U4 k5 @) G- g    Block size=1024 (log=0)6 _$ v1 ^5 `. i! U3 s$ f
    Fragment size=1024 (log=0). F8 H/ t3 o2 t7 o# U9 J
    126480 inodes, 503968 blocks6 h, \: @4 J3 s' `" S# f
    25198 blocks (5.00%) reserved for the super user. n" q% M0 s! b5 }  H# S2 B% \3 ~
    First data block=1
: H& U1 T2 [* F5 K# T6 ?. E0 C    62 block groups1 g( d8 U3 _- O2 L( s6 s0 }: J4 }
    8192 blocks per group, 8192 fragments per group
' x. P6 _7 G, x( i  R* k( F    2040 inodes per group5 e6 t; [8 M9 x& {% {
    Superblock backups stored on blocks: # C: X8 B6 W& i* T) E
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
- @, X4 O3 V1 Z+ c. b    Writing inode tables: done                           
% @+ ~; Q& n$ ~* h, u1 m    Creating journal (8192 blocks): done
5 L7 v; o* ?, v    Writing superblocks and filesystem accounting information: done1 E5 i* g: v  C% E
    This filesystem will be automatically checked every 30 mounts or
' h+ [6 O9 q2 e/ r: [    180 days, whichever comes first.  Use tune2fs -c or -i to override.
' z8 Q/ g7 T: F
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点/ d' a& k/ o( L! V8 Y$ E
    /dev/sda3              3723848    705992   2828692  20% /
2 ]( B- z1 R4 Q  k5 H' Z9 ^    /dev/sda1               101089      9274     86596  10% /boot
5 H9 ?7 b5 T+ x' T( j9 ?& ?% y) }    none                     14520         0     14520   0% /dev/shm: ]8 n2 r9 m( S. }* P: F
    //挂上新分区
/ ^) h# N# D; P2 s& [% I
  1. mount /dev/hda1 /home
    0 e+ z& ?# F6 |& U& h* c/ c
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点. a* E+ R: D! a7 O& t6 w; l/ K
    /dev/sda3              3723848    705992   2828692  20% /  W$ Z% B7 Z& _3 q
    /dev/sda1               101089      9274     86596  10% /boot3 [  b4 J: ~' A' L
    none                     14520         0     14520   0% /dev/shm" g3 o& g. P- ]8 M; M& D- c# T
    /dev/hda1               488006      8239    454569   2% /home% e" O! I/ [2 o/ K/ F- U8 B

9 R% ?& L. j$ {, |* \9 t6 N. k自动挂载:' c+ K( `2 ~( l4 h
  1.           vi /etc/fstab. S+ n- ]* t* l/ w. F. T! ~9 P, i
  2. - {2 c" y- ~6 m3 ]+ |  e
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    1 K6 Z) S' c. j
  4. ! b- i( J" [; B& h* O6 I4 t3 P; t
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
6 ]  f' K7 y2 s5 U/ M* V
  1.           mount /dev/sdb5 /mnt/ljp1
    # p3 k, G; r5 V( a0 i, n
  2. / V) Z2 D& @8 D  n6 M5 t, o" K5 p) E
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

+ D# R9 s* o& q; u# a" d4 @# P7 u
& f+ G; v: {9 }# e$ ]( K% E3 W. U6 B
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-22 20:56 , Processed in 0.016873 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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