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

 找回密码
 立即注册
查看: 2771|回复: 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)
7 _& _# D0 ^! ^  v5 W      or: fdisk /dev/sdc  (for the third SCSI disk)" o9 {0 K9 _; C9 `/ [& c
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)! {6 |6 Z' X: k. E
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
  V/ \2 Y0 z' }( Q      ...
) _( g6 x/ c4 p) m6 F6 W
  1. df -k
    1 z8 O6 j( W7 {! k/ M2 {' H& q
  2. df -lh' {% W* [/ v' {/ @$ j* T, I
  3. 查看有几块硬盘:fdisk -l
    # z  [  f1 H  ]: A7 C
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
! h: W5 |1 G8 K    /dev/sda3              3723848    705968   2828716  20% /2 f6 u) ]8 e5 X
    /dev/sda1               101089      9274     86596  10% /boot
  }2 s! e0 {' ~. x, K, E    none                     14520         0     14520   0% /dev/shm5 d" Y6 t/ v9 K$ R8 s9 N
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用+ E$ S7 o# X% O! H. i: R6 H% r
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
, J6 F' }9 |& h& b9 {; C" {* d+ ]    Building a new DOS disklabel. Changes will remain in memory only,
  S/ k/ J/ A- `, g    until you decide to write them. After that, of course, the previous" J/ t* g2 q7 m7 q1 I. ~! M
    content won't be recoverable.6 Q$ P* j6 F8 f/ r4 W4 m; y
    The number of cylinders for this disk is set to 8322.' R  Y- c) P5 j: C* v$ Z, p
    There is nothing wrong with that, but this is larger than 1024,
, Q6 n+ u4 g7 K7 J8 H; K    and could in certain setups cause problems with:; O! K" V. @) P) P
    1) software that runs at boot time (e.g., old versions of LILO)& `# A$ F$ ^! D5 B$ ~
    2) booting and partitioning software from other OSs3 z8 c3 C' @. ^- x( n' S0 n3 c
       (e.g., DOS FDISK, OS/2 FDISK)
5 T/ _' f2 q" H( @; ]6 Z9 d3 [/ H3 ^    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
3 g, Y' D2 {! |. ^9 ?    Command (m for help): p5 P' v6 r/ b+ e  Y" m8 @
    Disk /dev/hda: 4294 MB, 4294967296 bytes
$ h3 k7 M; s$ G9 @, H' [  q0 j$ K    16 heads, 63 sectors/track, 8322 cylinders* p( p& x; Y9 t; t" ^3 `
    Units = cylinders of 1008 * 512 = 516096 bytes
6 o0 c# l, j0 M4 f       Device Boot    Start       End    Blocks   Id  System1 E( s9 @/ }3 G/ T* o( N
    Command (m for help): m) K7 `9 F8 i8 K: g; u5 e* T
    Command action
  p0 f' R$ ]1 {& Q       a   toggle a bootable flag9 O* J" [; @0 \" b- V8 x5 ^, Z- G
       b   edit bsd disklabel
: f  X5 M* Z( E0 L; P& F/ B: S- T       c   toggle the dos compatibility flag
! e( m# x8 V2 Q9 n) X       d   delete a partition1 X. ^1 K1 d$ @. s: r9 R
       l   list known partition types# I0 v: ~' |& V; W& U' @
       m   print this menu8 a7 n) u) o; Z; C, ~- R
       n   add a new partition3 e- B1 _, a( c$ e; h
       o   create a new empty DOS partition table7 s. @, `# Z. i, N8 h4 ~
       p   print the partition table
