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

 找回密码
 立即注册
查看: 2637|回复: 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)0 Z# ^+ L* X# B( o' K
      or: fdisk /dev/sdc  (for the third SCSI disk)9 k( m' y6 }9 ?" F# X7 n
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
; h5 M. |! r  @% F  V0 }      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
* Y& j# E: C; ]9 V3 M. F      ...) F: Z3 g0 F- H' ~
  1. df -k9 w# X# }3 [) i+ w6 B# p
  2. df -lh  f' C; w/ |6 b5 a6 A! g
  3. 查看有几块硬盘:fdisk -l
    3 r" B3 S8 j9 n
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
/ C6 ]3 c; z6 O8 G; T    /dev/sda3              3723848    705968   2828716  20% /  Q+ `  L/ G# n
    /dev/sda1               101089      9274     86596  10% /boot$ ]: X( m/ i1 j
    none                     14520         0     14520   0% /dev/shm6 E  r7 R" Y* y2 Q
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用! O/ X9 _, g& M, F9 g
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
  Q* Q4 f# i+ m/ `  T    Building a new DOS disklabel. Changes will remain in memory only,' I( {9 x. \3 z5 t) q; |
    until you decide to write them. After that, of course, the previous1 {# o- V. I. C" K6 T
    content won't be recoverable.
6 X# |2 [5 o, M, \% J8 D    The number of cylinders for this disk is set to 8322.
7 O, _8 A- n9 \3 |    There is nothing wrong with that, but this is larger than 1024,
: S3 A1 f% R1 B8 t1 S    and could in certain setups cause problems with:2 m" R6 i9 D3 \
    1) software that runs at boot time (e.g., old versions of LILO)# ~, }7 u4 P9 D! }
    2) booting and partitioning software from other OSs
