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

 找回密码
 立即注册
查看: 2697|回复: 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 z8 [# K9 {* I, Y  t      or: fdisk /dev/sdc  (for the third SCSI disk)
5 [, H/ l9 P" f5 \& R& F      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
# |9 \' M" P1 h: N  w4 H* ^5 G      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
, ^, ~1 t) A& V' R      ...
! p; a+ F6 B2 [
  1. df -k
    & r, d3 c% U$ T& o; _$ F& X2 i
  2. df -lh. q6 t5 B( h6 H4 \1 z4 G! p2 O
  3. 查看有几块硬盘:fdisk -l
    * b/ S: o! |5 ~8 C; `% H4 S/ z4 I
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点8 Z- W$ v  R  m7 x
    /dev/sda3              3723848    705968   2828716  20% /
% O6 z0 l) r  \) Y1 y$ @    /dev/sda1               101089      9274     86596  10% /boot
! J; z8 Z2 \, ~" G+ e, {1 [* s! v    none                     14520         0     14520   0% /dev/shm( O- y3 z1 r% a) b* U8 {% |
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
! P# ?; Q$ `# ]
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel( ^' o" R- h. z$ B/ s
    Building a new DOS disklabel. Changes will remain in memory only,/ H+ e2 B; `9 t' z. d% J! v# ]2 i
    until you decide to write them. After that, of course, the previous* j8 }* v% M5 r* M6 D( H& W
    content won't be recoverable.
; M& x$ m- k, D* z" h/ E    The number of cylinders for this disk is set to 8322.
  h+ A4 r( M, A' }( j6 i5 E    There is nothing wrong with that, but this is larger than 1024,5 k+ y0 F) T) l4 y$ G4 J( R
    and could in certain setups cause problems with:
' F( q5 Q6 q) v& A8 `- ^    1) software that runs at boot time (e.g., old versions of LILO)" A5 l' \% C8 a8 _
    2) booting and partitioning software from other OSs
9 a# F* F1 J# E) q% c. J       (e.g., DOS FDISK, OS/2 FDISK)5 H& _5 f8 v- s3 Z/ _5 q4 h
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)1 \0 u) K1 W9 j% C
    Command (m for help): p
9 ^  l% @& Z& `    Disk /dev/hda: 4294 MB, 4294967296 bytes7 n6 t; }7 d4 n( q) k* I
    16 heads, 63 sectors/track, 8322 cylinders! R) J9 f  g8 U
    Units = cylinders of 1008 * 512 = 516096 bytes
2 O( I! i& T! F9 `       Device Boot    Start       End    Blocks   Id  System
( j( g1 x: d. V9 }    Command (m for help): m7 n8 a4 K3 H3 b/ v5 ^$ p
    Command action
% V' J& _8 ~+ w6 I/ e& g. d' }       a   toggle a bootable flag. [2 P) X& K) Z5 c8 U% F! W, n
       b   edit bsd disklabel
