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

 找回密码
 立即注册
查看: 2615|回复: 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)
$ [) i4 C+ f4 u! y5 x1 U5 a# g4 a2 A      or: fdisk /dev/sdc  (for the third SCSI disk)' x" c6 o  @' |( M8 m
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
; \5 {* g2 O7 p+ M# N. d      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
3 y' R1 k& i9 e6 `      ...
1 |! S) Y$ ^3 {7 T5 [( C
  1. df -k
    ( C& b8 ~! o4 ]' m
  2. df -lh: j. u- M3 L2 {" r& U
  3. 查看有几块硬盘:fdisk -l0 @# S; _+ P9 o1 f, R& g
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点. l3 N) |/ U% o6 w) X8 n" P) k1 k2 t1 ?
    /dev/sda3              3723848    705968   2828716  20% /" i% |1 m5 `; d0 R, v& V, W
    /dev/sda1               101089      9274     86596  10% /boot" C" N3 M9 g, z) Q- y% y$ U
    none                     14520         0     14520   0% /dev/shm
! m9 |+ v8 ]4 e# y, I% q0 n    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
8 f. `7 ?/ `  L- v% A2 y
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
1 R; s4 t0 f0 b( T: i, g' j- I$ b    Building a new DOS disklabel. Changes will remain in memory only,  D% k( F, M, C0 M. k, `
    until you decide to write them. After that, of course, the previous  v/ O& g6 B) A7 ?" d* e
    content won't be recoverable." s$ l8 m$ N/ e. t" k  Z
    The number of cylinders for this disk is set to 8322.
- @0 ]: R# S+ |1 ?6 m7 k    There is nothing wrong with that, but this is larger than 1024,' M  H8 _& ]3 v
    and could in certain setups cause problems with:
+ T0 |2 X( `% \1 ^! {* ~$ N    1) software that runs at boot time (e.g., old versions of LILO)# o0 M3 \: b. s' m; y% }8 `+ J
    2) booting and partitioning software from other OSs
$ V+ c; }$ B+ b/ ?6 d( l. Y       (e.g., DOS FDISK, OS/2 FDISK)' W* e" \! V: U- \. ~, ]
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
& N  R! x% i2 K! C4 _$ r, }2 G    Command (m for help): p
2 D; u0 i, u; P; s9 B% \1 O. c8 N    Disk /dev/hda: 4294 MB, 4294967296 bytes
0 r: U7 ?# q$ p  q! f: o' D: T1 Z    16 heads, 63 sectors/track, 8322 cylinders! S6 h) N, X; ?' C: N: [
    Units = cylinders of 1008 * 512 = 516096 bytes$ ?# I. N+ o0 ?
       Device Boot    Start       End    Blocks   Id  System0 ~+ p# f0 m  l) O8 b
    Command (m for help): m, U. f1 c6 r4 M5 C3 T/ r) t
    Command action
$ q. i# @& s  D+ E# M       a   toggle a bootable flag' q- R0 S+ a/ U  k7 c0 {
       b   edit bsd disklabel- R5 ?5 E8 H- `/ c* l5 t5 d
       c   toggle the dos compatibility flag
1 g; M* w. I& z; J" d7 z       d   delete a partition% \$ g: j3 @' P4 ?7 a( b- N: F/ E
       l   list known partition types; a( k+ \- x3 p( O9 n. R
       m   print this menu+ r1 Y9 q5 l5 L: a2 Y
       n   add a new partition0 x" q; p. q4 u& N1 {# p4 h5 T
       o   create a new empty DOS partition table
3 d$ y+ Z& R8 d+ A* o       p   print the partition table
; c; y# x4 @+ t- l       q   quit without saving changes- H6 b7 _) X6 ?0 o% S7 t, k& B% t+ _
       s   create a new empty Sun disklabel
0 E# j) }* ?7 T1 c) {" o# Z" u       t   change a partition's system id
3 F4 w8 m, }3 `  ~# t5 ]       u   change display/entry units4 r$ Q! q5 ?2 j% s& f
       v   verify the partition table
: V8 p9 `$ X" W3 T  T       w   write table to disk and exit* m8 w% ?' _6 `
       x   extra functionality (experts only)
% c8 s' N; a* I2 D    Command (m for help): n0 U! V8 i  ]4 P* b4 V  {/ A
    Command action
0 J9 |5 W9 X3 |) R3 L) m, h/ `8 Q# L" _       e   extended, i  `: e- b* G5 D6 Y
       p   primary partition (1-4)
