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

 找回密码
 立即注册
查看: 2698|回复: 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) p' o+ n2 ?! W4 A      or: fdisk /dev/sdc  (for the third SCSI disk)
/ Y* |. R3 }9 `. Y& j, |      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)5 `( u& ~2 _/ ?4 O5 Z
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)* k  }4 y6 o+ ~" h* J/ Q7 W2 y2 |2 b
      ...
  \( U. }' I7 [4 o( o- @7 R
  1. df -k
    ; s& {" g- V* Z" V1 s
  2. df -lh8 F! M1 G( p, J" E' J5 `0 R
  3. 查看有几块硬盘:fdisk -l$ P# W8 s4 [  {% ]0 a" z9 Y; n; p( G
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
' {+ h& z' K/ t2 p    /dev/sda3              3723848    705968   2828716  20% /+ r/ B- _& c: t2 x
    /dev/sda1               101089      9274     86596  10% /boot
& E, Y' U& n% Y/ \    none                     14520         0     14520   0% /dev/shm
+ w/ K  @- q5 R/ V. R    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用5 F  y/ n0 R" a
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
) H9 |$ y. w- Y6 v1 A9 g    Building a new DOS disklabel. Changes will remain in memory only,6 e2 C' Q3 _. z/ L
    until you decide to write them. After that, of course, the previous7 l; s6 s) @# p4 O& L
    content won't be recoverable.0 i. J4 p  H4 e: v. n! P) d5 m
    The number of cylinders for this disk is set to 8322.
8 }" y2 @9 I& M    There is nothing wrong with that, but this is larger than 1024,% H6 _& N0 r2 P; G" H3 K1 n; y
    and could in certain setups cause problems with:+ e' N. O! x5 [1 e
    1) software that runs at boot time (e.g., old versions of LILO); j; f. D* l$ [0 y
    2) booting and partitioning software from other OSs
- k# _" D2 Q* ^& V       (e.g., DOS FDISK, OS/2 FDISK)
. K3 m, z0 m  Z! Q- m' r4 }1 \% Z/ U( S    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
) L) h6 C/ t9 s7 Q    Command (m for help): p
/ l( A9 \) g6 N- }( U; h    Disk /dev/hda: 4294 MB, 4294967296 bytes
3 S) M. o9 K" }, o+ W+ ]  o    16 heads, 63 sectors/track, 8322 cylinders
2 m. R3 a( s" X' Y7 j    Units = cylinders of 1008 * 512 = 516096 bytes
$ T; y( S. _8 K8 ~' U$ @. b       Device Boot    Start       End    Blocks   Id  System
; ~/ u1 J4 K* D    Command (m for help): m
0 E6 l6 J5 ~2 ]& p1 g    Command action0 a( _- s+ m! n3 o
       a   toggle a bootable flag7 V& U% v) I3 T0 X: J! }  S
       b   edit bsd disklabel5 J: P% B+ A  Z7 f5 r
       c   toggle the dos compatibility flag
* u& M5 R! T: X6 j3 A3 Z5 r9 B       d   delete a partition
+ c) m4 s; ^: i       l   list known partition types7 X( n8 ]& \- H5 V
       m   print this menu
% n- k7 i& W! A* e& V0 _       n   add a new partition
$ Z1 c4 f9 |% `       o   create a new empty DOS partition table
# Z9 B0 @# B" Q       p   print the partition table
) f$ h6 `- w$ O: h9 `       q   quit without saving changes$ Q8 M& C# A& A3 @% P8 H; T
       s   create a new empty Sun disklabel4 Q0 ^! N6 E- T; @
       t   change a partition's system id
" t2 k' U  ^8 m; s1 m       u   change display/entry units1 t" i8 |' `; n1 y+ A' _
       v   verify the partition table% r8 G. \% o$ Z1 q. q
       w   write table to disk and exit$ l0 C2 R$ I- ^7 z- b0 U
       x   extra functionality (experts only)& i2 f4 x# p5 `% a1 Y( L9 i. A
    Command (m for help): n
+ Z/ z6 a- y1 T    Command action
; ?9 F8 I- s  l; p$ a       e   extended& a$ d, Q4 Z9 u/ o/ w
       p   primary partition (1-4)
1 P9 F  e1 N" o  ^4 D; q    p
# L0 Y7 p' C0 ~# R. Y7 G    Partition number (1-4): 1
6 u3 x' Y& S8 E2 Y. u+ Y% Z) G    First cylinder (1-8322, default 1):
. X3 q, Q$ E9 ^% u4 j0 f    Using default value 1" F( P- s0 T2 k& h5 M% h* F/ z
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
' q( {6 c  ]* h, ^* z- d    Command (m for help): p! V! ^# q. d+ Y/ u% A
    Disk /dev/hda: 4294 MB, 4294967296 bytes
