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

 找回密码
 立即注册
查看: 2784|回复: 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), Y5 Y5 o* b# p% K) Z' G) b% U7 p  k
      or: fdisk /dev/sdc  (for the third SCSI disk), W# |) l% y. f4 k- s- a; L
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)) y- k# d; u4 h1 D& e' B
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
" f& H. A7 ^6 M; Y4 G; g      ...
2 C5 b% q+ X2 u. y+ J
  1. df -k
    , N- K$ q5 R* |& L+ c
  2. df -lh
    4 B' o$ s' P+ W" o
  3. 查看有几块硬盘:fdisk -l* C2 h7 {2 q' h
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点' s  @0 [$ b9 a1 c/ {( E
    /dev/sda3              3723848    705968   2828716  20% /
3 ~9 x: S7 h( q. o& N4 g2 J& [; d5 W    /dev/sda1               101089      9274     86596  10% /boot
1 D! j$ X1 P/ ^5 V5 L, z    none                     14520         0     14520   0% /dev/shm# u8 k, [) M, h& A6 g" \& ^3 G( }
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用/ v5 o+ ?- x$ }# u- i
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel8 j0 M2 j( [/ g
    Building a new DOS disklabel. Changes will remain in memory only,
6 s9 l$ J% L0 F, ]8 I( H, `$ w    until you decide to write them. After that, of course, the previous
6 \# {0 }' I8 ?# M9 ~    content won't be recoverable.) F" i" q% A# @6 P" g5 ?; h
    The number of cylinders for this disk is set to 8322.
* R+ m) p: |$ w* t0 T% g5 B$ I+ ]    There is nothing wrong with that, but this is larger than 1024,
5 Y; _) m1 u' K2 m) u- I3 {$ L    and could in certain setups cause problems with:$ p, b- [! x- `5 w5 K" H8 n
    1) software that runs at boot time (e.g., old versions of LILO)
! V: a- p1 p& V$ V/ R/ W    2) booting and partitioning software from other OSs
/ ]4 S$ i5 M) j1 `  K- O$ k7 y. m! h       (e.g., DOS FDISK, OS/2 FDISK)+ ~+ _4 N; x3 e/ A+ M) s
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
4 b1 Q+ v6 G! e1 _2 o1 s    Command (m for help): p: x3 Z  j1 D1 _% X
    Disk /dev/hda: 4294 MB, 4294967296 bytes
6 O+ M1 U! r, t% |: |    16 heads, 63 sectors/track, 8322 cylinders/ [# l- f0 y, G+ M7 w2 R
    Units = cylinders of 1008 * 512 = 516096 bytes
+ R" p8 g  {3 T; O  v  }3 R% @       Device Boot    Start       End    Blocks   Id  System
3 V. ]2 p: W+ e* l0 @    Command (m for help): m
" E$ |2 L5 _8 l    Command action( ]8 z5 T4 O( M+ u
       a   toggle a bootable flag, J* D! n9 Q  L& }0 p
       b   edit bsd disklabel
" e2 J- |* K8 r2 f; G; t       c   toggle the dos compatibility flag
/ Y5 @4 [7 N" z       d   delete a partition
1 N5 S) n; f; P, v% s7 j       l   list known partition types  `' @2 y. J; h- c2 T
       m   print this menu
; h' V/ m3 ?+ a  C7 E       n   add a new partition! K$ j$ }+ M4 q" ^7 Z
       o   create a new empty DOS partition table2 }( ]$ j( k1 n9 m  A: I
       p   print the partition table) d4 _, D: K3 n7 @3 l
       q   quit without saving changes
" o1 h$ K/ q0 I  _8 b4 G       s   create a new empty Sun disklabel
9 q: b$ j) f0 A& N' X7 j       t   change a partition's system id' K2 [- H9 M' {" ~  R" a
       u   change display/entry units
' m6 N5 A" k& e1 q       v   verify the partition table
8 p  k" A6 K1 O8 ^" q/ \6 s       w   write table to disk and exit0 A6 Z/ u/ E# b, Z+ r) C! y0 h
       x   extra functionality (experts only)
& C5 F) x' k2 e    Command (m for help): n0 R$ v8 \& [, _# e
    Command action6 F8 m1 p% R# |6 q! q8 G& e$ S* a
       e   extended
1 L, n  _2 d: l  F8 v2 t       p   primary partition (1-4)
- \" b) x0 u' [    p& `4 g) c) R" ]
    Partition number (1-4): 1