" T4 q5 N, A! y0 _       q   quit without saving changes
4 x8 D7 [. ?. G! P% M3 w# [       s   create a new empty Sun disklabel
2 m) w5 |4 r- B1 d, @' ^, p# U  {       t   change a partition's system id- S! c( m/ {8 ^
       u   change display/entry units. P$ M" `3 C/ }; O& J  r
       v   verify the partition table3 V/ ?! b. a, q& W3 V  O! k
       w   write table to disk and exit
3 ~  |. d6 q) z8 X* U2 ], O$ _. ?7 r       x   extra functionality (experts only)
9 D5 C. ]' p4 K5 D6 q    Command (m for help): n1 p# r* z9 a3 q
    Command action: e6 {+ X( M2 h' |6 {7 G7 f& Y
       e   extended4 F) o, f9 W3 Q0 ?8 j8 v7 G
       p   primary partition (1-4)
# `0 v- l; S: t: u. V/ k( W8 Y    p
& ~' W8 p1 g) P    Partition number (1-4): 1
7 y5 H" J, H# B3 Z' D    First cylinder (1-8322, default 1):
6 r4 s! f" _5 ]' U7 Y5 o    Using default value 1( f* @. c) ~: ^- Y
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G9 q1 f# [! b. u9 Y
    Command (m for help): p0 c0 s! z4 l' [* ?* T1 F5 T
    Disk /dev/hda: 4294 MB, 4294967296 bytes; v* y! [; W8 l5 a/ E$ z+ Y
    16 heads, 63 sectors/track, 8322 cylinders
6 }+ z# D7 a9 v- X    Units = cylinders of 1008 * 512 = 516096 bytes
4 ?' ~8 k9 |& j6 T       Device Boot    Start       End    Blocks   Id  System
, W8 C: Z3 b  J) r: q& w    /dev/hda1             1      1000    503968+  83  Linux) e* A4 s. J* z
    Command (m for help): w9 w; b1 G$ D5 _: I% s
    The partition table has been altered!' Q: o6 ]+ J7 F2 P
    Calling ioctl() to re-read partition table.1 r5 I* R  `) z3 g; I
    Syncing disks.
* Z8 u9 H" Z. {0 P. }- [* N5 Z    //格式化新分区% ^# N/ h) f9 c0 L! S
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)7 [& [6 e4 d# z7 ]4 N. ~0 s
    Filesystem label=
& H0 D! ~5 w9 _# I; M; e9 S- S; {    OS type: Linux
; ^: k: J) @0 |% T4 \3 \) C1 T    Block size=1024 (log=0)8 B0 f: B6 g! Z7 g9 B
    Fragment size=1024 (log=0)4 P( v% y7 O0 B6 H% e
    126480 inodes, 503968 blocks$ G; @* ~; f9 ?9 C$ T' @& t6 P
    25198 blocks (5.00%) reserved for the super user$ s& l2 c- y- j0 [4 L
    First data block=1
; Y& x2 w! G9 p. k: U$ D    62 block groups
5 s/ F6 D$ U& |  L5 f5 z    8192 blocks per group, 8192 fragments per group
) U2 w/ Z( ?* M2 N) a8 d    2040 inodes per group; a6 U$ |# e2 ~- b
    Superblock backups stored on blocks: - k% A7 `6 S* `0 ?) _+ W
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409# B0 y" j+ y! X; }
    Writing inode tables: done                            & I; F7 s% ^7 s
    Creating journal (8192 blocks): done
; ^- m( p% H" [" Q* }+ Y0 m    Writing superblocks and filesystem accounting information: done# o( _7 Y1 X% S9 L" g( z8 i
    This filesystem will be automatically checked every 30 mounts or  Q1 {& ?4 b0 |5 Z
    180 days, whichever comes first.  Use tune2fs -c or -i to override.2 {* ]; a0 D$ s
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点' w4 i7 ?! U2 R: L
    /dev/sda3              3723848    705992   2828692  20% /& }# U" z* N/ m& c0 R, J; M
    /dev/sda1               101089      9274     86596  10% /boot& ^, q! b+ V  [( J) u3 [
    none                     14520         0     14520   0% /dev/shm9 e+ Y, J6 g) H- U/ `, @$ `
    //挂上新分区& W: }- ^$ A, `  p. a; {% o
  1. mount /dev/hda1 /home7 d; W1 v: y- ]/ T  c" H& A
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
8 Z) k5 w% U' G4 U0 y    /dev/sda3              3723848    705992   2828692  20% /
2 ?; b5 x) }3 G- A) ~- T* r    /dev/sda1               101089      9274     86596  10% /boot
( U  W% s9 }( G" B    none                     14520         0     14520   0% /dev/shm
4 W) k: s( A# z6 A% _    /dev/hda1               488006      8239    454569   2% /home" E. {- t) B9 ?( l2 I4 }- K& L  G

2 I  [- y: Z+ C$ h- M; Y自动挂载:% S; E/ S0 Z/ T0 u: ~& o
  1.           vi /etc/fstab( d& [" y& `- @* u
  2.   I" F8 Q' V5 k% V
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    7 \% I) y- }1 R3 y6 ]  w% L

  4. - q7 v% Q( q, Y" ~5 H2 {6 U6 E
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
( ?: E1 I. T$ ?4 x+ F
  1.           mount /dev/sdb5 /mnt/ljp1
    & u/ L2 H& @  x  ^; T% t' L
  2. * U7 `1 }$ |2 {1 ?  @
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
9 I* u- a0 Y0 N) r( z7 e
6 ]0 @$ j+ |/ Q/ J

5 g) z, e3 F" z- K% o
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-13 01:00 , Processed in 0.044757 second(s), 16 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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