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

 找回密码
 立即注册
查看: 2832|回复: 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)
7 M) m7 I/ G* v, s7 E) v; f      or: fdisk /dev/sdc  (for the third SCSI disk)
$ s* q( b( Z, R4 E7 `      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)0 z1 H; c! }& v( l
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)5 L% F# h  ?, n
      ...5 R5 E( g9 x, t0 V
  1. df -k0 X9 ?5 Z6 j+ ~# g
  2. df -lh; J$ n; I. n3 c1 x
  3. 查看有几块硬盘:fdisk -l4 x9 [2 O9 |8 _/ ]# _1 H! C' H# k4 H
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
  V1 J" u8 X5 |2 q" W    /dev/sda3              3723848    705968   2828716  20% /
- w( N1 u& v1 r5 I; _    /dev/sda1               101089      9274     86596  10% /boot
  z7 o& F& g9 p* _2 x    none                     14520         0     14520   0% /dev/shm( c. p1 n2 J) x/ P9 d7 N1 F  Y0 D- O' X
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
# y" B  x9 Y) X9 E, _: O4 P+ @5 B
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel4 I" b3 Y1 b# i! u6 Y  N
    Building a new DOS disklabel. Changes will remain in memory only,3 v! U" @  `9 W6 M
    until you decide to write them. After that, of course, the previous
, y" D; F. k+ `: g    content won't be recoverable.5 l: P/ G6 s  Q( p
    The number of cylinders for this disk is set to 8322.. T, T7 i0 k; a* v) ~" v2 g
    There is nothing wrong with that, but this is larger than 1024,
* [0 o) j( w$ \2 x1 c) o9 u    and could in certain setups cause problems with:
% N* ^! g' p7 E' h2 B4 m: l    1) software that runs at boot time (e.g., old versions of LILO)$ i5 D! h; ^; o' Y
    2) booting and partitioning software from other OSs  F( j: ]$ x7 ^# J6 v
       (e.g., DOS FDISK, OS/2 FDISK)
% U! y: A  [9 \    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)2 l% n4 V* ^+ S$ n
    Command (m for help): p# M7 ~. ~9 C$ x8 g
    Disk /dev/hda: 4294 MB, 4294967296 bytes9 U7 U2 i& v5 I; M% {
    16 heads, 63 sectors/track, 8322 cylinders
: x# D& [' z: g/ M  b9 |    Units = cylinders of 1008 * 512 = 516096 bytes) S& @2 @* P8 o1 N3 e" s9 R- z
       Device Boot    Start       End    Blocks   Id  System. {: W3 c" s" ^# C$ }) G
    Command (m for help): m! d$ i0 ^- `7 d, l
    Command action1 E8 k6 }9 {. S, m( a
       a   toggle a bootable flag; ^' c3 S3 b2 O* R2 f) N2 k& a
       b   edit bsd disklabel
: q& c0 P. ~1 l1 v       c   toggle the dos compatibility flag
  [0 U: i7 R& g6 n       d   delete a partition: C1 X' I$ b6 [7 p" H) E$ u; E0 o
       l   list known partition types
5 p: E7 I$ k/ U2 i$ w+ `; h  E       m   print this menu
2 J+ t1 e) ~" O* V( \) W       n   add a new partition" y$ z" m' M& h% Y2 }. `
       o   create a new empty DOS partition table/ b/ N- _2 r' b! a  j0 j+ k
       p   print the partition table
1 u7 R, O& @- J5 b; l       q   quit without saving changes0 G5 F2 W7 X8 r) c5 b
       s   create a new empty Sun disklabel
