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

 找回密码
 立即注册
查看: 2712|回复: 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)$ Z& Z: A5 V/ x% W: e9 a1 d1 v7 X
      or: fdisk /dev/sdc  (for the third SCSI disk), @" g1 @: u; x( z' Y% q9 X1 O
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)4 J( R/ `: N0 g! w% P7 f
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)% x( i+ n! r: a9 Q6 C  E' R: r- l: T
      ...
4 V$ r3 S+ ~: Y6 S
  1. df -k6 j4 W# M% ?# g9 @
  2. df -lh6 _2 K4 w/ t8 h+ q0 y9 ?2 K/ U
  3. 查看有几块硬盘:fdisk -l
    1 D6 {( d: D8 Z! V% g0 `
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点2 |) `7 |' [" B6 h( l
    /dev/sda3              3723848    705968   2828716  20% /" |" E, c8 O3 [0 u* o+ \
    /dev/sda1               101089      9274     86596  10% /boot, c( d( q3 i9 L6 \) }1 \% V3 m8 S' X
    none                     14520         0     14520   0% /dev/shm/ k' u4 L9 ?! \  N
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用. G% [% L4 T. I3 I. I3 R
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
$ G: o% o# b2 Q1 s1 f    Building a new DOS disklabel. Changes will remain in memory only,- d& N6 i6 v3 P8 ~* {% o( ]$ k# {
    until you decide to write them. After that, of course, the previous
& }9 t7 J$ V0 X    content won't be recoverable.6 Q+ t; Z$ ^6 g- l
    The number of cylinders for this disk is set to 8322.
9 g8 M) V+ J; k3 Q$ h5 X    There is nothing wrong with that, but this is larger than 1024,/ E. O2 `8 K: f: a8 c. o' D
    and could in certain setups cause problems with:
: P5 U4 e3 u: A1 V3 F- t+ r0 {    1) software that runs at boot time (e.g., old versions of LILO)
8 p8 P6 ?# N0 k/ F    2) booting and partitioning software from other OSs
1 M& B( c  K: D" ^' c: \- i       (e.g., DOS FDISK, OS/2 FDISK)
5 t& L% g* k! G8 M    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)3 }. K5 ?2 b8 V4 H' F' R4 I
    Command (m for help): p6 l( m1 \# h4 h
    Disk /dev/hda: 4294 MB, 4294967296 bytes1 I$ }# J# w! C/ a8 p" [
    16 heads, 63 sectors/track, 8322 cylinders
% M  |" V+ U9 i" E    Units = cylinders of 1008 * 512 = 516096 bytes
- V, U* L! z* k5 b. ^, e4 c; |9 a       Device Boot    Start       End    Blocks   Id  System5 e1 R. {: X9 ]; d. k, J" S
    Command (m for help): m" ^5 p+ \: N+ Q6 R! S& ]
    Command action
. X  w& [1 ]  A* @# _6 e3 v       a   toggle a bootable flag8 e- n' V% W; ]7 Y8 w. }
       b   edit bsd disklabel
$ R* L: W( [0 d& H" I+ Q       c   toggle the dos compatibility flag. g7 {) W9 k6 u  Q9 `* L" B. `
       d   delete a partition) t2 S& m6 b3 ?" [; C  J( o
       l   list known partition types
6 i6 l9 r# W$ z3 Y& G; g       m   print this menu
! Y: E' F2 x' s  R5 N       n   add a new partition8 k1 N/ ]; V  u) Y: B
       o   create a new empty DOS partition table
! o6 [$ x5 c9 N% @3 d0 r. y       p   print the partition table
1 N  W  {2 s. `& z: Y       q   quit without saving changes
2 L/ u9 z5 |3 F7 c* H& }       s   create a new empty Sun disklabel# ?) b" o( H" z$ U
       t   change a partition's system id
" t) B& k1 H  G, B+ E0 `       u   change display/entry units% B  |- Q3 g. n6 x7 h, w
       v   verify the partition table+ ~5 {) r" @0 Y# q6 ?# L
       w   write table to disk and exit/ R! [$ y6 t) e$ v5 G! D0 e  D  o" W
       x   extra functionality (experts only)
) T( a, m! e' A+ M    Command (m for help): n
( X: p# h) p: x1 N2 _& d    Command action
5 S8 ]+ `' E' w: j+ H       e   extended
  H2 B0 ?; D& ~: ]; s( o* n7 x% c       p   primary partition (1-4)
$ n" X; c/ F. w6 p% ?    p7 i7 E9 F3 |: \
    Partition number (1-4): 12 A) M3 x; T# V1 @$ ~
    First cylinder (1-8322, default 1):
2 A2 S+ d) j( F* N, l    Using default value 16 t: E; c8 I; P  [+ u' S
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
7 _+ Y: F4 S- i$ W$ z2 q3 I    Command (m for help): p
) E8 f# {0 A/ S" M    Disk /dev/hda: 4294 MB, 4294967296 bytes( m; n% e7 B2 A! R
    16 heads, 63 sectors/track, 8322 cylinders
7 P  o# @% y8 V+ z& ~    Units = cylinders of 1008 * 512 = 516096 bytes
/ n" ?! [# A  ?( d3 W/ e5 B- T4 x0 h       Device Boot    Start       End    Blocks   Id  System2 W' u  r( Q& Y" a7 V
    /dev/hda1             1      1000    503968+  83  Linux
, S; t0 m  z5 W# K/ m6 |    Command (m for help): w
. _5 x# J* A3 c  a& e    The partition table has been altered!
- w3 h$ ^/ }5 j/ _# H    Calling ioctl() to re-read partition table.* i* k8 C! o8 z0 E3 O% G+ n( h0 i
    Syncing disks.
1 l/ x2 X4 x; n$ {2 _5 o' ^    //格式化新分区
1 F+ D: `  W, {1 p8 O6 O* C2 o2 L
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)$ B/ g+ ^+ }3 V* A; |
    Filesystem label=
