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

 找回密码
 立即注册
查看: 2653|回复: 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); n- g4 w/ n1 D9 [3 q6 N1 N
      or: fdisk /dev/sdc  (for the third SCSI disk)
5 k# \* o1 R1 Z  l% q6 p      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
$ @& V# n; S# [! V2 r' k+ `' z+ A      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
  R4 P6 R* Q9 u      ...
3 S# R* N0 P7 N" h' q" ]
  1. df -k6 j& g  ^: w! t9 l$ ?
  2. df -lh( x: n7 @% ]3 f1 n6 R
  3. 查看有几块硬盘:fdisk -l
    % |/ g, e; [3 S& l( A& g
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点$ M; s3 s! {  ~" d) p- O$ B
    /dev/sda3              3723848    705968   2828716  20% /
8 D- U. h* Y2 b    /dev/sda1               101089      9274     86596  10% /boot! E8 x: T( Z- D& T6 _( V
    none                     14520         0     14520   0% /dev/shm
# f4 r- \# {5 S9 P$ @4 q- D8 }    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
/ ]" }" J; d/ \4 R8 v' ^; ~$ m0 U
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
) C, f- m9 r3 v) G! z% a    Building a new DOS disklabel. Changes will remain in memory only,
4 ?9 y7 }- N% I3 e    until you decide to write them. After that, of course, the previous& A4 P# d7 N2 ]! b. H
    content won't be recoverable.
) t# h6 ~- u% o- s2 A& S    The number of cylinders for this disk is set to 8322.
- }7 ~. J" D9 \- [    There is nothing wrong with that, but this is larger than 1024,6 X" f' u) c: H3 a0 E
    and could in certain setups cause problems with:' ]$ t  d/ W5 X8 G
    1) software that runs at boot time (e.g., old versions of LILO)4 x$ l6 W+ q, U
    2) booting and partitioning software from other OSs5 [0 t/ g/ B& {0 v/ T+ y
       (e.g., DOS FDISK, OS/2 FDISK)
$ m+ N; E! `6 k# u! A/ O    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)$ `: J# h# P0 T4 \; X
    Command (m for help): p
* r( P# r4 u: p1 K    Disk /dev/hda: 4294 MB, 4294967296 bytes
2 F5 j4 L& q, u2 \/ _8 v    16 heads, 63 sectors/track, 8322 cylinders
* H6 E! x; J( ]2 p    Units = cylinders of 1008 * 512 = 516096 bytes
/ _- p# y* N, s       Device Boot    Start       End    Blocks   Id  System
4 H% k) a2 _7 z, e5 K! w9 J  \    Command (m for help): m4 J6 d4 w$ M1 |1 G3 x/ }$ J/ `% ~
    Command action6 v5 `, `! q* @7 X: c* a
       a   toggle a bootable flag+ T' d7 @4 v: n% d' `7 n5 R
       b   edit bsd disklabel
$ ~$ D/ |$ v; d, s/ E       c   toggle the dos compatibility flag3 Q4 i4 ]: \# z$ G3 v1 e2 b7 i" p
       d   delete a partition
