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

 找回密码
 立即注册
查看: 2693|回复: 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! B+ H6 B- L
      or: fdisk /dev/sdc  (for the third SCSI disk)
( t+ [) U0 K* ], Z      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
& a4 Y0 C% y: A& P" C3 U      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices), W7 x3 q# J$ t# D' j
      ...
1 [, U' T$ W& J" f( X
  1. df -k. d8 I" G! S" D. v, \
  2. df -lh
    ' y/ {# N# C2 f6 q# S
  3. 查看有几块硬盘:fdisk -l/ b9 d3 R5 S' ?0 t8 p+ J/ B! \5 G
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点4 c) A, r6 c1 k- G6 ]
    /dev/sda3              3723848    705968   2828716  20% /+ |9 B! e3 |) e8 ?. h3 T3 Z5 ]5 {
    /dev/sda1               101089      9274     86596  10% /boot
% G. e2 k. O" P# y( Q1 d    none                     14520         0     14520   0% /dev/shm& o2 [6 }' f! w1 S6 d6 j% i9 ]5 d
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用; m# O! R0 a3 v- u8 Q0 [: m
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel  Z) Z' r4 }, |9 y1 E
    Building a new DOS disklabel. Changes will remain in memory only,% R% U! ?$ O9 |# ^# n
    until you decide to write them. After that, of course, the previous$ K% f5 J7 ~) o, V
    content won't be recoverable.0 q3 Z7 q& d: `% Z/ A
    The number of cylinders for this disk is set to 8322.; q/ H! f, G! J
    There is nothing wrong with that, but this is larger than 1024,3 Y7 B; ~1 {% |5 i$ S+ H: k" J
    and could in certain setups cause problems with:
7 P% m% q, Q* I4 k+ K0 J    1) software that runs at boot time (e.g., old versions of LILO)
# H" g9 d& F4 ?3 q3 I' T! S. y    2) booting and partitioning software from other OSs
9 [0 S$ l' V, m& |       (e.g., DOS FDISK, OS/2 FDISK)) Y1 ^$ C( n9 Q9 r$ g
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)  t% ~2 y) t# }
    Command (m for help): p
, H- b# x/ ~6 B# e* A/ g    Disk /dev/hda: 4294 MB, 4294967296 bytes: p- `2 {, m8 B" P6 m9 S
    16 heads, 63 sectors/track, 8322 cylinders7 K% o' ~/ m$ O# {' k% M
    Units = cylinders of 1008 * 512 = 516096 bytes
3 z5 [, s! T3 U& `( S8 |' X/ D- j       Device Boot    Start       End    Blocks   Id  System: _8 m3 j0 p) a  k( f
    Command (m for help): m
2 x0 ~5 k* g5 s7 u  O* p# E    Command action! W: b* c4 j" ^0 [% g
       a   toggle a bootable flag
$ M4 |* ^2 q& _% G. [$ o2 u% @3 {       b   edit bsd disklabel
0 p0 ~. ]4 J" i- V# g% G( Q' F+ a       c   toggle the dos compatibility flag2 C4 J  [  k6 |: {; H, y+ \
       d   delete a partition
0 R% u- f3 [" L4 T       l   list known partition types
5 ~& T9 c1 p- U2 K, h       m   print this menu
$ f# ~$ Y' I; S4 R8 G       n   add a new partition
& U) S7 J3 \6 c- l       o   create a new empty DOS partition table
9 U7 w5 K; b2 D       p   print the partition table4 ~  B# @* R4 o
       q   quit without saving changes
, Z0 P* J$ u; L       s   create a new empty Sun disklabel
7 I1 _/ j1 A- m9 m1 ^       t   change a partition's system id
3 }" o9 q# y1 f) z       u   change display/entry units
) H! B' |) Y8 [0 Z/ |; M       v   verify the partition table; `- M7 @; h& E; n, ?
       w   write table to disk and exit" u( v: |8 S0 b0 M  f" c6 C
       x   extra functionality (experts only)
3 K) r  n0 P; u! |# R% V  f    Command (m for help): n
2 ?9 d4 Z% E2 S# H9 M  [; J* W2 N    Command action% M' _" R% q3 h" F
       e   extended5 ], _5 J- h" u# }- W# _6 A3 k
       p   primary partition (1-4)9 D/ I  ~, M9 b7 j/ K
    p
