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

 找回密码
 立即注册
查看: 2806|回复: 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)5 _& T% d  S" s) P
      or: fdisk /dev/sdc  (for the third SCSI disk)
! u; u% _/ s# P  i4 [& |      or: fdisk /dev/eda  (for the first PS/2 ESDI drive). L0 h% _' |1 J% {1 ?3 `9 }
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)+ g8 L% G: }9 f/ D' y
      ...
( \/ y& s: m; b+ U/ p0 N( L# H
  1. df -k
    , |: k( l: L  v3 I8 a$ D( s8 s* H
  2. df -lh
    ! o* r# d# O* q) E- Q- @% s) X
  3. 查看有几块硬盘:fdisk -l1 ~2 F' n1 F4 U! `8 R
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
7 r0 [7 D: X1 R6 O% V) J& B    /dev/sda3              3723848    705968   2828716  20% /7 m+ `" z1 n! q$ E6 z4 F8 f7 E8 O* X
    /dev/sda1               101089      9274     86596  10% /boot6 }- ]2 y" A- j
    none                     14520         0     14520   0% /dev/shm% J+ l8 m; B9 g! Y" R
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
8 a# b. E3 E  P
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
* {, Y$ M' K+ [4 g. u' M    Building a new DOS disklabel. Changes will remain in memory only,2 W- a: h5 V3 p/ C9 |8 C! L
    until you decide to write them. After that, of course, the previous3 m5 N' B0 O. f
    content won't be recoverable.
  C' p, o1 A8 I7 B8 ~8 {    The number of cylinders for this disk is set to 8322.
" M9 D$ ?3 ?4 |# R* R; h    There is nothing wrong with that, but this is larger than 1024,
" x# b% w6 \" {6 D2 t    and could in certain setups cause problems with:
4 m8 O' {2 Z) l5 ]' ]8 U* y    1) software that runs at boot time (e.g., old versions of LILO)! g4 o: A( B6 Q# \! s& ~
    2) booting and partitioning software from other OSs
* W  V( Z" F! R, |. H1 w       (e.g., DOS FDISK, OS/2 FDISK)
! y: I, m9 X# o1 V3 O    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
, X5 t' ~/ v5 I/ b8 U: s3 T    Command (m for help): p
0 q! d) p8 [8 Z    Disk /dev/hda: 4294 MB, 4294967296 bytes
7 @5 k+ h4 h8 w! g( {    16 heads, 63 sectors/track, 8322 cylinders# a  x7 D7 P2 l" K5 J& w5 G* ]
    Units = cylinders of 1008 * 512 = 516096 bytes4 q" c/ ~: O+ k
       Device Boot    Start       End    Blocks   Id  System
% H/ G- a/ f$ n8 T+ I    Command (m for help): m) ?3 ^# y5 E% s% O; {
    Command action
& n$ b9 H1 K# y9 t  W! _       a   toggle a bootable flag# ^5 H& T  V8 R
       b   edit bsd disklabel  s6 l" z7 T9 a9 m$ }, Y( v( T; j
       c   toggle the dos compatibility flag6 L6 _0 I; n- |$ y( B
       d   delete a partition, L) K5 n4 T% u3 q5 C1 ]& _
       l   list known partition types; f4 g( S& H9 j# A
       m   print this menu
0 t, n( q# K$ M3 l, W8 i! L       n   add a new partition
' j# S# D, ~, }) N% ^/ h1 \       o   create a new empty DOS partition table
8 [* _* a! f' y5 F       p   print the partition table/ l9 _: i8 q# {* \+ C/ K
       q   quit without saving changes: V4 ~8 x5 ?8 }: ?% g* y3 b+ L+ ]
       s   create a new empty Sun disklabel
: g/ r3 ^8 H) B0 b" S8 v       t   change a partition's system id) a2 w  q+ Z1 r6 S5 P- U# S! L
       u   change display/entry units
8 M' ?$ E2 {9 z3 E8 q- s3 W       v   verify the partition table
2 H4 N" p7 _1 g, u$ s       w   write table to disk and exit' S2 g" y0 X. D5 A# S
       x   extra functionality (experts only)
2 X9 Y) V" _" [) j2 n    Command (m for help): n
; P/ `2 v7 w) _0 U    Command action8 O2 r- w' c, P+ y$ _
       e   extended( S5 f1 e$ W( D6 }
       p   primary partition (1-4)
  X! v/ J) b( q8 S7 r3 Y( }. L    p
+ x3 N& z/ w2 e    Partition number (1-4): 1
! U: S* J# M, @: b' _) [    First cylinder (1-8322, default 1): ! b5 e7 }2 |4 l1 t; X" J4 C
    Using default value 12 J" k* I5 T9 D" T
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G2 m( M8 W# u, E9 u3 r9 @. X
    Command (m for help): p7 A  K$ B/ q: g: B5 R
    Disk /dev/hda: 4294 MB, 4294967296 bytes6 o3 E! ?. v2 C
    16 heads, 63 sectors/track, 8322 cylinders0 z9 \, j# j0 W
    Units = cylinders of 1008 * 512 = 516096 bytes
' P1 o$ |* P/ @# i' v       Device Boot    Start       End    Blocks   Id  System
' j" R; ^0 B+ h: |) r    /dev/hda1             1      1000    503968+  83  Linux
& p0 d: I+ e6 t* o9 T, a3 x% E    Command (m for help): w6 M. `- p% h  D/ \% R% t7 X4 h
    The partition table has been altered!
- F$ y; z! k0 k- b0 W8 n$ s    Calling ioctl() to re-read partition table.6 X- P  s' C$ Y  _& [4 \( d+ @7 K% J
    Syncing disks.
4 |7 @4 m# w! o' O& g+ t    //格式化新分区
, j/ m/ x) Q8 P: F0 x. ]+ M  g! k
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
& i3 J, R+ Q' n" G2 w2 F    Filesystem label=
$ H9 j7 ]* _/ b    OS type: Linux& D# R3 |; C. l
    Block size=1024 (log=0)
" P4 L: [* b9 w9 L    Fragment size=1024 (log=0)- S9 B& \: p: |. L# v
    126480 inodes, 503968 blocks
& V8 M, ~8 x0 Y& B; l    25198 blocks (5.00%) reserved for the super user) @9 F6 [3 G# T! s# t
    First data block=1
4 }& {: G9 O0 [  Q  l6 [) K" X    62 block groups: ^. A- a$ b  ^' e
    8192 blocks per group, 8192 fragments per group
; X2 ^  V1 P& _    2040 inodes per group
7 w, J2 `. P* f' v1 \0 T7 @8 J    Superblock backups stored on blocks: 3 M$ W. m& Q9 m$ B( Q* m
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409  v" P6 W2 J. C+ ]
    Writing inode tables: done                           
$ M1 m% Y  r# H' U    Creating journal (8192 blocks): done
% {0 t+ F' Z2 f    Writing superblocks and filesystem accounting information: done4 `5 W* G8 h6 m' m- E6 a
    This filesystem will be automatically checked every 30 mounts or3 G: C: E. X4 F0 v; ~* k
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
1 @8 L" H( A3 e# A( G
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点8 U+ D  q! H8 I4 l
    /dev/sda3              3723848    705992   2828692  20% /& Q* |, f, A+ Y& \0 G, D0 L# H: l1 [1 r
    /dev/sda1               101089      9274     86596  10% /boot
  U1 T0 W, E( ~- G: j$ W    none                     14520         0     14520   0% /dev/shm) |; r5 S$ d4 b# n9 u
    //挂上新分区. C& y2 e6 B7 A# U$ M
  1. mount /dev/hda1 /home
    - `6 \8 n( o8 n. R- V$ z3 P, S
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点% ]  o$ Z8 J4 Y+ d- K& R, O
    /dev/sda3              3723848    705992   2828692  20% /9 u" r0 P* m1 @6 K* _
    /dev/sda1               101089      9274     86596  10% /boot( D5 \7 t1 J2 Z7 |0 Y9 I
    none                     14520         0     14520   0% /dev/shm6 s/ y2 I, [: C9 F( N1 e' z
    /dev/hda1               488006      8239    454569   2% /home* M; V6 z! o# P7 }7 }# B
0 s$ a: u0 }7 r4 @, v1 X3 N6 ^
自动挂载:* V, P* ]- e; s+ \: E: o: b
  1.           vi /etc/fstab, z! N% w3 [* }5 g' Z3 `" u6 K5 c
  2. 0 `: x$ Z% A; M6 y9 I, c+ J2 A
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 07 J) Z5 y  J5 Q. ^& ~

  4. / w8 d9 B* b  i! M! @
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:0 m3 p. u' x0 y* ]
  1.           mount /dev/sdb5 /mnt/ljp17 H/ E' c# x' V' _$ T

  2. * q. \$ Z% r, C$ I' @1 f: ?$ S
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
4 U6 G( C, u; P" L3 ?8 Q
. C8 [" F+ a1 [
6 y2 k0 O9 v( J5 b& Q* P! _
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

Powered by Discuz!

© 2010-2023.

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