7 X2 z9 r9 w9 p* p7 {       l   list known partition types4 M9 k- p2 _# F3 u3 g) @5 m
       m   print this menu
7 F/ F+ t7 u; h! T+ F% e7 L; r1 w       n   add a new partition- }! {6 u' }5 v6 h! t+ X
       o   create a new empty DOS partition table
2 s$ `; [2 U0 U9 L  B       p   print the partition table
5 s6 z# q# p( z1 j       q   quit without saving changes" q/ M2 ^3 V3 ~
       s   create a new empty Sun disklabel# j: F; f- C; e: a
       t   change a partition's system id5 U% S- }9 c- n5 m2 }
       u   change display/entry units% {  {3 z+ ?, ?3 t* v+ x0 F
       v   verify the partition table$ f$ F- ?; o. t( R
       w   write table to disk and exit
2 ?3 ?, d2 t$ J7 X8 p6 G5 g       x   extra functionality (experts only)4 ?) m9 M" Z* \7 R! A, B
    Command (m for help): n
2 z8 [5 s9 z  u; S    Command action( d* x  q! `+ b9 {# z& g0 \* n
       e   extended( x! Y# h0 f' u% c! B" Q, B: h
       p   primary partition (1-4)
  y7 x. ?' ^) w/ r, m% V    p: r$ U( D5 N0 `2 b9 u% X
    Partition number (1-4): 1
6 {* F+ G/ V& n, c" y8 U    First cylinder (1-8322, default 1): 9 @" j' J7 w" {6 y& P# F/ V! J
    Using default value 1
5 L$ F$ f! V/ c$ y3 j. L    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G+ l0 ~" V* y% H9 T0 B* z) j
    Command (m for help): p
6 p+ ^$ h: L* y  Y, ]2 p, F    Disk /dev/hda: 4294 MB, 4294967296 bytes
& O2 f- s; N! R$ D* q% D    16 heads, 63 sectors/track, 8322 cylinders4 d8 D& o$ |' N. h
    Units = cylinders of 1008 * 512 = 516096 bytes
9 b1 P% ^* E% A% h. t( \- M       Device Boot    Start       End    Blocks   Id  System+ O0 }! V6 h2 b8 B  H: `
    /dev/hda1             1      1000    503968+  83  Linux9 E+ d1 I  l# r( }$ E4 _  O$ ?
    Command (m for help): w2 X2 q1 u/ E: g1 N: S# N0 d3 f$ n
    The partition table has been altered!
$ @, S9 _" p+ S" G8 F; B6 U6 r    Calling ioctl() to re-read partition table." q0 w* B4 H7 `+ {$ D1 u
    Syncing disks.
/ W/ F- H& t* ~0 ~# w% T    //格式化新分区( i0 g8 y" X" q9 n7 _
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)/ b- U& \* V: G. b
    Filesystem label=
8 N. @1 }" b- T: y* ^8 q, o% g: j- [    OS type: Linux& G: Y4 h; ^' L& o! p4 }
    Block size=1024 (log=0)
% \, @& x+ W, c- W% l* G    Fragment size=1024 (log=0)
3 m9 B( L- e: w; ^' \% y. n5 h* t    126480 inodes, 503968 blocks
+ _# Z7 D+ N/ H8 m/ }    25198 blocks (5.00%) reserved for the super user
0 ~" S2 f8 g, W; F    First data block=1
0 o  t8 C9 Q6 p* q) ?; U6 Y    62 block groups
/ c; Z/ I+ q" g; F    8192 blocks per group, 8192 fragments per group; T' f8 u0 q. j$ [
    2040 inodes per group
3 ]! X+ j, t# Q9 P; J$ n    Superblock backups stored on blocks: + W% d) D( G5 U* {
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409& h( B( Y( Q6 @, J. r  g; r
    Writing inode tables: done                            & M+ `; B% L! r! [9 ?/ n9 h
    Creating journal (8192 blocks): done
. K# L$ u9 }8 w+ L: O    Writing superblocks and filesystem accounting information: done
3 S* z$ X  C  m4 m# j* w6 }    This filesystem will be automatically checked every 30 mounts or$ v7 m% m8 \9 i
    180 days, whichever comes first.  Use tune2fs -c or -i to override.3 h) A# z' i! b+ F2 t% C
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点; I; \6 c) V9 H$ d! \
    /dev/sda3              3723848    705992   2828692  20% /
; y& w: Z. O4 P% W9 Q. F    /dev/sda1               101089      9274     86596  10% /boot
( ]/ f$ o" v/ E7 g2 Q$ ]( L' B    none                     14520         0     14520   0% /dev/shm
) q  u- _1 C- x0 `/ f    //挂上新分区( e: y! v! Q; b- s5 A9 Y
  1. mount /dev/hda1 /home# v6 f3 w1 [( ^/ K3 L
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
3 j; e6 \4 ^! _! K  P    /dev/sda3              3723848    705992   2828692  20% /
& m0 g) S( K4 O/ f    /dev/sda1               101089      9274     86596  10% /boot9 a; j! E5 @3 o, W1 N7 w3 ]" s
    none                     14520         0     14520   0% /dev/shm* t# P+ @7 M. `
    /dev/hda1               488006      8239    454569   2% /home/ y6 Q- }! R- D" Z

: b7 ], ~# T( O  _: W8 ^/ a2 Z自动挂载:
* v' W8 I, |5 f
  1.           vi /etc/fstab/ g! F. E1 d1 Q% x  c- `5 B5 h
  2. % S$ c: s" Z$ _1 |2 O. b. u" U
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    # H# n9 \% Q4 s6 n

  4. 0 Q) w7 I# Q2 e! A# k
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:1 R; y3 m# P- T9 A. v$ Q; p$ d
  1.           mount /dev/sdb5 /mnt/ljp1
    9 \4 a! A+ m; m; S# F  Q/ W
  2. ( W) X$ n+ g$ r0 o9 X, f
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

2 n; f3 I0 y' z6 z
. T% Q6 u& D: N, [  ?0 g% \; A3 I0 i' Q/ Q) ?& ?4 j+ f8 z' k# i: w
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-8 03:17 , Processed in 0.029152 second(s), 10 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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