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

 找回密码
 立即注册
查看: 2361|回复: 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)
4 `2 C2 Q( U# L) ~5 a      or: fdisk /dev/sdc  (for the third SCSI disk)
$ g, ^1 f7 m9 D      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
* s7 w( o9 M5 h9 |& p5 z. m      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
+ V  p* A: b( u0 j      ...' |& v4 X/ l/ z" C9 [- R# o" @
  1. df -k
    ! }6 c8 O! O; L+ n, l
  2. df -lh) W+ l4 A* p$ ?3 @7 n. [3 W0 H4 ?; ?
  3. 查看有几块硬盘:fdisk -l- J% p0 _9 ~( y; O1 |$ p& l# R
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
0 `- n5 H  l( C6 n/ r    /dev/sda3              3723848    705968   2828716  20% /$ ]. {: Y3 N, G8 g2 ^! J$ @
    /dev/sda1               101089      9274     86596  10% /boot
- p6 \' m' I8 d! D- Y* h    none                     14520         0     14520   0% /dev/shm$ Z6 T# Z5 h/ p1 i7 Q
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
3 L+ ?/ {: n" `0 L0 }2 W
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel6 C# z* P8 B' Z
    Building a new DOS disklabel. Changes will remain in memory only,9 _7 s( i5 X5 f9 l9 ~! {. F% z- w
    until you decide to write them. After that, of course, the previous! \- Z0 v- g( g+ ?+ D
    content won't be recoverable.( @. U3 m. i2 u0 n
    The number of cylinders for this disk is set to 8322.
" x" U; [5 }0 e/ a+ U( _% B9 Y    There is nothing wrong with that, but this is larger than 1024,+ g$ d" k; p; [
    and could in certain setups cause problems with:% i* \9 `8 v5 V/ m  F3 M! A  T
    1) software that runs at boot time (e.g., old versions of LILO)
5 A" @5 p9 B& P    2) booting and partitioning software from other OSs0 e1 r9 t7 B3 k% M1 ?$ P
       (e.g., DOS FDISK, OS/2 FDISK)5 X2 ~* |; ]  L0 E/ V; H
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
8 q. q- k; }: v$ ]. W    Command (m for help): p
0 T5 d, L9 D" U! r4 z7 P) V$ W1 `    Disk /dev/hda: 4294 MB, 4294967296 bytes( ?8 A, R  ^% l% R! x, G
    16 heads, 63 sectors/track, 8322 cylinders5 H! \7 F+ {/ t, P6 c- A. x
    Units = cylinders of 1008 * 512 = 516096 bytes
- f  f, A) o/ J. ?/ i       Device Boot    Start       End    Blocks   Id  System( B. C/ a, `5 X5 q0 p
    Command (m for help): m# N% A% w6 e) W% y7 @" B0 l/ f
    Command action- z& f+ G# i. A. u8 a. i: K3 d
       a   toggle a bootable flag
' S$ g, t% a" b       b   edit bsd disklabel% ]- G; z) m; z( r# p. I& s- q4 E
       c   toggle the dos compatibility flag
" I' O& L/ p0 b* N" T# v# P       d   delete a partition, Z! b5 `5 p/ P- L
       l   list known partition types8 e- K5 @! @3 l  C9 C
       m   print this menu
% Y1 x; Z/ K5 O' N       n   add a new partition  r; \0 L2 |$ z  A1 T4 F7 c
       o   create a new empty DOS partition table# v$ Q9 w8 T5 f; d3 a
       p   print the partition table
/ A6 V! [( i2 \3 x. T2 W: I- N       q   quit without saving changes
: {: r( N8 [: c! c: _# Q5 X5 }- g       s   create a new empty Sun disklabel
4 o- h2 B& ~" \( A& x  z       t   change a partition's system id
2 t/ x5 w! w9 ^( u# ]       u   change display/entry units
. J2 L: ^+ V7 e       v   verify the partition table, h& J2 D: a7 ?: h' [
       w   write table to disk and exit
9 x4 I" z, r4 [; w2 N/ A       x   extra functionality (experts only)9 _. s; F+ k; D0 D% r; C9 i2 S
    Command (m for help): n
3 I% D2 Q) k3 g6 I; t    Command action
! d! W5 D& U& ?% `6 q       e   extended
. O7 i' Y9 {  F- O  w       p   primary partition (1-4)
( D# W1 F/ b' K# \8 y) h    p. }6 e' E: @  v% C+ |: X
    Partition number (1-4): 1
6 \/ a3 \7 O9 e  r* x    First cylinder (1-8322, default 1): 9 i8 [+ p& H9 @. ]
    Using default value 1
. n. ?: W( f  [. p8 S- A    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G0 D! O- e' Q3 K
    Command (m for help): p
- t: X5 x: K0 ~  S6 j6 b    Disk /dev/hda: 4294 MB, 4294967296 bytes
6 E7 X. k; s; v- C, g    16 heads, 63 sectors/track, 8322 cylinders
* L0 C8 h7 s% `" \) }0 K7 C1 s    Units = cylinders of 1008 * 512 = 516096 bytes% M( @! m. e- }) `  C3 Z3 A  t
       Device Boot    Start       End    Blocks   Id  System
9 l3 w8 h! H; w    /dev/hda1             1      1000    503968+  83  Linux% D  n! \, {& h
    Command (m for help): w
. q( Q, M* p7 b) Q' B  Y2 j    The partition table has been altered!
, c" E" h& l7 b    Calling ioctl() to re-read partition table.' \; H% J( @$ g! t+ }( B
    Syncing disks.. Q( f& {% g) A' C" M5 U
    //格式化新分区
8 v& @; M$ r! S9 ^4 N
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)2 j% D, {; f+ _, q( i( Q! `
    Filesystem label=
) ?  f% s. W7 H  Y4 U    OS type: Linux
; g5 w$ B2 t) n. q4 ?4 b7 P+ |    Block size=1024 (log=0)8 H; b; I7 n! z& d0 R
    Fragment size=1024 (log=0); H" ~2 ~! f8 n  w$ ~( A" u: ]1 |
    126480 inodes, 503968 blocks* _& s, ^! e  @1 Z% o5 k5 u0 ]3 H9 W
    25198 blocks (5.00%) reserved for the super user9 K) S# n; J: c1 l
    First data block=1
  u, Q, l/ G0 n    62 block groups+ H: ?  \( S# [& \( E2 X
    8192 blocks per group, 8192 fragments per group# }/ K2 r0 ]8 L& J
    2040 inodes per group
! Z0 m$ ~6 C. t- D* _! W    Superblock backups stored on blocks: 0 a" J9 m* M% M: l" R
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014090 @0 Y" |: e2 y+ A$ [+ t0 F
    Writing inode tables: done                           
- ^! m" w7 ?. G3 h5 o( b7 C% A    Creating journal (8192 blocks): done# O1 ?1 n9 [) f
    Writing superblocks and filesystem accounting information: done, t; |( A+ }  b% _
    This filesystem will be automatically checked every 30 mounts or
- G1 M, N9 \' f* j, p    180 days, whichever comes first.  Use tune2fs -c or -i to override.2 b8 }7 e7 f: I  T/ j
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
) a! x0 C- {3 R+ S    /dev/sda3              3723848    705992   2828692  20% /
* G0 ]7 `4 @' b9 j4 o" ?/ m6 K    /dev/sda1               101089      9274     86596  10% /boot
2 E6 }& Y4 r6 `    none                     14520         0     14520   0% /dev/shm8 c: Z, N( m- K8 @6 m$ T, E
    //挂上新分区
7 C# L( Y+ N5 E$ E* x
  1. mount /dev/hda1 /home/ o7 y6 ^4 d4 d/ F" E
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
, G  }3 e3 B& n3 e5 K) W' A4 O- d    /dev/sda3              3723848    705992   2828692  20% /8 l: R' b0 N$ I+ a& E- B
    /dev/sda1               101089      9274     86596  10% /boot& w( i- J( h9 {  _% k
    none                     14520         0     14520   0% /dev/shm" }  S& x3 t( O+ X2 d+ j
    /dev/hda1               488006      8239    454569   2% /home' T; }; c4 L! u% V) t/ g. h+ A$ ^

9 T+ e4 e6 U, \9 L6 ?自动挂载:
8 v3 d" m7 r) P( }+ }) r4 ?
  1.           vi /etc/fstab# }! \9 ^2 L( L) s! H' g  a9 g

  2. & I. |" a2 C, G1 Q; ]- l
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    ' u- \  X) C9 S& G
  4. 6 p% @) e' K! a
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:  ]7 Z8 `9 X) y8 _/ \
  1.           mount /dev/sdb5 /mnt/ljp1
    " m+ e4 [  ]; o' h' D' o! A4 D) h

  2. % e6 H+ H. t4 ]$ V$ F% Q* X
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
7 ^7 l7 H) Y* g9 g
' J: X0 {/ ~' ]! a3 a# u

6 x2 t/ B2 ]; [/ x$ O% |8 k# K. w* j5 I
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-10-10 02:43 , Processed in 0.007044 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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