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

 找回密码
 立即注册
查看: 2675|回复: 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)
( G8 c+ ], c# U- ?8 p: `      or: fdisk /dev/sdc  (for the third SCSI disk)
6 X7 V/ `; }0 t% o# x      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)2 y. \5 i$ }: w
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)3 ]0 |1 }; O7 g# {& w
      ...9 a8 f0 w9 u. C# W! Z) U# B
  1. df -k
    - H. j. O$ z5 e1 @7 V2 X
  2. df -lh
    / D  V; p4 a& X- T9 ~% R. [! u
  3. 查看有几块硬盘:fdisk -l
    , o; t- B* \) A9 y, R7 Y
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
7 f% E2 n  Q! k    /dev/sda3              3723848    705968   2828716  20% /5 L6 A5 L" r# P" f) [  e% H4 u0 M/ G
    /dev/sda1               101089      9274     86596  10% /boot
2 p+ c6 B$ J2 p6 e& r$ j    none                     14520         0     14520   0% /dev/shm! b) K) N! h1 j+ L, Q
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用8 ~- z& q; L/ M7 W7 S4 l
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
3 E0 J1 J. W  L0 E( Q. h, E    Building a new DOS disklabel. Changes will remain in memory only,, F8 B' m2 d9 D/ L" k1 e8 H
    until you decide to write them. After that, of course, the previous
7 |1 f* p9 \8 B# H( L2 R9 T    content won't be recoverable.% [9 Y! f6 K# q" B! N
    The number of cylinders for this disk is set to 8322.
6 ~1 k: b( T4 Y6 G/ T( S    There is nothing wrong with that, but this is larger than 1024,
# p# X  I" H2 U0 ^* Y! u    and could in certain setups cause problems with:6 j/ T5 g% A& z/ y
    1) software that runs at boot time (e.g., old versions of LILO): [% D. ^6 f/ ^  ]3 P* W- _/ w& Y, e
    2) booting and partitioning software from other OSs
* u3 T. {- ?  m7 u. p       (e.g., DOS FDISK, OS/2 FDISK)
5 i8 j$ F  J1 a" M; n; Z    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)6 X: |" o- \, E; b6 J' }% g
    Command (m for help): p
7 U! z' J$ x4 o; ~    Disk /dev/hda: 4294 MB, 4294967296 bytes/ Q! q- k# ]6 ?1 F
    16 heads, 63 sectors/track, 8322 cylinders7 a4 K& _* G( U9 _. [( z5 Y0 [* J
    Units = cylinders of 1008 * 512 = 516096 bytes
9 r% N, p  Y& c% c7 ^: d       Device Boot    Start       End    Blocks   Id  System
3 b. Z0 r9 {$ J5 F2 c& Y5 L    Command (m for help): m
; b; x7 k2 P6 \% R" k    Command action
' d8 r/ _* u- U; @7 ]$ T       a   toggle a bootable flag( U2 F# Z- q( W" R9 y& X. d
       b   edit bsd disklabel
, ~2 ?# R. K0 J- L+ A       c   toggle the dos compatibility flag
3 K8 h9 n2 J3 j       d   delete a partition) }6 M$ e7 X! `
       l   list known partition types7 y4 v% I  g" n! l3 ^, P. X
       m   print this menu) V( m& `$ K$ z
       n   add a new partition2 g6 z0 {' C: d) w
       o   create a new empty DOS partition table: G# a+ c5 a/ S/ b& n
       p   print the partition table9 w  X$ H( A. y5 f7 {3 M
       q   quit without saving changes" C# G2 t) B# ^  W
       s   create a new empty Sun disklabel
, `* n% g3 Q; D       t   change a partition's system id8 d, M+ W* |+ t6 E' A+ I
       u   change display/entry units
' ~( K# w5 m6 _5 d       v   verify the partition table. z* e" j- |1 X: r) [
       w   write table to disk and exit
6 G' i0 _7 P! j( P       x   extra functionality (experts only)' r0 O$ _: U& l& X* w3 P5 P/ ^6 n
    Command (m for help): n2 y; q/ r( e% d  u, \
    Command action% B: O5 c# H3 f) O/ Y' X3 p0 _
       e   extended# }% m' V9 z! G0 C& i: Y
       p   primary partition (1-4)! B1 @' T1 t! Q* S
    p. \" {+ C( d& D) f5 `7 K4 y
    Partition number (1-4): 10 v* `- J% }. b" _
    First cylinder (1-8322, default 1): 4 E+ `1 L" U: r! E1 r7 R! n7 q
    Using default value 1% e& I0 c8 G2 [7 `8 ~
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
. F9 L0 g1 p5 W- Y6 r7 G/ z7 K2 `    Command (m for help): p
  A  G; l% I! {2 E  b    Disk /dev/hda: 4294 MB, 4294967296 bytes5 v6 r& G; l1 w. C
    16 heads, 63 sectors/track, 8322 cylinders% j; p4 y& T# o# @
    Units = cylinders of 1008 * 512 = 516096 bytes
$ ?& P/ B3 z* F$ J( @2 W( ?( k       Device Boot    Start       End    Blocks   Id  System
- f5 l0 s0 C# i1 P* M9 o    /dev/hda1             1      1000    503968+  83  Linux
: a" Q8 u9 H+ l: z1 b3 z3 P: Y: U    Command (m for help): w* t5 r& L. E8 q' s3 ~
    The partition table has been altered!
9 s9 ~" ?2 _/ [0 y% J/ ^' F& u    Calling ioctl() to re-read partition table.! i1 Q9 @9 P# C0 [8 m
    Syncing disks.
" x9 w9 z4 H3 v# Z    //格式化新分区0 s) P) a  f* d& X$ {) @
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)9 c- A" x. v0 g: D  b
    Filesystem label=. X: `  f. K. T8 k
    OS type: Linux- x4 _( W" Y- V$ \
    Block size=1024 (log=0)0 X2 I  ^& i9 ]' _9 j, e: }
    Fragment size=1024 (log=0)
8 E5 x- l" }) Y  I$ a/ F    126480 inodes, 503968 blocks
8 Z7 ?: Y' q! `3 a$ U7 K5 e1 @    25198 blocks (5.00%) reserved for the super user) ?2 X( G) l* ^; I
    First data block=1$ r& O' I$ N9 C& ^- }
    62 block groups; ]: I$ d! b+ \3 D& h
    8192 blocks per group, 8192 fragments per group" C! M" R, f# i3 F
    2040 inodes per group) X' t2 f  f1 f
    Superblock backups stored on blocks: ( l7 t1 N, U$ f7 S0 B
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014092 s: Q5 b$ e% ^. P
    Writing inode tables: done                            / c: s2 R1 J$ m- l4 L% Z+ `
    Creating journal (8192 blocks): done
  l9 Q7 e+ @6 M" V' W/ F3 X" y    Writing superblocks and filesystem accounting information: done
. I, z7 R0 f3 @    This filesystem will be automatically checked every 30 mounts or9 `% P+ f) M; c
    180 days, whichever comes first.  Use tune2fs -c or -i to override.+ }) n" y  W! Z. ~2 ~# |
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点! W& |8 `  `; {
    /dev/sda3              3723848    705992   2828692  20% /! E( T, ]9 D# k6 `9 Y7 C
    /dev/sda1               101089      9274     86596  10% /boot* p% z& X2 q& ]8 F4 x) m% K+ ~
    none                     14520         0     14520   0% /dev/shm