: }# ]0 ^7 u9 f. A) e8 M1 K( H: _    16 heads, 63 sectors/track, 8322 cylinders
1 N# O# B: E2 H9 n6 Q    Units = cylinders of 1008 * 512 = 516096 bytes8 H* A3 j0 U, |' e# c; E
       Device Boot    Start       End    Blocks   Id  System
7 K( U( W0 V1 Q1 N. N    /dev/hda1             1      1000    503968+  83  Linux9 x2 j- m, Z6 x9 B
    Command (m for help): w
! W$ V9 m9 A0 @) j: B/ r    The partition table has been altered!4 |' I5 i# ~9 M
    Calling ioctl() to re-read partition table.2 w$ b, V- }6 b" Q1 F
    Syncing disks.6 @: z1 G3 i4 ?! p
    //格式化新分区
, y- P1 L/ D4 p" [3 U
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)6 b, m) m0 ]  a( j. E6 G. {4 I
    Filesystem label=
; ]# b$ C. I+ d5 Y$ ~3 Q9 g    OS type: Linux
3 j8 t4 @* L  g# l    Block size=1024 (log=0)4 u% x& U2 ]& J/ |( T) k& `! n3 q
    Fragment size=1024 (log=0)
! W/ ~- M3 |' w  V  p, B  p    126480 inodes, 503968 blocks
% r9 `0 k" p$ ?2 n% d. v    25198 blocks (5.00%) reserved for the super user
$ X" G! e7 o2 H. {0 K$ K    First data block=1
+ ^) k# m4 G- h6 B    62 block groups% n" `7 d  A1 {  c( N
    8192 blocks per group, 8192 fragments per group6 P- b( X8 Z* W/ n" G9 a* }% z$ r
    2040 inodes per group
- `& y- K8 h6 }% [( K2 D, ]    Superblock backups stored on blocks:
7 c5 S8 e/ x' u6 h  s            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
6 i1 K. C$ V; B3 s3 b# {9 R6 ]    Writing inode tables: done                           
" H" m0 w) W; Z7 G# A" N    Creating journal (8192 blocks): done
& W4 V/ d% a" |5 Y2 c! |# v    Writing superblocks and filesystem accounting information: done
8 _! I3 e* k4 N% Q, o5 g: x    This filesystem will be automatically checked every 30 mounts or
6 U3 j/ P9 W  r, u  I4 Z: J* A    180 days, whichever comes first.  Use tune2fs -c or -i to override.
# y3 W7 t" [) C# B3 L1 \
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
+ D4 B. L2 m' v$ [7 p1 z$ e    /dev/sda3              3723848    705992   2828692  20% /; G1 F% e  t4 k
    /dev/sda1               101089      9274     86596  10% /boot3 X4 Q1 n, t) T6 c0 V  B
    none                     14520         0     14520   0% /dev/shm
4 t& V. }* `1 ]3 ]. a9 c    //挂上新分区
  b1 Z$ w# E+ x" i: l) F
  1. mount /dev/hda1 /home. m1 K9 T: L+ ?# K3 W
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
: D; x  X; r) b9 S' N) f    /dev/sda3              3723848    705992   2828692  20% /( ^  m4 O& C5 y2 j. H
    /dev/sda1               101089      9274     86596  10% /boot2 s/ a( S1 x% K7 r" m! I7 p9 S
    none                     14520         0     14520   0% /dev/shm$ W4 A6 ~7 \) {) h+ w- j7 @, J
    /dev/hda1               488006      8239    454569   2% /home
6 u* _9 H1 G) w# Z# a
: b! T: F# y' e& {自动挂载:. w" q! ]  S! J
  1.           vi /etc/fstab
    ' v9 l9 I" G5 W& h5 H/ g! l( @% q

  2.   W& p9 T9 b( q
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    ' P6 N1 ?* O  A/ E* [: Y" c
  4. & J# v0 J* P% v  Y+ W
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:0 P" w' ?* ~+ X( T+ j# C
  1.           mount /dev/sdb5 /mnt/ljp1; S# V6 {/ D; P: f  o  m# Z3 Q

  2. 6 p+ N- j5 D1 x7 f: S
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

+ ]* q6 T0 j1 F' g" N& L, Z. ?% u: H+ _

) V4 r: E/ y# L6 r; m" z
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-18 14:38 , Processed in 0.027856 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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