2 u* F5 j9 A' o       (e.g., DOS FDISK, OS/2 FDISK). r" R! D: o" I2 U
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
  g. e4 p& V  [; `1 b8 q4 V# h/ y    Command (m for help): p4 y. u: `. g5 u- ?3 y' A0 Z1 S
    Disk /dev/hda: 4294 MB, 4294967296 bytes
9 g. K" l+ }. ]  x& R    16 heads, 63 sectors/track, 8322 cylinders
5 @* |/ X0 g* s0 F, b' ^9 i    Units = cylinders of 1008 * 512 = 516096 bytes8 _+ X4 `$ N. N& }$ j8 A% {7 A& |
       Device Boot    Start       End    Blocks   Id  System
; @% W# b# L' `. X/ z    Command (m for help): m
1 i, @# g! z6 W0 x! s& Q5 ^  Y- o    Command action
7 H8 `9 |& ?# J1 l0 ^: K# R6 ^       a   toggle a bootable flag* l7 a5 Q8 r. I- S8 M; h* b
       b   edit bsd disklabel' t( L" g4 M% x4 A0 q6 Q# P
       c   toggle the dos compatibility flag9 A9 ]) j# b% i8 f, i
       d   delete a partition
9 J0 f. ~  J4 }! X       l   list known partition types
7 t' K/ V5 k! f: e3 u; q6 K: l       m   print this menu5 ^9 Z# J/ k. {: o9 b" F
       n   add a new partition4 |! S9 g1 `3 F
       o   create a new empty DOS partition table
5 m4 S* d1 q0 k7 i. I       p   print the partition table$ j' d% }9 i' H- Z# q
       q   quit without saving changes
2 {8 }6 D4 W8 W. a+ e/ j- f       s   create a new empty Sun disklabel
! U: F+ h, v7 R2 ]) f& w       t   change a partition's system id  N* K2 @% S% A
       u   change display/entry units8 ?3 ^: B: A7 c$ v
       v   verify the partition table; V3 c0 A) B9 P6 f) c" z
       w   write table to disk and exit2 H% ^, p9 Z  h
       x   extra functionality (experts only)$ s8 R( N3 G4 A2 \# }3 v$ g
    Command (m for help): n) J4 u& {- L  m8 O2 b
    Command action
9 r& I8 I. ]  B( A. I5 {* l       e   extended. f2 |. J/ ]8 [. M, u
       p   primary partition (1-4)
) q' S0 m6 H! K    p3 ^$ |4 Z5 ]! ]/ W, L; c
    Partition number (1-4): 1
% T" g- F1 r" ~9 Z) Q9 W    First cylinder (1-8322, default 1): 0 i1 K+ t, e% {4 |# M6 I1 a& H
    Using default value 1
. b' y' n$ i$ K1 e( O% u/ R- J3 Y    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G# y" G) ^; m! [% _
    Command (m for help): p& ~8 g  R8 z3 X3 n. j
    Disk /dev/hda: 4294 MB, 4294967296 bytes: j( q- j' V& c! E, |( S8 @
    16 heads, 63 sectors/track, 8322 cylinders. W# e! e- f9 W! P/ v7 M$ H5 t; a- c
    Units = cylinders of 1008 * 512 = 516096 bytes5 s& ~$ v. D+ _$ V
       Device Boot    Start       End    Blocks   Id  System
1 L4 e8 _% c: r* C6 A" X, l. ~    /dev/hda1             1      1000    503968+  83  Linux2 O; l6 z( V2 T1 m' x
    Command (m for help): w; b# F0 Z6 s7 R- H
    The partition table has been altered!, _: D9 E. H! Y. |# v" l
    Calling ioctl() to re-read partition table.
6 `& P# \) m8 B! I: M  r. k    Syncing disks.' F7 u9 |0 t8 W" f
    //格式化新分区
$ g2 `' X# S6 ^% {1 l7 Z
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
- _/ O9 d$ c5 l; y  r1 e+ @9 K" w' X2 E    Filesystem label=
3 `  E) J1 h! E) h$ r& \    OS type: Linux
& c2 k9 e4 n, a; E5 z0 G    Block size=1024 (log=0)
& m0 p2 l4 w/ i4 @) x! N% o    Fragment size=1024 (log=0)
3 N) ~0 V7 @  T$ J    126480 inodes, 503968 blocks* S9 k/ a5 H; S/ R
    25198 blocks (5.00%) reserved for the super user
' I/ y5 }! j% m3 R* ?8 S    First data block=1
5 R2 A4 |+ q/ l3 V- ]: I' i, U    62 block groups
- F0 G0 M  d/ C  D5 G$ m    8192 blocks per group, 8192 fragments per group0 E7 X# A& N; K6 e& @( u/ g
    2040 inodes per group
0 e4 R6 o' Z8 ~' r2 M) R. m    Superblock backups stored on blocks: 0 j+ c5 P  h- N5 H7 V! |. h0 ~, I  F
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409' G- f" \; x3 A$ N
    Writing inode tables: done                           
$ Q- a* T& _' o( d    Creating journal (8192 blocks): done8 X1 n' M& [; B
    Writing superblocks and filesystem accounting information: done
$ Z; [- J$ o4 \  X+ s    This filesystem will be automatically checked every 30 mounts or- L2 x# s* X# S+ c3 Y
    180 days, whichever comes first.  Use tune2fs -c or -i to override.1 g# z0 s. ?  R5 P4 h' E! }6 N$ T1 T
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
( [; s) b- ~; V5 M* q; h  x    /dev/sda3              3723848    705992   2828692  20% /+ B$ W/ N( ?7 {# l
    /dev/sda1               101089      9274     86596  10% /boot
1 E# \& y! N2 ?) P7 y    none                     14520         0     14520   0% /dev/shm4 v3 \7 u" {  w" r1 x6 r0 Z
    //挂上新分区- [4 O% E0 z  X9 Q
  1. mount /dev/hda1 /home
    # w; K, {3 {$ s; Q2 V  v
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
, D9 L: ^7 F# d, T7 |    /dev/sda3              3723848    705992   2828692  20% /
  J# N: o: {. i6 `, r    /dev/sda1               101089      9274     86596  10% /boot! m9 ?. f! B( z3 Q! s! K* O8 E
    none                     14520         0     14520   0% /dev/shm4 E. W' _8 W7 t) m
    /dev/hda1               488006      8239    454569   2% /home
: u" T) }( z% ?  S& F) @% s! y0 N8 P5 O
自动挂载:
7 I+ B9 o1 {6 }& N
  1.           vi /etc/fstab
    . C1 Q# \0 ^. c  ?. s

  2. ' g: B3 q2 ^* Z* I5 D1 g9 f
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 08 h- L2 ^: Y  }" q. A: m! ~) E
  4. % T) P5 V# V) r8 M, J  z- ^0 J
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:: s4 x4 \2 ~0 v
  1.           mount /dev/sdb5 /mnt/ljp1
    . P) x$ x* [, @8 Q( i# U
  2. : \3 x4 S8 }2 c1 g4 V4 Z0 ~
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
6 o3 o0 J$ i2 T) R( j

6 T/ }0 [8 Z+ o/ V6 t7 g( `8 H
8 t$ F8 ~4 Q# m5 w$ H
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-4 20:57 , Processed in 0.018849 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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