1 X  M2 V- N9 v0 ]1 J    p' w3 [. z3 s. P2 E# Y
    Partition number (1-4): 11 L* s, [2 |! D
    First cylinder (1-8322, default 1):
; x; e) h. P2 k6 I! J    Using default value 17 ^, M* L' z1 Z5 I2 ]# c! ]
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
/ g$ Y# j1 g9 C! ~* \    Command (m for help): p
/ W1 T4 S1 m& h  D# \+ n4 P    Disk /dev/hda: 4294 MB, 4294967296 bytes
5 B. P& T5 _: c7 g" a1 f  l    16 heads, 63 sectors/track, 8322 cylinders7 o9 i. F) ^1 ?) `
    Units = cylinders of 1008 * 512 = 516096 bytes$ `" O1 I  g$ N4 m" Y
       Device Boot    Start       End    Blocks   Id  System+ u, D$ [9 m) P' d
    /dev/hda1             1      1000    503968+  83  Linux
$ K3 D! `7 N5 c7 B8 Q    Command (m for help): w; ^6 m8 }, G* e" X
    The partition table has been altered!
0 v+ u9 A/ q$ j) x    Calling ioctl() to re-read partition table.6 i, x: A1 H( F
    Syncing disks.- P) q0 P6 i- D
    //格式化新分区
& t2 a2 R/ U8 _2 N
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
) U2 D6 n4 [5 ]7 E  ^    Filesystem label=" H% H# b7 [8 C7 x7 a8 D$ {9 U
    OS type: Linux2 w& s5 x) K; \/ a
    Block size=1024 (log=0)
' ^8 J6 T2 ~" k    Fragment size=1024 (log=0)9 r6 }- }' W: Z$ X4 y+ _
    126480 inodes, 503968 blocks
0 J8 f& D, ]. {6 g8 @0 X: f5 ~. P2 W    25198 blocks (5.00%) reserved for the super user- }5 r' V" K  I8 L! ^2 l' x; B
    First data block=1
$ e: W: N1 U  N$ t, Q* _    62 block groups- f9 z4 U  k8 m& R
    8192 blocks per group, 8192 fragments per group: O6 L6 ]4 ~1 ?4 r% u- l# m
    2040 inodes per group' A. ~* d/ |+ o" L2 H- E7 j3 ~
    Superblock backups stored on blocks: - H' T: V* x  K# I* f' Z
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
6 T  Z4 W0 f6 i: f    Writing inode tables: done                            6 p$ ]+ {  l  _2 }4 L, q" p4 N
    Creating journal (8192 blocks): done
, F& e" g2 ^8 v+ z$ w+ b/ n: f    Writing superblocks and filesystem accounting information: done+ I) b$ I0 v- x1 z
    This filesystem will be automatically checked every 30 mounts or  B# I) S, Z6 n( z( N# p: M
    180 days, whichever comes first.  Use tune2fs -c or -i to override.) K- t# s* ?  j4 W# B
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点+ L* E( I; ?7 Q3 Z& \
    /dev/sda3              3723848    705992   2828692  20% /6 Y3 M5 g' C  V8 Q+ V/ v+ A6 N& \
    /dev/sda1               101089      9274     86596  10% /boot
8 E5 D* o# G4 K9 u/ j# {    none                     14520         0     14520   0% /dev/shm
( B9 i8 n( r6 Z    //挂上新分区9 t1 U0 O1 O- R
  1. mount /dev/hda1 /home
    - n+ W5 h! I$ o$ f6 D' f+ W" B7 d
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点8 Z5 K# ?( _; B6 _  B& r1 J' _+ \
    /dev/sda3              3723848    705992   2828692  20% /
+ c" P6 c5 V* W; B" F. ^    /dev/sda1               101089      9274     86596  10% /boot
8 ^) w9 z, i9 u3 @    none                     14520         0     14520   0% /dev/shm
, d# }1 A1 E) X6 C    /dev/hda1               488006      8239    454569   2% /home
' S) z* F' y# F7 `- \" }. U- d; E) _& U( K8 [# W4 N8 I) E! [
自动挂载:- l5 J3 r. @$ H) J9 ~
  1.           vi /etc/fstab- K# V. n& B; P1 G% ^7 u2 `" `
  2. % W7 ^& h. v2 g" O5 N/ ~
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0$ _; i/ |) X% \
  4. 3 R# ~/ R9 \8 Q8 G% ]8 Q
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
! O9 x- s( k% J: y
  1.           mount /dev/sdb5 /mnt/ljp1
    / j8 D1 _* R  A  y7 H1 s

  2. 9 ?8 g% }+ p9 C* V
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
. d: s- g7 p; d3 G$ Q

' l, `: e/ e2 @7 G8 r6 U8 E! `9 M; R/ M1 j7 Y0 ~
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-30 03:05 , Processed in 0.034001 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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