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

 找回密码
 立即注册
查看: 2623|回复: 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)
+ A1 L! e$ D' O      or: fdisk /dev/sdc  (for the third SCSI disk), x! T1 E- }) y9 p2 d& S9 x
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
# P. P% z, n6 G: x4 K6 o      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)1 r3 d  z+ ?. M2 N# Q
      ...
7 ?" }  M7 Y2 Z' Q6 t
  1. df -k4 H& r, I# W8 O  t9 c8 g/ v
  2. df -lh& Q5 H$ o8 O5 N4 z1 t3 o, c: e% N
  3. 查看有几块硬盘:fdisk -l" i5 T1 f7 y7 I2 ~4 ?6 o
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
: x( x/ ~* m& @' v: U3 ]) N% N    /dev/sda3              3723848    705968   2828716  20% /! q7 Q/ _; Z0 E- T& R5 j' l1 u
    /dev/sda1               101089      9274     86596  10% /boot: n7 N' d. B$ _: ~* I) ?
    none                     14520         0     14520   0% /dev/shm7 a6 ^, ?! R8 a) P: D8 c
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用7 _$ W+ W: ~4 \8 ^9 }' C3 a% z
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
0 ^* s- Z4 {: H  w9 `3 S+ `  x/ b# C    Building a new DOS disklabel. Changes will remain in memory only,# P. n1 K* @' r
    until you decide to write them. After that, of course, the previous5 l: |( ]1 C9 v0 q5 Z
    content won't be recoverable.
) Z4 G/ g9 O* B5 J4 R    The number of cylinders for this disk is set to 8322.
' z' w/ a1 I4 h/ ?7 f% w  S    There is nothing wrong with that, but this is larger than 1024,& x2 p( T1 J( d* x" j% o
    and could in certain setups cause problems with:
# l9 g! n- s/ E* k! @! a    1) software that runs at boot time (e.g., old versions of LILO)
- E4 X4 N! ~$ G0 ~; \$ s    2) booting and partitioning software from other OSs" I( L  y/ Q" R, b7 q+ Z& f/ }
       (e.g., DOS FDISK, OS/2 FDISK)2 B$ u0 {& I& m- d  c4 S
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)- [& N% n2 G* z2 a
    Command (m for help): p
; `9 O/ g5 ~  C0 y3 D    Disk /dev/hda: 4294 MB, 4294967296 bytes
/ l) \5 e& {  Q, y    16 heads, 63 sectors/track, 8322 cylinders
7 ]& C; b# T9 K0 L  K- ?0 Q1 q* a    Units = cylinders of 1008 * 512 = 516096 bytes( C# P3 T5 g& V
       Device Boot    Start       End    Blocks   Id  System
- P" t9 }( Q# I- s) C  _    Command (m for help): m
* l! W- d1 W0 P9 L# B    Command action
$ R- \: e. {, J$ ~       a   toggle a bootable flag4 `- H7 R8 }1 h) c( {- w
       b   edit bsd disklabel# i7 i6 m2 l+ S5 d' J# j
       c   toggle the dos compatibility flag. I  R4 j. T2 [( I8 G+ D3 C
       d   delete a partition4 b. J  c; C6 P6 d; a* ]' A
       l   list known partition types# w5 ]( |+ q% K; r
       m   print this menu; J" w3 E; B1 ^
       n   add a new partition4 l1 i2 G, U( j1 U% u
       o   create a new empty DOS partition table
$ x3 k( s3 C* c6 x8 T       p   print the partition table
4 A' _1 }$ B1 g0 ~' M       q   quit without saving changes/ l  w" U% K) X6 l( p
       s   create a new empty Sun disklabel
' f9 m8 p% [5 s' ?       t   change a partition's system id
9 \; k6 r1 ^2 v: \9 z+ ~1 f       u   change display/entry units  x" H6 L" p9 D7 F
       v   verify the partition table# j# h( n! E8 g2 s4 k
       w   write table to disk and exit" t' U0 u) ?+ m' k  p6 f
       x   extra functionality (experts only)# }+ Z* v0 l6 a. u9 Z
    Command (m for help): n* W, O: D7 N+ ]$ [: |' h% q
    Command action8 b1 A/ ^" E' t: f/ w  L  e3 i" O( Z; }- A
       e   extended2 }; h+ {7 s+ a
       p   primary partition (1-4)
$ k! o- E1 h9 {9 G6 i$ n    p! `2 s  h. [( `6 K/ \) ]4 s6 T  z, w
    Partition number (1-4): 11 ]. n" P! g# v. U2 D
    First cylinder (1-8322, default 1): ' Q( J; ^: I% J( |" l
    Using default value 1
' B) w4 O, y: T- p    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G. [! K- F* D' a1 g
    Command (m for help): p1 k; j0 U. _7 E$ c+ b. F4 z) |; ^
    Disk /dev/hda: 4294 MB, 4294967296 bytes8 O0 ~; }+ B+ _$ C
    16 heads, 63 sectors/track, 8322 cylinders+ q% d* z7 F- w: N  v1 ?# ]
    Units = cylinders of 1008 * 512 = 516096 bytes* b' A" R; |0 y& R0 k
       Device Boot    Start       End    Blocks   Id  System
* w6 T% h6 `1 z7 h  U* a    /dev/hda1             1      1000    503968+  83  Linux
5 P2 w: H1 q+ Q# ^  ?. S4 H/ F0 e8 ?    Command (m for help): w3 V2 V9 v  D0 h& G
    The partition table has been altered!- w0 ~. F1 P( m% u$ d
    Calling ioctl() to re-read partition table.0 G- f& V; _+ V! p
    Syncing disks./ \$ `9 t6 G, }6 W% ^
    //格式化新分区9 w4 y) ^, `: V! z+ A
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
4 y. Q6 o1 r, G* n/ Y    Filesystem label=
; Y$ K/ X" a0 ^1 K" g$ |    OS type: Linux
3 V" ]5 V6 T; P* M    Block size=1024 (log=0). G) q6 N. d3 X. ?
    Fragment size=1024 (log=0)3 O' X5 K' y5 c4 f/ f8 O* V* K4 L" S
    126480 inodes, 503968 blocks
