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

 找回密码
 立即注册
查看: 2707|回复: 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)
* w+ ~, c" Y. X9 x3 a# h      or: fdisk /dev/sdc  (for the third SCSI disk)
, E4 g3 T. x7 {. |# E% k: z      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
/ `4 \( w9 A2 V      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)) q' ], |' q; S- K+ \4 }
      ...
8 ^0 B; b) y8 h3 t$ l; c' Q
  1. df -k* A2 l6 n1 P& }, \  a
  2. df -lh
    ' R* m: h- O# ^! H
  3. 查看有几块硬盘:fdisk -l5 Q% U0 L+ `9 D" J# w: u0 ]# s
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
" j7 a1 ?& g' h: f  N    /dev/sda3              3723848    705968   2828716  20% /4 E# J3 X. V0 @! l* x
    /dev/sda1               101089      9274     86596  10% /boot
$ J+ G' s8 t0 v7 d    none                     14520         0     14520   0% /dev/shm
9 Q1 I" K" S' e- `* P5 P  s    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
! |) e% b1 S8 N) e6 N  Y* \' F' T
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
& j7 U" ]0 e# @6 C* d- n    Building a new DOS disklabel. Changes will remain in memory only,
5 |# @0 y* J1 p    until you decide to write them. After that, of course, the previous
2 {# @9 d, k! z, w& J2 S    content won't be recoverable.# Y, e/ W* Z, {2 U
    The number of cylinders for this disk is set to 8322.
- h2 B* B  I- @- ?% ~( u: w! \    There is nothing wrong with that, but this is larger than 1024,
: G& F' v% n+ D& _    and could in certain setups cause problems with:
" n' X- ?% F9 O3 [4 L! L5 y    1) software that runs at boot time (e.g., old versions of LILO)
  q$ A7 o- b/ W    2) booting and partitioning software from other OSs
# P% k+ Q8 _! V' \       (e.g., DOS FDISK, OS/2 FDISK)7 ?4 F+ b2 P8 C! a/ [% n
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
7 I" ]2 K! K$ _2 D    Command (m for help): p( J/ r# s- E) w+ c. ^8 {
    Disk /dev/hda: 4294 MB, 4294967296 bytes
/ J' S. e4 `6 j1 J2 N' L+ _; C    16 heads, 63 sectors/track, 8322 cylinders
, h, x4 J: l' X( D/ R% e    Units = cylinders of 1008 * 512 = 516096 bytes! w9 }: e/ o! K; s
       Device Boot    Start       End    Blocks   Id  System
6 T$ L$ X$ b+ c5 x& @7 c$ C    Command (m for help): m
$ T3 B4 b% X3 _% `    Command action  w* x& W1 y" ^( E) x- ]7 p
       a   toggle a bootable flag  O) a8 }& I  U% |! d' i; m; D4 K  {
       b   edit bsd disklabel8 ?3 z+ j* H, D
       c   toggle the dos compatibility flag) l  u& q' N9 W2 r# J% c
       d   delete a partition
+ d- T+ r2 J" D! l6 L) H* X/ V' c       l   list known partition types
" e; t. _- X  }/ K2 B5 Y9 z! l       m   print this menu$ m- M+ L. v+ l6 A
       n   add a new partition+ o. ^5 y3 E0 Z7 G8 P6 d
       o   create a new empty DOS partition table$ W6 \0 l* o" D! q  T
       p   print the partition table
. r, J! A* x& H, b4 R       q   quit without saving changes+ {+ a# B9 v6 L# V- ^) Q! [
       s   create a new empty Sun disklabel
* n/ A) x# S' p  q) K, X- C' z/ A       t   change a partition's system id
  ~2 V/ f7 i& A4 h. A' w       u   change display/entry units1 a% ]8 D' y/ b6 |( b5 F
       v   verify the partition table8 {/ f) Q; Q5 p8 I( M7 K+ Q: `. g
       w   write table to disk and exit+ u" x1 k4 q9 k) z. R
       x   extra functionality (experts only)
- U0 W! ~  y8 Q- A: H7 q    Command (m for help): n
1 T$ j3 e$ u) Z    Command action7 f0 _5 j, H- b) b( D# A- M
       e   extended
9 R" W( J1 Z6 |  x: w. W/ q       p   primary partition (1-4)
! V$ R$ q2 c/ X. S0 u    p% m( g! p3 X& y. k: Z
    Partition number (1-4): 14 A4 m% T) Z" G( }6 Z2 x: u
    First cylinder (1-8322, default 1): & S  X. q3 ~, d' |9 _$ p1 \
    Using default value 1
$ |  G9 Q: T5 [, P" z0 }% Q  d    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G" h, q& F4 k8 U+ e: l  s) C
    Command (m for help): p5 i' ?9 F$ h" |: a( J
    Disk /dev/hda: 4294 MB, 4294967296 bytes
; G  v& K& G& X7 z. D    16 heads, 63 sectors/track, 8322 cylinders( z4 A) |; U1 V0 r- T* v
    Units = cylinders of 1008 * 512 = 516096 bytes
5 E$ _! [. {  ]/ A# w       Device Boot    Start       End    Blocks   Id  System; o4 @+ `3 t4 ~' R
    /dev/hda1             1      1000    503968+  83  Linux7 L3 O; h& l% O; W) J6 E
    Command (m for help): w
( e/ a; U. n' M% Q2 v    The partition table has been altered!
0 X/ r& {1 O: A7 H# ?- [8 C    Calling ioctl() to re-read partition table.0 `( t( K0 N6 B& v$ A5 K* W
    Syncing disks.
2 q: ^2 }% D& A0 f    //格式化新分区; }# J$ N1 e( M; z' c9 t4 H
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)2 J( U2 Z+ y' \% e/ v) X* h+ r
    Filesystem label=
% x) Z+ Z, Z. ~8 X    OS type: Linux
( i; b! K$ l) ?& _4 b7 m( r! N  @    Block size=1024 (log=0)/ b( `* O$ L# B( r: [! {
    Fragment size=1024 (log=0)5 I+ ^/ l# m4 \& Q& |
    126480 inodes, 503968 blocks
! R# D/ G4 }7 z4 T0 g! ^  B& m    25198 blocks (5.00%) reserved for the super user5 v' a4 C0 v0 w4 b" i3 \$ \
    First data block=1
3 u5 {/ P: N( R  K- E    62 block groups6 S0 \: L5 G% h4 Y
    8192 blocks per group, 8192 fragments per group+ k2 e7 o8 a8 G: N
    2040 inodes per group; ^3 Y8 B4 m/ U
    Superblock backups stored on blocks: " u0 e! r  _: E( [6 o
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
6 U4 w2 R( e! l- O% I    Writing inode tables: done                            0 l+ J+ Y, v$ @* p1 x
    Creating journal (8192 blocks): done
) l  u" i4 g5 V    Writing superblocks and filesystem accounting information: done6 M& m7 \7 u  e5 Q5 D0 ^; s
    This filesystem will be automatically checked every 30 mounts or
1 j9 t. G) @% A& j& o    180 days, whichever comes first.  Use tune2fs -c or -i to override.
" u5 R! A+ o) d' b
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点$ c) `, t" F% V2 {( @5 y
    /dev/sda3              3723848    705992   2828692  20% /0 ^. H0 z6 ^/ N5 t9 }/ e: Q) e
    /dev/sda1               101089      9274     86596  10% /boot
7 G: x. q4 ?6 z- [( M0 a    none                     14520         0     14520   0% /dev/shm
) ~9 z+ c9 k8 G) i' l: N* q    //挂上新分区
5 i) i1 i1 d3 ~5 Z
  1. mount /dev/hda1 /home+ A' |& W' h) S0 b- Z+ R( W
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
' r! I# \' E7 [5 r# l. J5 r$ }    /dev/sda3              3723848    705992   2828692  20% /
# L. S& k% W, Y! ]! \    /dev/sda1               101089      9274     86596  10% /boot9 _) D9 {6 E2 U1 Y5 G
    none                     14520         0     14520   0% /dev/shm
" d: k. L- G9 n( N; ~8 c    /dev/hda1               488006      8239    454569   2% /home
2 q5 z. Z: o4 E% n! d
! P6 F4 r& F2 F" K. T" m  H5 V自动挂载:
' D2 H' K8 a2 @% C8 T
  1.           vi /etc/fstab+ g; d& u9 f( D) k
  2. 3 {: r( g* B, {/ e7 Z/ |; }
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    # i& e& ?! H* p7 O
  4. 1 @0 V4 o" o" Y3 [$ W/ W4 [  @
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
+ v2 j# O5 E% S6 R9 {
  1.           mount /dev/sdb5 /mnt/ljp1$ W4 }8 i! Q; Z; u
  2. 0 _6 u! B! x  v) }
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
4 @: w3 I9 S5 e+ U' {! j
6 [2 J+ D: t( }3 \, w/ Y
! p. {4 F; Y- C: K
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-24 12:29 , Processed in 0.009218 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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