! [: b# b8 w9 D+ [$ M       c   toggle the dos compatibility flag) M4 @: n* X! T; h4 d& I7 _% H
       d   delete a partition+ K- U5 t" Z! C; o0 U  R
       l   list known partition types
$ K# U, h7 D: t% H2 o& x       m   print this menu# V) e& d4 T9 U. A) `
       n   add a new partition
' u" w) ?' C" D$ m( q       o   create a new empty DOS partition table
; }: c( j/ R( v1 [       p   print the partition table  A" E. v. l' h5 k/ t+ A
       q   quit without saving changes
, J. G" p) K7 ?! p       s   create a new empty Sun disklabel
9 z4 x$ f+ t& U6 |5 [       t   change a partition's system id; x" `* T% i+ ~  l
       u   change display/entry units
" n2 P+ x1 f# L  o% u$ C. _       v   verify the partition table
& e4 |) i- S  j$ X3 F+ ^       w   write table to disk and exit
( k$ H8 R9 I" x& i% M       x   extra functionality (experts only)
8 n- x+ j" [; \. p7 F0 \    Command (m for help): n
8 l3 Z1 ~! R/ h% ~8 |. g8 E+ ~    Command action) v; h7 S9 c+ C) [
       e   extended' E7 {: N0 Z) W* ?0 Z
       p   primary partition (1-4). w# a2 E; m6 n/ r
    p
* W* \4 d  [' V4 H% `1 P    Partition number (1-4): 1
# c. _8 z7 N/ d5 O. u    First cylinder (1-8322, default 1):
) J. r! F, {  x2 I1 ^    Using default value 1
+ X( w8 b$ `! F    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
" {8 Y  K) t1 L0 p! F    Command (m for help): p
8 a4 G- l3 ]/ B* f1 t- R% W    Disk /dev/hda: 4294 MB, 4294967296 bytes
& y8 w7 W0 X- G1 H$ c    16 heads, 63 sectors/track, 8322 cylinders9 `. M4 A& d- t5 r& {  H
    Units = cylinders of 1008 * 512 = 516096 bytes
- K: J. w# J6 m" |- i' H, Z       Device Boot    Start       End    Blocks   Id  System4 P9 L& V3 h/ t8 v% B$ u# G8 X
    /dev/hda1             1      1000    503968+  83  Linux$ Z' l& R0 {( h; w6 _7 d
    Command (m for help): w
8 x7 I: T" p7 a1 o& f3 X    The partition table has been altered!( Y& F9 d/ o" J& y
    Calling ioctl() to re-read partition table.! _' S1 X7 D2 P  u9 w
    Syncing disks.4 j) T' m& Y# r; |! N
    //格式化新分区" Y  @- K2 b0 F4 J2 e( ], l8 S
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
" N+ V8 j5 n- ~; }; t( ?3 d    Filesystem label=
( s* u, y( C# \  Y8 o    OS type: Linux
) U' @' J, T4 S% @9 \) m    Block size=1024 (log=0)
  K% s* o; _4 J1 [0 Q' Z    Fragment size=1024 (log=0)
) o3 \! c$ A. Z' ]0 M2 {    126480 inodes, 503968 blocks) |7 w- q: Q+ O& ^/ S  w
    25198 blocks (5.00%) reserved for the super user' h# n' v0 @& h$ v# B* N( O
    First data block=1/ t) M6 b) Y) F
    62 block groups3 a2 g$ {- I6 b/ o) x( m
    8192 blocks per group, 8192 fragments per group
5 Z: i. i$ i# x; ]    2040 inodes per group: a5 P1 R/ U1 w( r/ B  ?
    Superblock backups stored on blocks: - n- I( B8 C$ x
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
) h9 m$ j' e! V0 U6 E    Writing inode tables: done                            6 Z+ R, B2 P6 z2 ~
    Creating journal (8192 blocks): done$ p: |/ e5 E2 M' W7 @/ ~' P3 s
    Writing superblocks and filesystem accounting information: done. f) b7 e) H# [) f+ P" ~
    This filesystem will be automatically checked every 30 mounts or
. ?# l& m6 [% G) u    180 days, whichever comes first.  Use tune2fs -c or -i to override., k5 Z: l8 g+ v- e6 `
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
% b/ J- o4 ]- V# @    /dev/sda3              3723848    705992   2828692  20% /7 |; i3 x* n3 U9 H$ `& c* ~- j
    /dev/sda1               101089      9274     86596  10% /boot
1 `& P) C% |, ^* D  e: d+ m    none                     14520         0     14520   0% /dev/shm) c% ~. a2 v$ [+ h( c% }2 Y7 l9 ^
    //挂上新分区
; `( a( Q9 u% T: D) ~& F' S
  1. mount /dev/hda1 /home+ T7 D$ p6 d2 l, j3 F2 }
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点9 _  Y- `, b3 Y0 [
    /dev/sda3              3723848    705992   2828692  20% /8 o" b' O# V; T
    /dev/sda1               101089      9274     86596  10% /boot3 H, w- \7 d* ~# L
    none                     14520         0     14520   0% /dev/shm
+ E. i4 ~" m/ B2 }2 `    /dev/hda1               488006      8239    454569   2% /home
  i" z% U) X* c: M3 {& ^% t, d. D/ Y/ v( b: ]+ ]# S+ M
自动挂载:+ `( h* Y* P# ~  i, v0 ^
  1.           vi /etc/fstab6 r- L' N( _& v/ Z
  2. * L; E8 U' [3 Z& L; [- ~
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 01 D# e. |, w& ~/ z5 W/ L2 |
  4. $ a  ~3 g4 J+ ]7 u% w" X/ V& s% o
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
5 x  w! ~- q. A0 g) U9 ?
  1.           mount /dev/sdb5 /mnt/ljp1) o9 B9 d0 ?# _" n+ x' v

  2.   P% y7 q- R* e3 O: E
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
5 o% ?$ w8 L1 m& O: k  F

) O' z* v9 R1 E* Z8 k. R; l. p% M8 h. u1 [7 H8 b
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-18 04:03 , Processed in 0.011407 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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