! X) _4 L8 J+ x2 ^    Partition number (1-4): 1
+ d- o" Z5 W  O+ P+ A. E    First cylinder (1-8322, default 1):
" ~6 w) b1 d; o! }# P    Using default value 1
3 D( a9 G! P' F$ l5 K3 F* ~& p" Q    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G! _" E6 J6 {# l2 [4 J
    Command (m for help): p/ c1 s; C1 \" a( m: d+ ?' H
    Disk /dev/hda: 4294 MB, 4294967296 bytes
" \- z5 i# g% y    16 heads, 63 sectors/track, 8322 cylinders
, t# t0 F! j  i* i! s) M    Units = cylinders of 1008 * 512 = 516096 bytes( P/ I' k% a. z6 y$ r
       Device Boot    Start       End    Blocks   Id  System
2 I6 ]0 R2 |7 Q! N8 h2 Q/ r    /dev/hda1             1      1000    503968+  83  Linux
( j( l& {( I+ d5 m7 c& L- C8 Q    Command (m for help): w# z! c. S3 C# |4 C5 {3 ]# \
    The partition table has been altered!
* T% I; _  o. V4 B2 \    Calling ioctl() to re-read partition table.' _" A/ Y. k8 S2 I+ l6 z
    Syncing disks.
( N1 F8 G& I2 t. w    //格式化新分区- T$ V/ G, D# ~/ y9 A
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
$ [0 _$ u* Y  ?    Filesystem label=, {2 N8 O4 o' s5 d1 Q
    OS type: Linux, z0 c: [; T7 o+ J) W  `
    Block size=1024 (log=0)7 h. q) R4 x4 c, e6 G2 W# O/ J
    Fragment size=1024 (log=0)
0 `9 G6 A* d# Y3 b    126480 inodes, 503968 blocks" ~" {; m# K& S
    25198 blocks (5.00%) reserved for the super user% h: ~' l0 R2 O# S/ ~" G
    First data block=14 f6 h! P: U# e9 ^- H, M
    62 block groups& O* V4 c' F& B! r( Y& k
    8192 blocks per group, 8192 fragments per group
4 m6 i3 d9 z! [- p    2040 inodes per group
4 Q7 @: A( B( D8 u0 O    Superblock backups stored on blocks: ! |- S+ z4 ?& n0 w4 V: Y& E8 m+ K
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
7 m8 X% p* T6 C/ D    Writing inode tables: done                           
6 t8 U! y$ y! H/ T- [! M" Y% j# v    Creating journal (8192 blocks): done0 g& Y; ?  z5 k& l2 @! Y7 G
    Writing superblocks and filesystem accounting information: done/ l+ W8 o& K+ D+ z) @3 k
    This filesystem will be automatically checked every 30 mounts or: X) j( L' Y7 w2 {: R/ U5 [4 ~
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
5 T. ]+ D1 _) i4 \% d6 C7 Z
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
- t; Y; b- e; r! ^$ i    /dev/sda3              3723848    705992   2828692  20% /0 {: ~8 M  K/ j
    /dev/sda1               101089      9274     86596  10% /boot
2 g) w4 M4 L; v    none                     14520         0     14520   0% /dev/shm! P7 F* l6 z1 W* W7 M* n% Q
    //挂上新分区
  X$ k/ b2 @. X! f0 e
  1. mount /dev/hda1 /home5 H% T' H# V( ?( Y
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点0 `6 y1 k' T. [0 T9 Y6 Z) R' Y
    /dev/sda3              3723848    705992   2828692  20% /
& o) W5 b; M" J$ E    /dev/sda1               101089      9274     86596  10% /boot
$ I2 a$ d; W7 @4 l    none                     14520         0     14520   0% /dev/shm7 L, ~" I6 A9 c8 q" h& M
    /dev/hda1               488006      8239    454569   2% /home& g$ m8 R' Q' n+ c) ]! I

/ Q+ D3 W0 _; u0 ]$ W自动挂载:" E; F6 T# o5 _+ W* a# y  U
  1.           vi /etc/fstab
    : a" d. b5 o, C  d' u' a1 \* H, o
  2. ; G4 H* I" h0 C/ H6 W) i
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    - w# X$ t2 Y7 M
  4. % S8 k( _! u2 q9 B* y) _
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:) f) }  p& B( B! E$ F" t
  1.           mount /dev/sdb5 /mnt/ljp15 t8 c% {; e$ P# q# ]
  2. 6 G; d  Z3 a5 N$ ]$ B4 g
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

8 u+ U8 \7 I0 N( U* k$ w/ q( ]1 p

1 i# F, Z3 G) e1 T0 n# M
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-15 20:33 , Processed in 0.033655 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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