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

 找回密码
 立即注册
查看: 2739|回复: 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)  R: f6 V+ A5 G+ X2 O, r
      or: fdisk /dev/sdc  (for the third SCSI disk): U3 L* \4 N  H2 t+ e4 r: A
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
' q+ X% K- f9 j2 B, O" u% c0 ]8 \, {      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)/ u3 Q$ a+ G6 O4 g2 z7 r9 X: I
      ...
, ]; D+ k+ {  N" Q. @, d
  1. df -k' N9 j4 A: s' O+ U5 \5 `" q
  2. df -lh
    ! o; a% c( Y( }1 h
  3. 查看有几块硬盘:fdisk -l3 u$ t- f' j2 T& a! W
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
7 C; f' I- q1 x7 E    /dev/sda3              3723848    705968   2828716  20% /
7 k2 J) K+ }% f  }0 [1 \( G    /dev/sda1               101089      9274     86596  10% /boot
2 A! l( \6 |, _! N    none                     14520         0     14520   0% /dev/shm# t0 G4 v2 q) }, U3 P- Q. b
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
( a$ t4 l6 W$ C6 V( |) Q% G5 W
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
* F6 a4 Y6 K1 ~/ l    Building a new DOS disklabel. Changes will remain in memory only,
( Y; O* `! M1 Y- N: D* [& g8 [    until you decide to write them. After that, of course, the previous+ v; v/ K5 s% t; [4 V
    content won't be recoverable.  U3 s7 G, T: Q2 x7 }0 W
    The number of cylinders for this disk is set to 8322.
" C- _! x: \4 Q* B- D7 ^    There is nothing wrong with that, but this is larger than 1024,% ]( z/ P( N& L% J% r7 g% A
    and could in certain setups cause problems with:. [" Q/ [, ?9 P* ]1 _) [
    1) software that runs at boot time (e.g., old versions of LILO)# g8 K$ a0 c$ m3 \$ Z
    2) booting and partitioning software from other OSs
$ c$ t# v* K. R$ U7 B4 p       (e.g., DOS FDISK, OS/2 FDISK)
# i# r8 N7 t4 [4 ], d) M    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
5 [& R( S9 r4 h9 q    Command (m for help): p8 d) }* a, N& k8 x- @
    Disk /dev/hda: 4294 MB, 4294967296 bytes
! r+ [% K6 Z% v) D" y    16 heads, 63 sectors/track, 8322 cylinders, p2 K0 U0 r5 l* J, E/ Z
    Units = cylinders of 1008 * 512 = 516096 bytes
$ e3 m9 q( M6 u2 y% T       Device Boot    Start       End    Blocks   Id  System; R9 M8 [; j& ^$ E* s
    Command (m for help): m
. g3 L9 u3 p7 N3 q    Command action
9 j4 W8 @( L4 N+ c. P' v0 w       a   toggle a bootable flag- G- w- l& G+ g& m, `7 l8 D* d
       b   edit bsd disklabel
1 C! s9 B, O* ?1 h       c   toggle the dos compatibility flag" K- r; r4 J6 G% ^: g# H& Q3 B
       d   delete a partition
3 I3 u$ F% b" w3 L       l   list known partition types5 Q! \$ h9 ^7 q/ @1 u
       m   print this menu  J9 S' A: a& V- s. R
       n   add a new partition( B: [6 D3 D9 x5 s
       o   create a new empty DOS partition table5 e0 U7 N' v9 ~! @$ q: `; n
       p   print the partition table
9 p1 O% H0 Q" G       q   quit without saving changes
, D: v  z8 o5 N: V* H7 Z* G8 ~/ j       s   create a new empty Sun disklabel
9 b3 ]6 c( ]9 B8 f3 f# b3 S" Y+ r       t   change a partition's system id
7 u6 G( A: c& [( E; K" q) X       u   change display/entry units
# T* i" [0 }% Q; h1 J4 t       v   verify the partition table
/ _0 _: W2 P; S7 I5 q2 V4 S3 v       w   write table to disk and exit
6 n, a% s* V5 ]5 q       x   extra functionality (experts only)' X4 M' M3 n# n. E: w/ [9 W0 w
    Command (m for help): n1 _3 `' ?. C4 z! m, w' n9 D
    Command action' T; j4 A/ x" _6 r
       e   extended( `: e$ ?( m* [' S, p
       p   primary partition (1-4)
' T. e" Z: i" a9 U- ]4 V    p
( e! f5 a# h' w+ M# m2 D5 L. x    Partition number (1-4): 1, x% i  a. k* C- a) P
    First cylinder (1-8322, default 1):   j! C. v5 K# {, E0 m! Q
    Using default value 1
6 Y6 ?0 x) [$ o% m; c    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G: X: w8 ~' o7 C6 }2 R
    Command (m for help): p
  B0 y3 s" z' [4 B" g2 n    Disk /dev/hda: 4294 MB, 4294967296 bytes
/ _" [; _% q9 P5 f    16 heads, 63 sectors/track, 8322 cylinders1 N6 w4 N" U/ v! @. o+ P" B
    Units = cylinders of 1008 * 512 = 516096 bytes+ A# |* f& j6 d: @6 K- J& q+ s$ y
       Device Boot    Start       End    Blocks   Id  System7 o% D% P" z) _/ _7 U6 _$ g
    /dev/hda1             1      1000    503968+  83  Linux! ?0 x$ W& V5 e; U$ t- E- S
    Command (m for help): w
5 c6 [# M7 A6 u1 t, e  _/ B    The partition table has been altered!
" l. D7 b6 l. x; E  A* j1 C    Calling ioctl() to re-read partition table.2 E! z6 b( M: L! E: m
    Syncing disks.. e7 n& h3 ?  J' S7 t+ Z
    //格式化新分区
- e- h( G. W; D  P
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
6 R- u5 G, V; k" ~9 ~    Filesystem label=4 \3 g& K. m/ Z% w7 I' C
    OS type: Linux% \) A* N: p0 [0 m
    Block size=1024 (log=0)
/ J1 y# w% G8 g    Fragment size=1024 (log=0)
- X# \# b8 B, R    126480 inodes, 503968 blocks
  X, Z! F3 y4 G    25198 blocks (5.00%) reserved for the super user
( C6 w* p5 L, l( [    First data block=1; b/ f1 Q$ O; d3 |; h; h) _
    62 block groups8 K4 x$ K3 [2 s
    8192 blocks per group, 8192 fragments per group
# Y: K+ Z! a0 C$ E0 l, L6 }    2040 inodes per group4 B: T" k7 f; I% K
    Superblock backups stored on blocks:
. N3 x$ X/ U% [- X            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409! C. E8 `. Z: L0 x; Y
    Writing inode tables: done                           
) n2 Z, ^; o$ \! y7 W    Creating journal (8192 blocks): done
% o* H( J! P8 x& y6 o    Writing superblocks and filesystem accounting information: done+ A  S0 b0 ~: k9 F8 q& F' ~1 S  ]& ^
    This filesystem will be automatically checked every 30 mounts or$ T; C/ X6 w" a( Q$ A( I
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
! G- n- a2 F  R3 y* _0 T7 A! g* d  _
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
* ?2 v8 W* Z4 K4 U, w    /dev/sda3              3723848    705992   2828692  20% /# j- P# p& b) R* A% \% S# b
    /dev/sda1               101089      9274     86596  10% /boot
7 D; y" o3 m$ Y3 X5 m' Q1 ^    none                     14520         0     14520   0% /dev/shm( v: p% |# G7 ]: M/ @5 d& A" i
    //挂上新分区  s, D! T; l% x& o. I3 a$ q
  1. mount /dev/hda1 /home
      ?" X& T! s$ F) B! b
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点+ E! R4 c" w' {9 T3 Z" ]+ P. g' [
    /dev/sda3              3723848    705992   2828692  20% /5 u& t( j2 X( o+ z1 q7 ?2 b! l
    /dev/sda1               101089      9274     86596  10% /boot6 [% s& G" d; j5 I' D+ ?" ~
    none                     14520         0     14520   0% /dev/shm
; m9 d7 }: p5 Z* A. u8 l  w4 i    /dev/hda1               488006      8239    454569   2% /home
) T5 W! o: }/ }/ h9 g5 ^1 ~) k' E" ?0 l5 d5 x5 q8 y
自动挂载:
9 N$ {' R- C: s' i9 m3 S$ L
  1.           vi /etc/fstab
    9 e2 p) }/ j: ?+ }

  2. 5 I6 x# _% ]! g/ Q
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0( v4 T8 Z# P( B9 p
  4. ) T9 g$ z6 K4 ]. u3 _: s  h
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:7 ^4 ^7 D- h9 k$ Q
  1.           mount /dev/sdb5 /mnt/ljp1
    & j" q& R3 S1 X* R2 G
  2. 9 x- [( O# a( w- p* \
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
9 m2 R7 ]6 R6 Q2 V
3 j; ]& k) I$ p: d

: ], @; @4 D0 ~2 E
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-5 16:07 , Processed in 0.015195 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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