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

 找回密码
 立即注册
查看: 2745|回复: 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)
, x" n1 d$ j6 x. D# k  F      or: fdisk /dev/sdc  (for the third SCSI disk)" V1 [0 }# N% S
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)3 W( ^! ]+ h2 G9 M8 `/ K3 o5 G. r
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
$ k+ [5 M; X8 u: K      ...2 w0 d2 G# X: H9 N3 h
  1. df -k
    " r3 @$ j# V2 i$ _* z& H
  2. df -lh
    5 c& L, n. P0 m' F" j( ~$ G$ E) K2 C) M
  3. 查看有几块硬盘:fdisk -l
    6 n0 N4 ~) F# O1 e0 X$ }4 |* ?
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点" L9 _: O/ k' X
    /dev/sda3              3723848    705968   2828716  20% /
7 F9 [/ ~0 [) f0 G" j4 U    /dev/sda1               101089      9274     86596  10% /boot# D- H! G+ K' J7 F, Y% h6 j* J) I
    none                     14520         0     14520   0% /dev/shm8 y  S' E( }) G
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
7 Q9 A, u% o+ M, H. B
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel5 [& x+ z: B7 J: i+ @. k* q" n
    Building a new DOS disklabel. Changes will remain in memory only," U" h5 S& X, t, w& @8 E: [; v/ g
    until you decide to write them. After that, of course, the previous: _8 W# O- F  W
    content won't be recoverable.
" ]  |' s' p0 ~$ p    The number of cylinders for this disk is set to 8322.. `+ G; W- d4 C7 q: g1 U3 B6 G* h6 _7 D
    There is nothing wrong with that, but this is larger than 1024,
7 x) ?3 d4 Z9 c, L. p5 K# O    and could in certain setups cause problems with:
+ k- k' M  S2 \7 W3 M8 \    1) software that runs at boot time (e.g., old versions of LILO)6 u+ d7 h' h1 V% c! t
    2) booting and partitioning software from other OSs; {) p3 _# ]6 s
       (e.g., DOS FDISK, OS/2 FDISK)
! |' A# [; g& w5 i0 u6 l/ J    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
3 F. `- ]6 s! {( b    Command (m for help): p
9 [; o2 V- n" r4 F2 z( r& N, Y5 t    Disk /dev/hda: 4294 MB, 4294967296 bytes0 M, x# M  g, W- T: @$ s( E
    16 heads, 63 sectors/track, 8322 cylinders7 `6 E3 _* b/ i' \* n8 z
    Units = cylinders of 1008 * 512 = 516096 bytes
