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

 找回密码
 立即注册
查看: 2668|回复: 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)  a- J5 P! Z4 @* f0 e1 d
      or: fdisk /dev/sdc  (for the third SCSI disk)& H3 F, v1 @( ~$ Q' C1 U
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
* F0 s, @/ t) v      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
4 w) e; U9 Y2 P( e; _: J      ...4 ?% e* M- G! l; T: H9 d
  1. df -k
    + H# Q! D1 F( z7 W( v* W- P% G) m; B
  2. df -lh
    5 @& s, `  f2 R+ s7 n: B
  3. 查看有几块硬盘:fdisk -l
    0 h: F1 ]- f; \% X% U! v
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点1 @6 K, n5 Y8 {
    /dev/sda3              3723848    705968   2828716  20% /; r0 K+ g9 f  H' z# [
    /dev/sda1               101089      9274     86596  10% /boot
( ]4 h1 O: q4 E' O( q* s. l. a- b6 H    none                     14520         0     14520   0% /dev/shm
& [; V' I3 v( d  d    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
) W. K0 _# N5 F. T
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel1 I4 F; H& j! _7 Q
    Building a new DOS disklabel. Changes will remain in memory only,) {- }, q$ I4 I
    until you decide to write them. After that, of course, the previous; Q* C- s! W6 [/ g0 B/ Z6 a
    content won't be recoverable.# M( R: D/ ~5 ~- V
    The number of cylinders for this disk is set to 8322.
& Z0 K, {) H) H" R3 \0 n) K  K7 E    There is nothing wrong with that, but this is larger than 1024,
( @5 |' z7 t* i! I0 t0 q    and could in certain setups cause problems with:; Q$ p( W$ |2 x5 Y! @
    1) software that runs at boot time (e.g., old versions of LILO)
: w. f5 E8 s" T- @/ l6 |, E8 H    2) booting and partitioning software from other OSs
- f" }+ V4 z# ^7 c+ m       (e.g., DOS FDISK, OS/2 FDISK)5 [; Y# k: }% E' b1 ?( p
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)3 F, t/ n2 c6 |) ]
    Command (m for help): p& n, ^. k( k4 o+ C* k* u- W7 \8 A
    Disk /dev/hda: 4294 MB, 4294967296 bytes; x( _, K$ R3 f
    16 heads, 63 sectors/track, 8322 cylinders8 D- D# c* f( X9 {7 e
    Units = cylinders of 1008 * 512 = 516096 bytes! Q# H# P6 P) I; k4 |- F2 _+ F. G
       Device Boot    Start       End    Blocks   Id  System
4 W) C* G: U- ^    Command (m for help): m
  m1 N4 ]8 P  G  F" }    Command action
( N3 }, L7 t* y. i       a   toggle a bootable flag
& G5 K: Z1 x$ L6 x       b   edit bsd disklabel
2 V. g6 J- @0 ]  h6 N% `       c   toggle the dos compatibility flag
5 Y( }/ F! Z3 Z" }2 E) {/ Q       d   delete a partition+ H! J# m' r4 I" ~4 w
       l   list known partition types1 Y* B- G; W- L! U# x/ X
       m   print this menu" a- f. M  u( \5 \' _$ L
       n   add a new partition
" y: P& \) T: ~; o% k) o8 h       o   create a new empty DOS partition table
0 D0 p* }  d. \/ ^" t+ `1 A- y       p   print the partition table6 b) t. R4 i5 j$ S" V
       q   quit without saving changes
0 z. P) m- I7 g2 n8 o4 B       s   create a new empty Sun disklabel
8 f* A1 T0 ]/ F6 M/ v1 O       t   change a partition's system id9 H. J' Y9 L8 w; z1 X; w
       u   change display/entry units" ]! N3 {/ E" V% g$ u" g  k: n
       v   verify the partition table
+ h5 t, W8 D2 x/ M& D- B7 D/ i       w   write table to disk and exit
% C0 R  J' r+ l6 R* t       x   extra functionality (experts only)
: V. [5 m0 M: S3 C  b! |    Command (m for help): n
6 \& Q; f6 }9 T: e    Command action
1 t9 z/ n+ E4 {       e   extended- E5 [  H# U. ?' a5 i9 C
       p   primary partition (1-4)  z1 r% Z$ _% g7 R% D, j2 q
    p
4 g) J; L; e2 D$ Y' {( w2 Q& J/ Z    Partition number (1-4): 1: s3 G5 t& I- v2 Y" T
    First cylinder (1-8322, default 1):
* O3 n- A+ ^. T  c, e( N    Using default value 1
' s* H! K% a  i4 e; x    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
/ v+ i( o! x: p& A! ?0 @" O- b    Command (m for help): p
& L* a+ j/ J) A0 V5 O) d    Disk /dev/hda: 4294 MB, 4294967296 bytes
& k2 }; I% @- `+ Y5 I& U, y    16 heads, 63 sectors/track, 8322 cylinders: I( o% Q4 r$ P1 c' f
    Units = cylinders of 1008 * 512 = 516096 bytes
# y: R; r" p9 j       Device Boot    Start       End    Blocks   Id  System
; D# F% H  M( M& `6 s# I: q; U* M    /dev/hda1             1      1000    503968+  83  Linux7 f( \7 n8 l0 E2 y/ H' o7 Q5 j$ h
    Command (m for help): w