9 `5 h8 Y$ |7 |7 S% a- ~$ w    First cylinder (1-8322, default 1):
; E; a  ~2 H3 p5 u3 K& {4 u* [) j    Using default value 1
' }* k8 J- t4 g- a: y    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
; m  u5 o0 D" O0 j5 u    Command (m for help): p) R, d' @9 O! J- C
    Disk /dev/hda: 4294 MB, 4294967296 bytes
. H- k+ b8 J) V5 o" _, Z    16 heads, 63 sectors/track, 8322 cylinders- ?! b2 E+ @( g' V5 S
    Units = cylinders of 1008 * 512 = 516096 bytes- X0 n2 V, m6 Y( B. P% ?- q
       Device Boot    Start       End    Blocks   Id  System
4 o$ `/ u. ]) N( I% A3 V0 V/ g    /dev/hda1             1      1000    503968+  83  Linux/ p. P/ @8 V5 Q
    Command (m for help): w
" d2 a; C- Z5 M* W, {. N    The partition table has been altered!. n3 F% w0 w+ {$ \3 H  d4 O
    Calling ioctl() to re-read partition table.  ]) E  R+ Z$ ]8 K
    Syncing disks.. x# p3 _. R4 X7 j) H, c
    //格式化新分区
+ G# M6 o% r* ?3 h
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
! [5 [" {, M. h6 o. {3 k3 G    Filesystem label=
; a: P; U& U& |7 r- t8 U  D    OS type: Linux7 M2 Y( y8 [6 M- k4 |
    Block size=1024 (log=0)
& }$ D7 S4 B" X9 O4 X    Fragment size=1024 (log=0)% N' G, ^$ |6 F/ p" c9 U- l$ R
    126480 inodes, 503968 blocks
- Q+ ~) T1 P, I3 Z+ A0 f3 p& M; y; ^    25198 blocks (5.00%) reserved for the super user3 B# h# ~  w# i$ n- }
    First data block=1
( J! G# B2 L6 g9 ~    62 block groups4 l- S7 H" N- E+ e. i
    8192 blocks per group, 8192 fragments per group  y7 D0 V  }8 y1 X1 D9 Z
    2040 inodes per group
* a5 W" M1 o0 G( c) V# z6 m+ H0 n' K    Superblock backups stored on blocks:
9 k6 w7 I9 r- x( S9 }- y9 ]4 n            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
. x& n" v- x; o. [, _8 x: {9 O    Writing inode tables: done                            8 O6 q( P# m7 ~# u- j/ `
    Creating journal (8192 blocks): done- y& R8 z3 P; m
    Writing superblocks and filesystem accounting information: done4 k5 h& V" v8 a2 j; c4 |2 k
    This filesystem will be automatically checked every 30 mounts or
; e$ }% V0 \4 z' A    180 days, whichever comes first.  Use tune2fs -c or -i to override.
* ^( m$ a$ j3 P# P
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
& h5 d) B! S) E9 }    /dev/sda3              3723848    705992   2828692  20% /* U+ i7 c6 k, {4 j
    /dev/sda1               101089      9274     86596  10% /boot5 X% }& K$ p9 q$ t: t, w: j
    none                     14520         0     14520   0% /dev/shm
% A& `5 u+ N6 {    //挂上新分区
. R" ]/ K+ u* l
  1. mount /dev/hda1 /home
    & Q  R4 m5 T. s" J+ H6 Q1 v
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
) G5 Z% T% x% {; e. ~5 j    /dev/sda3              3723848    705992   2828692  20% /* G: |% V, `' l" W
    /dev/sda1               101089      9274     86596  10% /boot/ S1 u- G3 V+ l& l
    none                     14520         0     14520   0% /dev/shm
9 c: k3 n0 g' u0 w8 [6 M    /dev/hda1               488006      8239    454569   2% /home
. E$ W3 v) p' E6 X9 O+ u2 r+ t' K
! {3 U- G( o# s% ~自动挂载:
# s- i6 B/ O7 Y
  1.           vi /etc/fstab
    $ T% G  ?" a% `  q" @' n5 q
  2. , w) K( U7 h  x
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    1 F; }! e) a) j" i
  4. + @. l' `2 I/ F
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:/ k, |- o* Q7 \' x
  1.           mount /dev/sdb5 /mnt/ljp1
    ! p; n: b) K$ I- M* P2 w1 ^' w. U

  2. 3 X; v5 |4 C5 O
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
" Q% f; e* j& B, Y" V3 a; l: \
/ f" d# j# u1 Q+ T7 E
; `% X% Z1 @2 y$ F3 j
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-15 01:07 , Processed in 0.007990 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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