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

 找回密码
 立即注册
查看: 2580|回复: 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)
. N+ i" x0 U+ Z2 T" b7 i+ |* M      or: fdisk /dev/sdc  (for the third SCSI disk)
: t, x7 j1 W4 u; Q      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)7 Z3 U0 j& k$ x$ G
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices). a/ c0 ^5 j$ z* a  [) ?
      ...
. x0 s- z! Z( G/ w# B
  1. df -k# W% ~7 w/ F. x$ s
  2. df -lh$ Z$ `6 z$ F; N4 |! I
  3. 查看有几块硬盘:fdisk -l  E$ o0 _' ?& \+ V2 S
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
8 o" d- }- j. T2 z% L    /dev/sda3              3723848    705968   2828716  20% /2 f% n' s3 ]: y$ i
    /dev/sda1               101089      9274     86596  10% /boot4 Y# \5 B0 Z5 h( j% {$ J
    none                     14520         0     14520   0% /dev/shm
' b4 l/ J9 g9 {, E3 {+ c% _    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
: S) P7 l* J% k( w
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel- j: U# T. R& N1 z4 E- u: r2 {
    Building a new DOS disklabel. Changes will remain in memory only,
- B9 L6 @- u( i. Z7 \5 ~    until you decide to write them. After that, of course, the previous3 r. y1 ~, t& t! ^0 A
    content won't be recoverable.
  ~3 b1 Y+ ?# g$ P/ E* d( p    The number of cylinders for this disk is set to 8322.
! q! h' X6 C. A# Z4 J) b( d9 E    There is nothing wrong with that, but this is larger than 1024,
  t* a' V9 F8 D( U' w    and could in certain setups cause problems with:
) ^, q4 u/ Q+ l) i8 |1 G    1) software that runs at boot time (e.g., old versions of LILO)
! {& P5 P5 G7 g" q- Z    2) booting and partitioning software from other OSs: |: v; @6 |+ [; l8 G2 s
       (e.g., DOS FDISK, OS/2 FDISK)
- M9 n1 N6 ~. ^( t* f  e! U$ r5 e    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
& T% M8 @5 p# m( ?* F, m    Command (m for help): p  \2 R* l$ a$ ^
    Disk /dev/hda: 4294 MB, 4294967296 bytes5 t" P$ A9 m7 j' n+ }9 i
    16 heads, 63 sectors/track, 8322 cylinders
( [, R# _  E* j/ _    Units = cylinders of 1008 * 512 = 516096 bytes$ N) Z  v5 h1 o6 Y
       Device Boot    Start       End    Blocks   Id  System# D2 R) \  G. [
    Command (m for help): m
5 h2 b- a$ L6 l: l( b$ o! ]    Command action& o+ N+ H2 A3 G4 D4 Y
       a   toggle a bootable flag& z; L( e2 B4 P, b# M. l) M9 v
       b   edit bsd disklabel( Z8 _* R: h( q! q, N/ l
       c   toggle the dos compatibility flag
. b. {3 c% |8 @7 `4 U( D+ ]2 b+ Q. F' @; t       d   delete a partition
# ]. r* c7 N+ ?' @2 Q       l   list known partition types% |5 t0 t. ^# ^
       m   print this menu
8 Q$ S+ P! g, }       n   add a new partition
7 ]0 R7 f( J$ D* ^3 e       o   create a new empty DOS partition table: V+ v2 o7 T: @0 k* ~3 c: {
       p   print the partition table4 R# c- Z0 i* W- k3 z
       q   quit without saving changes6 f& M. z5 O" \1 q
       s   create a new empty Sun disklabel) `) P0 B" j3 ~  g
       t   change a partition's system id8 W$ }) x# G- R4 N2 Q% @8 Y% i3 a
       u   change display/entry units7 R* K1 K3 E2 G- q4 g" |* L
       v   verify the partition table7 c5 V9 i4 G/ ^& S  `/ D" v3 Q3 i
       w   write table to disk and exit
3 H3 E3 r; P. K; K% L4 e       x   extra functionality (experts only)  X; B8 D& [: z5 v. \  V* _
    Command (m for help): n) L5 b( I/ n5 Z) H9 I7 [  p
    Command action
- }' u2 o: [0 F       e   extended: K9 _% u/ T' y0 Z: ?
       p   primary partition (1-4)  ^2 L  M; r* I1 M7 p* p  ~
    p; H- s: b) }4 a3 N  p
    Partition number (1-4): 1  z* m2 o6 o. z' `
    First cylinder (1-8322, default 1): ( n, P0 S5 B9 d5 P: @" |# L; H) @
    Using default value 1
8 M/ h1 m$ M6 V/ F* }# m    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
4 p5 `/ T  @1 P) F    Command (m for help): p
" x8 F$ }4 V. p    Disk /dev/hda: 4294 MB, 4294967296 bytes
0 W$ X" ?( a, l" a  b) v; X1 i. B: S    16 heads, 63 sectors/track, 8322 cylinders  e6 K3 y; f2 l  {. v
    Units = cylinders of 1008 * 512 = 516096 bytes) C5 s( n9 `" z7 V& b
       Device Boot    Start       End    Blocks   Id  System
) L5 _% A4 z. B6 x; N; b7 a3 ]) s    /dev/hda1             1      1000    503968+  83  Linux
# h* G% ?6 ^4 b' G4 F1 J8 ^( T    Command (m for help): w
+ x: m' Q5 P9 ^2 H2 c    The partition table has been altered!. C$ ^  g7 f3 I: o+ |
    Calling ioctl() to re-read partition table.
