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

 找回密码
 立即注册
查看: 2705|回复: 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)
" E5 \, e' {( `) Q" _9 J# @      or: fdisk /dev/sdc  (for the third SCSI disk)
. {. ]6 n% v7 e3 G: C) p      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
& t, }( C" Y' a3 p      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)+ I# j5 @8 T) v( `; o
      ...
$ {: C2 h8 s0 V  V6 H1 X( r
  1. df -k
    - B+ l# ?( g$ g7 U, s! }
  2. df -lh4 L, S' d' S* E
  3. 查看有几块硬盘:fdisk -l
    0 P/ U8 C% h6 i0 ?! W5 Q
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点, j/ T  y% z/ j) q8 b* \; a5 N
    /dev/sda3              3723848    705968   2828716  20% /
% Y8 i/ X0 F6 I2 p! z    /dev/sda1               101089      9274     86596  10% /boot6 R% Q$ Z. b3 ?' m$ P. I  O
    none                     14520         0     14520   0% /dev/shm
5 _+ g; N4 P$ @0 l1 a    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
4 ^0 r( p0 N5 N$ {! O* Z0 ^
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
% z! m7 q; f0 g    Building a new DOS disklabel. Changes will remain in memory only," r1 p8 H; x4 M3 U& K" B
    until you decide to write them. After that, of course, the previous9 z9 b! s5 K, f) w; ^# V1 z
    content won't be recoverable.2 g. X7 k7 `$ [: m
    The number of cylinders for this disk is set to 8322.
5 L2 ?: K  l% I: K- W) L    There is nothing wrong with that, but this is larger than 1024,) }4 M) T$ w2 U- q8 |
    and could in certain setups cause problems with:
