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

 找回密码
 立即注册
查看: 2837|回复: 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)1 E: q: o5 J* a6 g% v# D. s
      or: fdisk /dev/sdc  (for the third SCSI disk)
# D, ^! }2 j9 x( b$ G, g; o      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)% P- N0 C  a: p! y8 _, z. U
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
3 T9 l3 m1 }( v) c; e: U      ...9 _: U1 l! F! n$ M
  1. df -k
    & ]8 f0 v; |' i
  2. df -lh4 u& y) I3 c0 P2 p  b' f
  3. 查看有几块硬盘:fdisk -l
    - V7 `9 v: x2 o/ B( z+ g& V0 R4 k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点6 r! B! d- N( y0 ~( w
    /dev/sda3              3723848    705968   2828716  20% /0 ^1 o& V  `: v  s) n: [
    /dev/sda1               101089      9274     86596  10% /boot
& L% y* J9 |# A2 L- j( {    none                     14520         0     14520   0% /dev/shm& D' A# U9 N4 ~( ], I& x
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
! z2 L& V( s% @
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel0 L; C  e! ~# T* a' Y& P. G0 J
    Building a new DOS disklabel. Changes will remain in memory only,9 d% e$ Z5 ~2 t! |6 j( e
    until you decide to write them. After that, of course, the previous: s$ s( E. \) R. i* U: s
    content won't be recoverable.# H" S! h0 i' y- i9 U# h
    The number of cylinders for this disk is set to 8322.2 `0 d1 F3 a' y0 Z% q
    There is nothing wrong with that, but this is larger than 1024,
6 p% N, W% d4 t& S% ~' b' Q    and could in certain setups cause problems with:
  j, D" e( F) m$ a2 s    1) software that runs at boot time (e.g., old versions of LILO)& V( A3 X6 {0 r5 W
    2) booting and partitioning software from other OSs
* z0 }+ Y7 X7 b4 H7 ?       (e.g., DOS FDISK, OS/2 FDISK)
3 L1 l) f7 l% s" }1 p) V; x    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
; d6 @5 B# T( {    Command (m for help): p
+ M) v: `% j1 c    Disk /dev/hda: 4294 MB, 4294967296 bytes
! O9 M; P; k6 S" v7 }6 P6 f2 N    16 heads, 63 sectors/track, 8322 cylinders
0 S  H6 s- N1 b- U$ A/ r    Units = cylinders of 1008 * 512 = 516096 bytes
3 x2 w; v: @# v* L4 T1 A       Device Boot    Start       End    Blocks   Id  System+ r! V; O# Y/ e+ ]: Y  Z
    Command (m for help): m
4 A+ W% A% |  c% h* {' x4 n    Command action- L* i" H! E1 a
       a   toggle a bootable flag
% T  q$ @. P* D, f! r6 N; J       b   edit bsd disklabel5 x7 X% `3 C# Z' \: Q
       c   toggle the dos compatibility flag
% V) o. r" |& i       d   delete a partition+ I( O+ L) g# Q" N! @, O# X, u) b; u
       l   list known partition types
. R2 m5 W% U. p* I# u       m   print this menu7 j. V2 G9 D! t4 u; h/ U4 F
       n   add a new partition; U4 T3 n- b8 z; F
       o   create a new empty DOS partition table$ ?- A2 z: k4 w# r( N
       p   print the partition table# v8 v  i% \5 O6 }- z8 N
       q   quit without saving changes
6 X$ t  J1 h! [3 x. M! p9 l       s   create a new empty Sun disklabel, R3 d& K  m  i# i7 e* A
       t   change a partition's system id
  W6 p7 \1 ~- m( s9 V; N7 ?* P' C       u   change display/entry units$ J% n1 a3 R: t% c. X  f- T5 P
       v   verify the partition table; ^; ]% O- g) j% e5 L' O
       w   write table to disk and exit
" q1 p- B  d8 r5 u  V1 B& j       x   extra functionality (experts only)
" I' O9 {+ E! v1 T6 h$ N9 C    Command (m for help): n* M7 a' l3 [) }1 M7 f  c6 I
    Command action$ c6 p) [" a9 w; f  [) Z& d
       e   extended- ~6 V' \% h/ A
       p   primary partition (1-4)
- H: `2 g! s0 _: u# o: p# `( ?- _    p: G; x' [3 B( J5 H* T4 v- b
    Partition number (1-4): 1
) O* O# M& g: C+ U' |    First cylinder (1-8322, default 1):
+ m$ C9 A+ \1 T  {. ~3 c+ ^    Using default value 15 M& _* s, L$ Y# T0 J2 h
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
% c% P, u' G3 C  t/ B    Command (m for help): p
* l; g8 [* ~3 V- E, J% O" j    Disk /dev/hda: 4294 MB, 4294967296 bytes: U$ k; M% m$ H5 \3 A# V
    16 heads, 63 sectors/track, 8322 cylinders, D* P5 G5 p3 s( w2 f; \! H9 E; I
    Units = cylinders of 1008 * 512 = 516096 bytes, z- M3 U2 b7 @; F3 U8 l0 t
       Device Boot    Start       End    Blocks   Id  System
, I2 S* w9 N. J) c) E* \    /dev/hda1             1      1000    503968+  83  Linux4 ^  q# c# \. I& K- \
    Command (m for help): w+ G4 U+ H7 b+ h& Y& t/ k: g
    The partition table has been altered!
* M0 v' a3 C5 Y- L! ^( P    Calling ioctl() to re-read partition table.
  ?2 F  M4 ]; w    Syncing disks.
9 l& P0 p0 f# c    //格式化新分区0 H% E' R# |4 l
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
$ e# x8 x2 N0 U( w# U+ f4 i    Filesystem label=, r% E0 e8 m: K( H) ?% K5 ~3 @
    OS type: Linux
6 H: K, a/ \* i/ ]5 y    Block size=1024 (log=0), l* N3 n# m$ Q& C" l  @
    Fragment size=1024 (log=0)
/ b' x2 w3 e/ x6 U. F; D5 Q( t4 G4 e    126480 inodes, 503968 blocks; P& b5 L$ Z$ D) P) P; @( m+ U0 L$ k
    25198 blocks (5.00%) reserved for the super user4 h0 f( X. o" A! G! m6 l
    First data block=1$ \. q6 g# O  n9 O/ m( Y- p
    62 block groups
: O; ?& q) e+ X* C  e4 A9 c( D7 |    8192 blocks per group, 8192 fragments per group" B7 r. J; M3 e) P
    2040 inodes per group
$ |! S% l( N7 \, V. M$ W% A( K  o    Superblock backups stored on blocks: % k3 R! r9 O7 F$ L) h& B% [
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409. Q8 Z/ b5 q# O$ I* \7 z/ |( @
    Writing inode tables: done                           
, y4 \  U9 Q( B3 `2 E    Creating journal (8192 blocks): done& H! B( m# E/ V/ D% o' h' f
    Writing superblocks and filesystem accounting information: done$ P8 u( e5 e; n2 R) G' V- e
    This filesystem will be automatically checked every 30 mounts or
5 |+ F% E1 ?. w6 a0 ^( o    180 days, whichever comes first.  Use tune2fs -c or -i to override." P. B& b! ?/ r- A* }7 l" X
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点' w+ |* F) a8 P) y1 f" v- J
    /dev/sda3              3723848    705992   2828692  20% /: a8 L% a' b. [7 [
    /dev/sda1               101089      9274     86596  10% /boot( o, v3 ^# F! x( u& o
    none                     14520         0     14520   0% /dev/shm6 Z/ Q9 `5 I1 |8 U* z, \6 P
    //挂上新分区6 X# `" Y3 o; s+ v! v7 ~2 `8 D
  1. mount /dev/hda1 /home
    / o* m' U) P' `  F
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
, F, T' Q! J8 j1 P3 `    /dev/sda3              3723848    705992   2828692  20% /! ?/ K( ]" k4 z0 s9 |4 o8 B* z
    /dev/sda1               101089      9274     86596  10% /boot: }7 Z/ U& n4 N
    none                     14520         0     14520   0% /dev/shm
! Y% ~5 R, {, n1 }) J  i    /dev/hda1               488006      8239    454569   2% /home* [1 l- F/ m3 F9 x% h3 H# Y. V
- h0 h: F, {7 B! v+ v3 l
自动挂载:
% L3 Y( J% r/ N0 ?; T
  1.           vi /etc/fstab
    + E* R* M8 L) P; X# V6 E
  2. ; Y6 Y3 [4 V# A9 h6 z, V/ c$ E
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 02 x. A+ ~2 l" h. V, v! v4 q

  4. ; E/ z" U$ U" j; |. L
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
. S5 Q3 m+ ^. t  ~, \( G
  1.           mount /dev/sdb5 /mnt/ljp1
    0 j& f, c! a6 P6 }: n

  2. : D. s. ]. x) H# ^. n
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
3 S" S0 M2 d6 G

1 p; r8 \& _" i
, ^( M; q+ f) m  |
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-23 18:21 , Processed in 0.038659 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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