5 x% a  Y8 C2 k0 f8 q8 c, U0 r* E    25198 blocks (5.00%) reserved for the super user
6 I9 M. d/ d7 V  e" S    First data block=1
$ l3 H1 I0 p; E6 \    62 block groups
2 B' _6 G: h, d% ?; @/ Z, T    8192 blocks per group, 8192 fragments per group
7 r4 L5 U3 j, r* u/ w, j  }1 }1 O    2040 inodes per group
8 x. \9 F. c) a- h    Superblock backups stored on blocks:
. u) |$ h1 b- F4 M0 f6 r$ ?5 K            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409* L# I. I1 s$ A& q
    Writing inode tables: done                           
& n' d. o" ~4 t0 ~; `    Creating journal (8192 blocks): done
; t  U! k: U+ e2 P# F3 _$ O# S# F    Writing superblocks and filesystem accounting information: done1 C4 L1 T2 z" [: ?2 D
    This filesystem will be automatically checked every 30 mounts or
# t' a$ w0 D5 l1 r- G1 I/ R/ S    180 days, whichever comes first.  Use tune2fs -c or -i to override.
# l5 ~6 k3 ]0 F! |$ W
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点) I5 K4 x& j! I8 r+ D9 \
    /dev/sda3              3723848    705992   2828692  20% /
) x% x( K% y( Q, q) y) m0 }    /dev/sda1               101089      9274     86596  10% /boot% [* D" r* R! v
    none                     14520         0     14520   0% /dev/shm$ r/ l3 h% `! R1 Z8 ]# L! z( j
    //挂上新分区
* U5 M3 x" I+ r% u, |& {2 G0 G
  1. mount /dev/hda1 /home1 i9 i" Q0 s' j# k
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点" ?( p+ [" }  n7 s+ W$ f) g( \
    /dev/sda3              3723848    705992   2828692  20% /4 W% k7 Y" }4 S/ F
    /dev/sda1               101089      9274     86596  10% /boot
  \# W" j. U! v    none                     14520         0     14520   0% /dev/shm7 _5 H# B. I/ \) j1 `6 {# Y9 @" j
    /dev/hda1               488006      8239    454569   2% /home6 p, j6 i; `2 d9 c5 j: J5 c& I

: }3 p8 i* {5 R2 y8 f7 R  e自动挂载:1 A, }+ Q, S  S0 o1 d; a! B& d* ~
  1.           vi /etc/fstab. M0 w5 G$ q9 [! q* e) T

  2. 1 i# y3 M1 x0 j
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0( H" k' p  {% l; c* B: }3 P5 \; ?

  4. ' n" g$ {, g' X! f
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
- Q+ O) @3 P3 J( P& V
  1.           mount /dev/sdb5 /mnt/ljp1. B3 L7 i, {" V  A) g

  2. ) K2 @! V8 ^8 g
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

$ f5 r  h( k6 B- D; ]0 @# X- O# J) r" B+ I- @6 i. d  n+ O- n

& d; s" P6 m) c) \+ d- }, i
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-2 00:34 , Processed in 0.033597 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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