8 m: i, u0 T) H" s    Syncing disks.
5 c! L; e- o5 z" s" H! M    //格式化新分区! `) t' _/ s& H: F0 ?: ~% ]  [
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
6 T8 T; h5 M( U) h2 Y' p& v    Filesystem label=
# R. X+ k/ O$ j* ~7 f1 E% c  }/ ]& A    OS type: Linux
1 ?1 x, L  h+ C6 {, V( P2 W% i1 A    Block size=1024 (log=0)
/ H5 A9 a2 w8 W$ \. i3 L    Fragment size=1024 (log=0)
& i# W/ J. `; G2 b# J9 s    126480 inodes, 503968 blocks. Y+ t) n1 h! H& W- Q  p) @- Y: a
    25198 blocks (5.00%) reserved for the super user" U* W4 Y- G* P# J( _' x& E
    First data block=1
1 Z+ D5 s/ r3 S, m3 ~5 r    62 block groups
8 \4 t4 N& M3 F' v. E, i    8192 blocks per group, 8192 fragments per group
- v* ^4 O; w! T8 @7 ^+ A    2040 inodes per group9 B; s- D3 u; {% M
    Superblock backups stored on blocks:
  f0 y) a- z5 X! d( _0 h            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409, a! k- }0 n& |2 n% T
    Writing inode tables: done                            7 l0 l! W/ X6 U% E- M
    Creating journal (8192 blocks): done0 T  a' r% J# e. U
    Writing superblocks and filesystem accounting information: done( M/ }: C  F4 T1 E( Q9 @" a: F) @
    This filesystem will be automatically checked every 30 mounts or
5 q" y* z: s! G, J6 N& |    180 days, whichever comes first.  Use tune2fs -c or -i to override.
3 }  ], e, Z0 y: A$ Y
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点  T: {! K8 k7 K! w; x. p9 y+ @
    /dev/sda3              3723848    705992   2828692  20% /
/ u0 Z8 f3 n( k# \$ B+ {, |5 C    /dev/sda1               101089      9274     86596  10% /boot5 Q2 o2 ~& q, s) ^( Y/ [
    none                     14520         0     14520   0% /dev/shm
0 H& y0 e- K9 ~1 C! k: a    //挂上新分区
5 }. p( v( j9 B
  1. mount /dev/hda1 /home! ]; v& B, K* ~$ r
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
' ?- `" v# n0 G    /dev/sda3              3723848    705992   2828692  20% /( y5 O- F% u1 |  n; i3 t3 e
    /dev/sda1               101089      9274     86596  10% /boot! Z  k: |3 e2 a3 }% Q
    none                     14520         0     14520   0% /dev/shm. `/ f7 z. w- e' ?/ L( T
    /dev/hda1               488006      8239    454569   2% /home
$ i1 K9 H! X9 v0 A0 e" i$ t/ T- H  k. L' j
自动挂载:
8 B4 l% e. B$ f) |
  1.           vi /etc/fstab
      |0 i4 ^* \8 [! j- n

  2. " e) o& \7 g3 u4 L7 e# ?
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    & Q; ]" V* C$ t
  4. 9 {% N) {+ L. b' s# `8 w
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
+ ^& z' {: l8 u& @* \$ C( P; n
  1.           mount /dev/sdb5 /mnt/ljp1
    : K4 c' ]0 y2 W( D

  2. , Z4 x/ d! N1 d# L7 P* j
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

) k  W+ K7 ^0 Y2 _+ P5 n9 l0 ]1 t; D, t* M& [+ b. L- J5 p
+ ^% Z& ]) v. d; i6 w: ?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-22 19:08 , Processed in 0.037123 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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