5 a: Q$ C) k2 O& W7 n1 r. i, u$ z       Device Boot    Start       End    Blocks   Id  System
1 ?* A( \- t, B+ r    Command (m for help): m
( q3 X8 u+ B- {: b9 a6 t    Command action
+ F* K6 R* j1 z" B, I       a   toggle a bootable flag
- D& \9 h& b3 i       b   edit bsd disklabel
  A( [, ^4 R. u+ j6 _- p9 D       c   toggle the dos compatibility flag4 Y  B9 O2 t" _  P* s  z( ]
       d   delete a partition
0 R" t6 x1 K; e  i2 R6 @       l   list known partition types" f5 P5 K6 o! t$ s) H
       m   print this menu
; z( y+ b5 l; g  f* \% v       n   add a new partition, d- d  \0 ^* h& B* r% c
       o   create a new empty DOS partition table9 ~8 Z6 V& a# i6 ^
       p   print the partition table
, D. `$ S* R+ n, c9 Z7 n$ N, j       q   quit without saving changes8 [5 c$ J& X0 r; X% _: Z
       s   create a new empty Sun disklabel
  x( r( ?, p* L1 @6 y: g6 Q       t   change a partition's system id/ w& j& r, \* _+ Z
       u   change display/entry units% Q% P2 i' V- X$ b$ m* B- b8 x4 k
       v   verify the partition table
! O/ m6 U6 s$ x  z: T+ [2 R       w   write table to disk and exit4 c( {. `, X' K# v: G, A
       x   extra functionality (experts only)
+ w: F& G- @; T" ~& o! l# ~    Command (m for help): n2 l$ Z4 f8 X# C/ \7 g& A! A
    Command action
/ m. E+ t* J- \' O       e   extended
, I- s9 Z- x" F2 F1 p       p   primary partition (1-4)
, x( B. o1 N% D8 E) H* C. Z    p
! ]1 n. k: M( A    Partition number (1-4): 1" v& @' ^2 o" y# a  P' [. X* Z
    First cylinder (1-8322, default 1):
. t/ ?' M. W; {3 r( V    Using default value 15 v( F' e6 g2 b8 u, M
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G% D! R) j# G! |% C
    Command (m for help): p2 i; |/ ]4 \9 g. E1 h: f4 C
    Disk /dev/hda: 4294 MB, 4294967296 bytes0 a" [2 ]: w! e# x
    16 heads, 63 sectors/track, 8322 cylinders
' f' M; f! _4 U7 @% Z! B+ K    Units = cylinders of 1008 * 512 = 516096 bytes
* i" f; A% }3 _       Device Boot    Start       End    Blocks   Id  System& z. ^; n7 J; |" M' t6 I
    /dev/hda1             1      1000    503968+  83  Linux) @& t8 R# w) O) N) D& b4 ?- `  g! N
    Command (m for help): w: J( k# d* @' k
    The partition table has been altered!
" s* d/ t8 h: I! M3 \( Y' p    Calling ioctl() to re-read partition table.% h! U" X" n6 f( f) S
    Syncing disks.
% z* Q+ ]# s8 F# D    //格式化新分区
) ^3 X) r% _- m/ D
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
" ?; {# o# |. L( s5 ?    Filesystem label=
" k- w: l9 }4 _; i    OS type: Linux: p- U" Y7 i; ?4 v; z& }
    Block size=1024 (log=0)
  C( f! R3 H4 H* f, l* i    Fragment size=1024 (log=0)# h% C! G+ `# Y5 g! v1 M9 u
    126480 inodes, 503968 blocks
+ K: e% G5 [, |+ V$ U) f    25198 blocks (5.00%) reserved for the super user
" ?3 F( e) O: B$ n    First data block=1
1 R3 t4 f2 X" K+ ]; l* P& P    62 block groups
5 P- ~- Q5 L% {& d7 _: W0 g    8192 blocks per group, 8192 fragments per group
: F' h! [2 m4 q  K1 T    2040 inodes per group
8 f% N: G$ w% [8 `5 W0 ~7 ?    Superblock backups stored on blocks: + I4 \# y+ ?7 O2 W$ L
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
% h2 I+ V9 W# x( H) f# p    Writing inode tables: done                           
& j1 P, ], P. b    Creating journal (8192 blocks): done
. D7 [' s7 O0 W- l    Writing superblocks and filesystem accounting information: done
8 h& ^/ Z! s& n# \, N5 F% Z: T* O    This filesystem will be automatically checked every 30 mounts or
( ]( G- m1 K5 O7 e& n$ k; f9 y( W    180 days, whichever comes first.  Use tune2fs -c or -i to override.( l4 a$ f8 v$ V9 Q" ^3 a; Q
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
# D2 m/ f6 x6 x    /dev/sda3              3723848    705992   2828692  20% /
8 F+ o7 c9 o3 c) g8 V* k* A    /dev/sda1               101089      9274     86596  10% /boot8 t7 I# D5 O$ r# z
    none                     14520         0     14520   0% /dev/shm6 _$ ]* _% b: x! f  B8 G7 z& I
    //挂上新分区5 k& G% V( L+ A, K
  1. mount /dev/hda1 /home& X# N; g1 W6 c
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点( }$ t. O$ o- V" @& X  s! G+ \
    /dev/sda3              3723848    705992   2828692  20% /
0 e4 e( e$ U! ~) l) c( g* L    /dev/sda1               101089      9274     86596  10% /boot
4 B3 E1 r2 E4 ?* L1 V. \; S    none                     14520         0     14520   0% /dev/shm
5 L2 S5 Q- z% I1 j7 H    /dev/hda1               488006      8239    454569   2% /home
6 r+ \0 ?' v# `& I: D% ]8 o5 W3 x' }9 A& p% F
自动挂载:
+ ~! a* ?4 H/ w8 k+ S' H- I0 [* a
  1.           vi /etc/fstab; s3 G* }# g) x1 _/ o

  2. 4 G3 R3 {* g) \- Q! K
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 04 F- i" j( q4 P# _* g9 I% i

  4. $ P1 y, q1 J; ^, A
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:, o% H" ?5 F# v5 e
  1.           mount /dev/sdb5 /mnt/ljp1  G9 V* P1 m  ]+ Q* g1 K

  2. & e, a- o' i4 G+ J9 a3 _+ ~' Y
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

0 W' q2 G. Z; ?$ z7 d. ?' F" T
- f' y. \8 w3 V7 |/ S
: @# |8 l& R# v$ x6 B$ h/ V
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-7 11:08 , Processed in 0.010912 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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