1 |; N" n+ m& E& Q# |/ z5 p5 B       t   change a partition's system id
. j9 b9 x! N6 |+ L7 E       u   change display/entry units
0 `( k  n9 h& K       v   verify the partition table
& A8 L* L) C( C- s- f$ p) R6 S4 \       w   write table to disk and exit; S+ n8 V& W5 H5 z+ t- I. S
       x   extra functionality (experts only)7 y5 }( K0 Y+ x, o, h, ~
    Command (m for help): n9 I$ `! V( l1 q0 V7 X2 g& G  a
    Command action( @. }% f( I3 c! R
       e   extended: Y- y- l2 O$ E& m6 {
       p   primary partition (1-4)
+ ]0 A9 r3 k1 _    p
8 q1 j2 K, L8 Y* i" e) f. _    Partition number (1-4): 1
+ J2 w  w1 H) q( u- m    First cylinder (1-8322, default 1):
0 j, Q2 {" E2 O$ T6 s0 N) B    Using default value 1! ^$ Y; p8 k' h. a( Z
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
- z- f2 b3 {1 v' ~2 c4 Z# O( Y  O    Command (m for help): p
# o' I: D1 f$ d/ ]1 c/ V+ w# I! ^8 }    Disk /dev/hda: 4294 MB, 4294967296 bytes
: m' z8 j  P9 P, G4 L    16 heads, 63 sectors/track, 8322 cylinders
5 A$ S% U' `% l7 q    Units = cylinders of 1008 * 512 = 516096 bytes- d, B$ q; l1 e  x1 {) e- O
       Device Boot    Start       End    Blocks   Id  System
6 n/ `* p5 Y- u9 ~7 t, H( g    /dev/hda1             1      1000    503968+  83  Linux, F1 p% t  k+ h2 @  _9 y1 X8 ^' Q
    Command (m for help): w
* _2 [) }/ p  T& [3 T    The partition table has been altered!
0 ?! _8 B4 _$ i  m$ [) O2 [    Calling ioctl() to re-read partition table.
% {6 I) g( ]/ W2 Z# b; ], H    Syncing disks.5 B& M7 v1 T/ C  p2 M9 z2 g2 P; a+ J
    //格式化新分区
5 F3 `3 R! S/ F3 ]& Q
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)& n' o- V2 r  ]: N; a9 y: m# {
    Filesystem label=
! a" r) m/ p- X* k) Y    OS type: Linux
2 f$ r" t6 h9 x    Block size=1024 (log=0); m. g5 W" b( I) E" a6 s# S, W
    Fragment size=1024 (log=0)% C; u8 i: _5 y& p; _4 G" Z. N: s
    126480 inodes, 503968 blocks
9 ?# p" I" \3 C8 I: s, j    25198 blocks (5.00%) reserved for the super user( x- ^  _  T0 E2 @. `& g
    First data block=1
* v1 p! w+ b) Y; r6 J    62 block groups
8 r: q) Y" Z3 I) E* j. t    8192 blocks per group, 8192 fragments per group% ~& _( m! s+ `! j
    2040 inodes per group1 T7 ?% m! D: a
    Superblock backups stored on blocks:
4 Q8 D% l0 h5 m& o* c            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
! Y4 V9 W' x1 p) C% K1 T2 Y    Writing inode tables: done                           
/ z- z6 I  z% Q: B! {, \* q4 E  g    Creating journal (8192 blocks): done
, u8 Z2 A4 Y+ y! `5 a6 U    Writing superblocks and filesystem accounting information: done
9 b$ z7 a- P' o' B' I; @9 @5 z0 y    This filesystem will be automatically checked every 30 mounts or0 n; ^9 q1 n. B
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
3 ]3 {- h4 ~- S. T) c. t$ S6 `
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点. b% O! S0 O6 O" ?( Q# p" l* c
    /dev/sda3              3723848    705992   2828692  20% /2 t0 h. Q& e7 \. L
    /dev/sda1               101089      9274     86596  10% /boot$ d! D" O, O+ R- \8 p9 `1 ]0 _6 @
    none                     14520         0     14520   0% /dev/shm, |" R- S3 p0 _+ T$ M" G' F# [
    //挂上新分区9 h2 ]# e. K6 U2 L- S7 m- q9 {
  1. mount /dev/hda1 /home
    ) U! |' _$ E2 `( Q" Q3 [
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
1 d+ E( a( ?* i8 V    /dev/sda3              3723848    705992   2828692  20% /
  z" a- y& W% H    /dev/sda1               101089      9274     86596  10% /boot6 h, d7 G. g: B7 E5 |/ z) q$ q# M
    none                     14520         0     14520   0% /dev/shm1 a- n+ A+ ~1 V
    /dev/hda1               488006      8239    454569   2% /home
' R; O) }. |; z# Y' Q4 k# |
+ N# H2 W- r; u  w7 K0 p7 j7 A自动挂载:
7 f( J& r/ r5 ]# v
  1.           vi /etc/fstab# v/ [$ }$ p% o9 T, P( ]
  2. $ u8 M  m3 b9 N  Q% O: }; P
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    5 S# r: w: w+ V0 f

  4. # W( ^: _4 i: @7 W
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
- c+ d1 k5 _$ ?* p
  1.           mount /dev/sdb5 /mnt/ljp12 }! r/ c! ]( _# R

  2. ; |: z+ r. Q$ ]+ {" a/ M
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

" F; U) j# ]; J9 g7 ~, A* ]
, r: y1 N8 Z9 t$ v  n
% W) Q( C' m* a
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-22 19:44 , Processed in 0.015469 second(s), 6 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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