$ U3 A+ s- M, M: s  U2 C    //挂上新分区, [4 p8 u) @5 f2 R0 Y( h8 d0 v6 V% L( B) x
  1. mount /dev/hda1 /home
    1 S0 d. @8 S% g& f! p: f  y
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
: x  Y' L* W! I  B6 P, f* }! M6 o    /dev/sda3              3723848    705992   2828692  20% // L; u( z. C9 [9 e
    /dev/sda1               101089      9274     86596  10% /boot! E0 W, C; E7 o6 g
    none                     14520         0     14520   0% /dev/shm
! G" K. L) i7 u    /dev/hda1               488006      8239    454569   2% /home- {6 ]$ q% x2 [

8 c, D- D; A: w: Q9 z自动挂载:
- o3 D: p7 Q5 b. i0 D5 P
  1.           vi /etc/fstab/ D5 u. F, p% E, X8 T( T; H; k
  2. 5 k! {$ ~8 }$ V1 ?% D, N" r' Q
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0: l1 M  X, k1 r- c. H4 o

  4. % a' Q; l. t( a
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
6 _- ~5 {( I8 K/ `, |
  1.           mount /dev/sdb5 /mnt/ljp11 q% ~$ }# T9 l5 `4 ^( v4 g% d

  2. ' Z( k* R$ r7 \; u4 u( N+ u( \! c& t
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
2 J7 F- V7 n0 E
( |  {5 c0 a" H5 l: u1 P6 `, @
- S, e* p' q' m/ q, f4 U" X1 |
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-12 19:58 , Processed in 0.010852 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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