1 R9 x+ G9 s% l( I    1) software that runs at boot time (e.g., old versions of LILO)
3 N$ q' O3 [4 \8 b/ d8 o" @    2) booting and partitioning software from other OSs
8 o. j( C8 \7 r/ x* T7 f       (e.g., DOS FDISK, OS/2 FDISK)
( Q+ p$ y# Z' o    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)# e. M; M1 }' }. H. p
    Command (m for help): p- X9 q  `; S2 u3 o. M* v- U
    Disk /dev/hda: 4294 MB, 4294967296 bytes3 A" s5 o) d% K* J
    16 heads, 63 sectors/track, 8322 cylinders
3 b8 K) y8 O, \3 J5 {    Units = cylinders of 1008 * 512 = 516096 bytes
  t! l0 T" U. K, Z       Device Boot    Start       End    Blocks   Id  System
/ P. P) p. A' C4 b! |7 K$ a4 a$ C    Command (m for help): m( G, d  }+ U+ Q. ^
    Command action( \1 Z, k( \4 t' W, S' O, q0 J+ ]
       a   toggle a bootable flag
1 f5 C# D! p3 n3 \: X0 a       b   edit bsd disklabel
% V/ J+ i, ^! L& M+ Y       c   toggle the dos compatibility flag
: Q# [' ^& J5 I$ T* w: o4 S1 v       d   delete a partition
/ c: ~3 S7 t2 y1 e# O( s8 }       l   list known partition types2 I# |  [3 m) l' Z& A
       m   print this menu
. N1 J7 ^% x7 ]% }       n   add a new partition
3 q9 S+ Y" r9 F$ d) W+ F' k) B       o   create a new empty DOS partition table& c7 o: Z) v0 W% E, {: O& j
       p   print the partition table
1 j. |, b  N1 r% }0 `& c       q   quit without saving changes
+ }# w* N+ e2 r" B       s   create a new empty Sun disklabel5 F( d1 Q4 m+ }/ v/ L5 z
       t   change a partition's system id
; \/ K% S9 f1 i$ m* }% p& G       u   change display/entry units9 V( [# ?7 m! _) m& n' r
       v   verify the partition table8 |( g4 o& m! m6 k! }# L2 u
       w   write table to disk and exit: [) j" B. q6 D, }" a
       x   extra functionality (experts only). p1 M+ X% [! P+ {  a
    Command (m for help): n8 A. H: t) G; o
    Command action
# a0 _& \: @, T1 d, O. F5 U       e   extended: c( ~! W  s8 V( G5 k
       p   primary partition (1-4)
" h/ V3 w) _0 M( s    p
/ y- B/ Z8 S% r0 y4 q+ |( \+ v    Partition number (1-4): 1' v' b- q6 ?/ A9 A: \- ]0 F3 z
    First cylinder (1-8322, default 1): ' g4 Z* [+ w, K% r% J* ^3 @
    Using default value 12 _( \5 u4 p  Y! W
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
% t0 @4 t1 P0 z$ |( W    Command (m for help): p4 @) L2 d" `+ Q% @& @1 Z4 e% h
    Disk /dev/hda: 4294 MB, 4294967296 bytes5 H2 {" U$ K& U8 G6 O
    16 heads, 63 sectors/track, 8322 cylinders8 W6 v  h  [# Q3 x3 g  T
    Units = cylinders of 1008 * 512 = 516096 bytes
' V" U6 v" Q: D# X& X       Device Boot    Start       End    Blocks   Id  System
8 v( P: O& B+ J0 D    /dev/hda1             1      1000    503968+  83  Linux
# v- H* p, L/ o/ `1 N  H: ?    Command (m for help): w% d5 y( I+ U7 z! T1 j3 s, R/ a  I
    The partition table has been altered!
# T. |- C3 V. \' x" {8 _    Calling ioctl() to re-read partition table., J# t: e" L- N3 v, V' m$ [
    Syncing disks.4 Y$ A; p' V% t5 `
    //格式化新分区
9 ~& C) L3 {- L# ~( v
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
) c6 r6 J  q/ T" V* D" Q- D8 Q2 W    Filesystem label=
) ]) d, D, w- M+ c    OS type: Linux
- M5 C+ t& i1 d7 o7 G2 C, e* b# z    Block size=1024 (log=0)9 f, j  G/ ~9 W3 l8 N4 y
    Fragment size=1024 (log=0)
* Q; ]; f, p4 M* x    126480 inodes, 503968 blocks. ~! C% }" ]) K& {
    25198 blocks (5.00%) reserved for the super user" S, |) u$ r7 u, w$ _' W4 \! N& ]
    First data block=1! `3 h; Z% i7 ?/ Y9 Y1 \) |/ c
    62 block groups. \6 ?, Z) j: v" S  ]/ {  Q
    8192 blocks per group, 8192 fragments per group
* @, j( A1 u" h1 V9 x    2040 inodes per group
: B# K9 M' f' l% f9 r5 r! P% Z7 w    Superblock backups stored on blocks: 4 z3 {/ |2 P% P! ~4 I
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
" q4 H: t& A8 ]1 ]4 i5 C* k, _; o    Writing inode tables: done                           
) |/ x8 R% S- o: {7 Y. @; N    Creating journal (8192 blocks): done2 d4 s8 i7 B% c( _$ X% T0 u
    Writing superblocks and filesystem accounting information: done
% M' o1 N" R$ W1 S    This filesystem will be automatically checked every 30 mounts or/ e/ |! C' |4 n9 _6 g9 X* }
    180 days, whichever comes first.  Use tune2fs -c or -i to override.6 \; G2 U/ t0 G0 s' }" Z
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点/ E' @3 }1 @; Y) _
    /dev/sda3              3723848    705992   2828692  20% /  x0 g/ P9 ^+ u$ O, r0 E
    /dev/sda1               101089      9274     86596  10% /boot
9 [0 O4 t% q. K  I8 i7 a) W    none                     14520         0     14520   0% /dev/shm' t" T) X% \7 Y% ~9 N
    //挂上新分区$ }" ]$ D, C9 {6 D! f% m+ U3 R
  1. mount /dev/hda1 /home
    6 ^% W, c7 R0 F
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
0 O, u5 U  _/ q) v' G    /dev/sda3              3723848    705992   2828692  20% /
1 F# A, x) {; o, ]: o    /dev/sda1               101089      9274     86596  10% /boot
8 P9 E3 i- D/ H3 O+ u- F    none                     14520         0     14520   0% /dev/shm
  H, E' h7 k, S* l    /dev/hda1               488006      8239    454569   2% /home
$ ?3 t& B$ b$ o7 n3 ~6 F, `+ z5 h+ ?
自动挂载:
% g4 R7 ]) W3 u' I& H
  1.           vi /etc/fstab! T) D8 D+ _$ o9 f3 z
  2. # y  g+ {, r9 ]; n
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    0 M6 a, H4 H# S# T5 C% S; ~8 h
  4. 6 d# e; r" ^( h& @' E& p% k
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
! d/ Y  u- Z. y. X% K9 D% O
  1.           mount /dev/sdb5 /mnt/ljp1( |! P. N7 G9 U. n0 a5 D2 }
  2. / V. v7 u2 C3 }& m# Y- J% Y
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

0 r: I, {' t4 r8 L7 ]- v: T8 `  W# \
' c$ {& I3 A0 {! r1 j2 z$ J4 \" N$ B# S5 A; a
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-23 05:08 , Processed in 0.038321 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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