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

 找回密码
 立即注册
查看: 3237|回复: 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)) \  P5 ]' F, ~, |7 D# y) ^
      or: fdisk /dev/sdc  (for the third SCSI disk)
! m* |7 m) @; Y" V  c) z# X      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
% P* I; P/ o' l# F! B3 y& v/ m      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
$ r4 B, b# R; f      ...
: g' g4 Y( L. I9 G8 `1 I" d
  1. df -k4 m  B+ p! `# _/ y
  2. df -lh
    " u$ P6 S3 t# U5 F8 w
  3. 查看有几块硬盘:fdisk -l
    6 E! W  S; G; V0 C+ Z' b
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
  a) ]! p  U% w% }# X4 h9 V- k3 k  Y* A6 e    /dev/sda3              3723848    705968   2828716  20% /" q+ \. x. J3 R. f' N: s, T& g
    /dev/sda1               101089      9274     86596  10% /boot
2 X, M* `9 U# z. g* w& D: }    none                     14520         0     14520   0% /dev/shm
/ E# a# z! g; G7 ?/ N( n" E    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
9 b& F  V, t7 p# j# f
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel8 P/ ^" F3 W. B/ B
    Building a new DOS disklabel. Changes will remain in memory only,+ m0 {3 ^8 V/ k
    until you decide to write them. After that, of course, the previous
- b  B: f9 K, p$ w  L( g    content won't be recoverable.8 l3 n& r# J% i9 y- w
    The number of cylinders for this disk is set to 8322.
% k( F% r- F0 `' }6 J    There is nothing wrong with that, but this is larger than 1024,
6 C& U2 h6 r8 U' {! f    and could in certain setups cause problems with:
: @6 n2 W) o$ C- x    1) software that runs at boot time (e.g., old versions of LILO)
$ h! M# |% S# \: S* f6 `' v    2) booting and partitioning software from other OSs! L* v) g, Z  j# v
       (e.g., DOS FDISK, OS/2 FDISK)2 c: N4 G, i+ C* A0 K2 w% }
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
& n  f# z* j  X0 L; P    Command (m for help): p
: R( c5 P* V! j- \8 H% ^/ q    Disk /dev/hda: 4294 MB, 4294967296 bytes
3 _7 r: H( i9 B: o" K    16 heads, 63 sectors/track, 8322 cylinders
6 i9 L; C( W! A7 ?    Units = cylinders of 1008 * 512 = 516096 bytes
6 Q  d! u5 S0 g' t5 Y' \4 n1 K       Device Boot    Start       End    Blocks   Id  System
. e7 l* R" ]" w    Command (m for help): m- X6 m8 u/ G, a0 d; o
    Command action- A, A  R! ]  L% Z9 @+ J3 l
       a   toggle a bootable flag
1 h( d0 _) K) K       b   edit bsd disklabel
' \, [9 Z/ Y: u# u% x$ v+ z       c   toggle the dos compatibility flag5 i: y: w. h; M$ C( ]
       d   delete a partition
9 y6 x& Y! n3 y+ W       l   list known partition types- ?4 R; u+ u  t/ s/ }! Z
       m   print this menu
2 g/ L  V8 s( c+ @' I       n   add a new partition
9 E% c# G* s. F8 A- L5 g       o   create a new empty DOS partition table4 s: Q8 L$ O- F! e6 W% S
       p   print the partition table% v$ m  t8 d, K' {
       q   quit without saving changes2 N5 L) s5 x2 _9 T
       s   create a new empty Sun disklabel
9 X1 ^: |  u1 e* h0 d  p       t   change a partition's system id
$ p/ P# S6 P/ Z8 s+ [& U) V2 d       u   change display/entry units
9 P1 V9 I6 b& n' [1 N3 m       v   verify the partition table* t- E' e8 C! R1 O1 ?5 _
       w   write table to disk and exit
1 `4 r3 ]3 a* V4 q! [- t       x   extra functionality (experts only)  G- l" o4 n2 X- ?( `% s
    Command (m for help): n
  r# e& J; U2 C4 S/ a3 M1 O. f    Command action
. _# f& V; W6 y3 n! ~. {1 n       e   extended
; q2 S: o+ @6 D% z! `# F       p   primary partition (1-4)7 q$ j* D2 F) v6 t& ]/ Z5 N1 R  S* T
    p/ ~7 P+ z7 B  b' g: d$ ?
    Partition number (1-4): 1
9 I! ?8 q# B5 h6 `    First cylinder (1-8322, default 1):
3 j, U" Z% m- {7 I( D1 ~, `* R    Using default value 1
- ?7 M+ r! ^$ u6 b9 m3 G4 U1 e    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G' ]# o9 ~! N) z0 q1 N5 K
    Command (m for help): p7 b# D6 M5 `# H+ ?- q
    Disk /dev/hda: 4294 MB, 4294967296 bytes
. m9 t  l7 ^. h& {* Q    16 heads, 63 sectors/track, 8322 cylinders
1 S. S. ?; N+ ~3 R    Units = cylinders of 1008 * 512 = 516096 bytes
$ ~4 ^3 U: _5 E       Device Boot    Start       End    Blocks   Id  System
' z' X# z9 f4 v& [    /dev/hda1             1      1000    503968+  83  Linux
4 y3 M) W3 |2 f    Command (m for help): w
% l( e2 o( J3 U- S; @5 v( [9 e$ N    The partition table has been altered!5 p" y4 Q9 U  {: ~+ a
    Calling ioctl() to re-read partition table.
- r  P& ~# @3 g0 M! h( ~" A- d    Syncing disks.. t) w% ]2 v1 \. w
    //格式化新分区
9 i' A. [% `5 T- j0 V
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)( U5 S2 m# n7 ?/ c9 r1 O( s
    Filesystem label=
1 f. b% w% j# r* C% ~# l% _5 C    OS type: Linux
  ^4 _+ N2 c; Y" V+ W9 u3 u    Block size=1024 (log=0)3 \* v- w3 ^' D) N7 G; n  D
    Fragment size=1024 (log=0)
; {6 V! y3 f$ m5 K7 K& ^    126480 inodes, 503968 blocks
* s) a+ T1 X. Y3 J4 p$ a& z    25198 blocks (5.00%) reserved for the super user. k" G7 Z3 P$ c! Q" k$ @
    First data block=1
  f# q( L& [. l' c1 z# N6 Y& c4 ~    62 block groups
/ m  t( U; L% z8 l4 a/ R/ c    8192 blocks per group, 8192 fragments per group
0 a& c  q. `2 |$ L( \  v" u2 R    2040 inodes per group
+ w9 W# x  i8 h+ h3 X    Superblock backups stored on blocks:
' g+ F) X5 f3 i* @" I8 A            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014096 b8 r  i0 ^/ N* X
    Writing inode tables: done                           
$ k( j. e& t1 V# z    Creating journal (8192 blocks): done1 k! u% e4 D* H8 g
    Writing superblocks and filesystem accounting information: done
" N1 b9 o! t- U" ~& H/ ]    This filesystem will be automatically checked every 30 mounts or( q& i( ?2 s( [: Y* N, v) k
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
+ L8 U) {9 D7 g7 I
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
) k6 \% t+ x4 F2 I5 f4 y/ x: S- \8 I    /dev/sda3              3723848    705992   2828692  20% /
( @/ ^% F2 e1 H/ F    /dev/sda1               101089      9274     86596  10% /boot
# @/ [- q$ v8 Z$ z. X  @5 }6 \" X6 F    none                     14520         0     14520   0% /dev/shm" W  n9 B  a7 Y4 b. U% h. _: _
    //挂上新分区5 C3 H+ q( ?$ {  v/ h( o' {# Z" V
  1. mount /dev/hda1 /home2 N; c! d- Q, h6 P
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
2 w% Y. a- A9 V4 [) P) ]0 d    /dev/sda3              3723848    705992   2828692  20% /
9 y# Z$ i, O2 J5 w* i    /dev/sda1               101089      9274     86596  10% /boot, R9 k6 a1 V6 e& U0 H, J8 O7 N. C
    none                     14520         0     14520   0% /dev/shm
" p1 T+ ]2 ^( O/ w3 n    /dev/hda1               488006      8239    454569   2% /home, }" E; k- R' E: s( x
+ Y; V) f, G% k; D
自动挂载:* h+ ]/ |) h4 f" o$ I. r
  1.           vi /etc/fstab
    : S) G# y  r0 w
  2. . V2 z" O2 M5 ^! W
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    - b, w  R2 ]+ a# ~* ]0 O
  4. % L0 E' \+ @& q  U; X" x
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:: I6 p& h% d# m8 Q1 e5 U/ J7 N
  1.           mount /dev/sdb5 /mnt/ljp1  n3 Z( g$ o& r4 [  I; _7 H
  2. 1 W# J% g1 ?# n6 ~* M1 V
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
$ e% z" M- g4 D: ~6 e- O( p

2 ^! x9 a9 v) b3 G
- ^0 Y9 w  e3 \4 i' h5 o
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-10-25 12:58 , Processed in 0.030544 second(s), 9 queries , Redis On.

Powered by Discuz!

© 2010-2023.

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