4 o; u# ^+ L9 J1 l9 i/ K! \    OS type: Linux3 F7 v8 ~# q" P. Q. y
    Block size=1024 (log=0)* Z7 ?, }& g+ c! }& Q- U2 r7 F
    Fragment size=1024 (log=0)
8 }: E3 v8 ]- J. X7 T& i    126480 inodes, 503968 blocks2 a0 J# v7 F: m2 e
    25198 blocks (5.00%) reserved for the super user
! n0 \% C5 h; `; Q2 q- V    First data block=1
! |' w# Y% @* `) M$ |3 `+ g    62 block groups; x) {' t" a% j
    8192 blocks per group, 8192 fragments per group0 Z$ }" @9 h' d# a# i- _/ ]
    2040 inodes per group; Q5 n; f. E+ ~: }4 A* p
    Superblock backups stored on blocks:
9 t) i+ |4 W* Z) X2 H- E            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014090 l0 c; j8 r8 Y3 U0 `
    Writing inode tables: done                           
' [% D* R# K, W. ^    Creating journal (8192 blocks): done
& }! C4 `+ c' h8 M    Writing superblocks and filesystem accounting information: done7 @) m+ G+ g) [3 ~$ m
    This filesystem will be automatically checked every 30 mounts or
$ C2 C& x  r# f& |5 f0 E    180 days, whichever comes first.  Use tune2fs -c or -i to override.! D3 R. L( s* B
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
3 b; A8 R+ w9 t    /dev/sda3              3723848    705992   2828692  20% /
, m0 W- H9 D- R8 g    /dev/sda1               101089      9274     86596  10% /boot4 g5 U) q4 s" Z( t! Q9 c. ^5 Q
    none                     14520         0     14520   0% /dev/shm% v/ B: I/ i1 W5 p
    //挂上新分区  x  x  S4 i0 \6 ]  Z4 n& {. a$ |
  1. mount /dev/hda1 /home% R: d* z8 Y" |1 n4 @3 f* r  o
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
, W7 Z0 A4 Z; g3 a3 t: B    /dev/sda3              3723848    705992   2828692  20% /- @  h/ t/ f' m5 X* G
    /dev/sda1               101089      9274     86596  10% /boot
6 u: K+ }* {# h1 B7 T" z; M    none                     14520         0     14520   0% /dev/shm
4 O; y: C& Z& |' y5 z, d9 T    /dev/hda1               488006      8239    454569   2% /home
% P# [$ N! A. g' `) B" j/ F  r! q4 s# }( `  _$ ?, C  q6 \# w5 [
自动挂载:
$ |0 \! w% M  J' \' w" L% }, t
  1.           vi /etc/fstab6 z( c0 F0 @- B+ \; s; w+ V2 ~8 l

  2. 4 L( C! J: P4 N* T( x
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 00 z2 G: U3 k1 ], {; ?5 ]

  4. 6 U# G6 J* z- s4 r; ~' H8 S7 P7 h
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:; s5 c) p5 a7 M
  1.           mount /dev/sdb5 /mnt/ljp1
    2 m: z6 E8 L$ r+ e/ |. W& _4 [* x

  2.   E% C$ y3 t  M, e+ V. [
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
2 C' l6 b, p* R8 I+ `: j1 v, I

- B6 ]* T8 t: W" r+ |! }9 Y( k) h1 ~# o  d$ [* e
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-27 01:38 , Processed in 0.016536 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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