3 d* ^1 o; q- O6 u' X    The partition table has been altered!9 v& I/ |  _/ o+ [8 o
    Calling ioctl() to re-read partition table.
8 S6 k0 A( j" ~- e7 s8 D; h    Syncing disks.
6 p: Z$ }% k5 ~) l, W4 Q: S! D# o    //格式化新分区
: Z$ e5 x* }; L5 o8 o/ m
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
- @5 N7 G" v( M9 C) X' J# F! o    Filesystem label=! r- ~- x, I  K6 U; j
    OS type: Linux% Y" {9 Q% U: {& L  x9 W, O( ?
    Block size=1024 (log=0)
  B) k0 f1 O$ e) |/ e. @: m    Fragment size=1024 (log=0)
* T* [2 B4 _( N0 O, I# g! j7 d    126480 inodes, 503968 blocks
/ t' }: Z* z4 V6 |& w7 x+ j- P    25198 blocks (5.00%) reserved for the super user
0 M, s8 ?7 L* }    First data block=19 S! ^4 y4 R( ~) @: @$ P# Y1 j
    62 block groups
( T1 s; \- B4 z6 B, `/ p* A    8192 blocks per group, 8192 fragments per group: g9 C9 }2 D' r  N# @
    2040 inodes per group
( B- h6 y3 X3 D$ ]8 L. m" _$ E* Z# G! u    Superblock backups stored on blocks: $ Q2 U7 l) Y# b
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409, H0 R- b# l* G' V- v
    Writing inode tables: done                           
1 ]4 d; w0 M- n2 J3 O( z" z    Creating journal (8192 blocks): done6 w7 }% B; Z/ d, \
    Writing superblocks and filesystem accounting information: done
% O# Q" I/ P7 P/ s2 k% o    This filesystem will be automatically checked every 30 mounts or
  |  `  k: {3 ~" R& ?$ {, }- a! ~    180 days, whichever comes first.  Use tune2fs -c or -i to override.
: N  e$ g6 [* u+ t, D3 ?  z# M* {
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
3 _- |' @$ n! h: h2 I    /dev/sda3              3723848    705992   2828692  20% /+ f& Q6 R/ V" e6 D% F
    /dev/sda1               101089      9274     86596  10% /boot
8 _4 E4 @* S* B6 \    none                     14520         0     14520   0% /dev/shm& Y, }0 Z/ t* O4 o. Q# W
    //挂上新分区
/ u* g% {, P  P( l$ D4 B) J' W
  1. mount /dev/hda1 /home/ c% T) _! ]3 O, p
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
0 |9 ^( S- |/ W    /dev/sda3              3723848    705992   2828692  20% /
" B5 y& j: i3 ~# I2 }0 q    /dev/sda1               101089      9274     86596  10% /boot: s* N3 {, q1 g9 ?1 _- G4 g
    none                     14520         0     14520   0% /dev/shm  m. w/ d, p- Z
    /dev/hda1               488006      8239    454569   2% /home3 \3 |* Z" ^; w! U+ f( p

3 R) [% u  [, f1 _" ^( Y- M自动挂载:; }, \) Z( W9 U2 k* E1 X8 D/ O% L
  1.           vi /etc/fstab8 n" x+ d. m8 Q, D% X. Y) _
  2. 2 j) [* m! Q/ f5 G; `
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    9 H( _; z6 |% @0 E; _

  4. + Z7 m$ a5 r" S' c; ]
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
5 x1 T* u  {( G  X" U: @- V
  1.           mount /dev/sdb5 /mnt/ljp1
    1 L; o: _) J8 h3 o$ A

  2. 5 Y, N! z) n# n6 M9 F
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

* V' b+ J8 O4 O, d# G% c5 `6 N9 n: a" I9 ^/ z
3 A2 I' F& X* d& |- l* y+ \0 H7 I; X# G9 q- F6 h3 D2 J8 h0 J9 a0 d
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-11 01:33 , Processed in 0.023015 second(s), 6 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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