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

 找回密码
 立即注册
查看: 2760|回复: 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); R, I5 u, u" q- I* k/ F$ L/ z
      or: fdisk /dev/sdc  (for the third SCSI disk): a" \  k" b; m6 i* y
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)$ i6 f- z$ d% ?: d' H, e
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)1 ~9 z2 t6 q+ }  C* W* s' w4 T
      ...  E" X0 ?' |) v8 O
  1. df -k
    # ~( k8 N' n0 h: H" L0 G/ U
  2. df -lh1 I6 Q4 L# q( y  g
  3. 查看有几块硬盘:fdisk -l
    0 p" ?$ ^+ t! \# x& F' Q
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点/ `) D$ r7 b3 g+ H( D
    /dev/sda3              3723848    705968   2828716  20% /
" A: I4 o/ y$ J    /dev/sda1               101089      9274     86596  10% /boot
7 h& R1 B# W$ w* S: r4 c& }    none                     14520         0     14520   0% /dev/shm3 ?; T9 _# M, L" J3 A; {
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用4 }9 X+ S0 I3 B# {: {# I
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel- z6 o4 l& h1 j8 B6 U" A! f4 h
    Building a new DOS disklabel. Changes will remain in memory only,: f: D" c- }% G
    until you decide to write them. After that, of course, the previous' E* @. Y" A/ u& x9 g
    content won't be recoverable.
) e/ Q* y4 b2 M4 h5 u    The number of cylinders for this disk is set to 8322.) j4 t& S+ V! q# @& A/ ~  o6 N: _
    There is nothing wrong with that, but this is larger than 1024,( A9 ]( N/ p5 f6 _* ^& E# n3 }9 s( @- Q
    and could in certain setups cause problems with:2 N/ `% Q0 U1 R! Q* L
    1) software that runs at boot time (e.g., old versions of LILO)/ k2 X) j0 l$ F: t6 d
    2) booting and partitioning software from other OSs
. n5 d, u) Z) T( C       (e.g., DOS FDISK, OS/2 FDISK)
+ T# v; l5 m; t: i! ^+ C2 i* w    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)% }6 H& E+ [& E& G$ A/ X
    Command (m for help): p
7 P: i  N% [' f! o    Disk /dev/hda: 4294 MB, 4294967296 bytes
: x# \- X4 s5 V5 \    16 heads, 63 sectors/track, 8322 cylinders
2 u+ y" m$ S! x0 w! d$ y% D    Units = cylinders of 1008 * 512 = 516096 bytes7 V) C7 |7 j7 N
       Device Boot    Start       End    Blocks   Id  System
' v# g5 d: z; X) `" z! i. W+ a' e, V    Command (m for help): m
- w$ ]6 e% S& S3 |0 @: A    Command action
8 C& }3 P7 A! @  P& j       a   toggle a bootable flag
  w) P3 k/ f1 u( P& ^2 ]7 ~- a       b   edit bsd disklabel5 U$ c( X; s9 E. O: c
       c   toggle the dos compatibility flag6 S7 S0 h5 n; c/ f
       d   delete a partition& o6 C$ s% j. T) T2 l
       l   list known partition types6 i* ]0 \; W# X4 f% ~. @; o) }/ H
       m   print this menu, b9 [1 ^4 N  s& g4 B  L7 D
       n   add a new partition
1 K6 h9 r7 L* j7 `$ Z/ |       o   create a new empty DOS partition table/ V# q$ y* ~0 {
       p   print the partition table5 P: V6 ]0 O0 K* g9 \8 }$ ?
       q   quit without saving changes
( @8 L7 f9 @. u% R" w       s   create a new empty Sun disklabel" O+ \! E; U$ d# t8 u# Q* K) T3 z
       t   change a partition's system id! u2 ?" Y1 s' w- Z- Y7 b' T8 F7 @
       u   change display/entry units
# G8 ^2 V: h" M- B       v   verify the partition table6 O( q3 k$ c- ?3 p0 r, G. Z. D) ]) ~
       w   write table to disk and exit
$ a! m& s! J5 N9 ~6 y: f: K       x   extra functionality (experts only)! t/ k: h. G: l8 q# b2 d3 ~+ a
    Command (m for help): n! P/ T4 q0 D# o
    Command action7 l8 I9 s6 @1 @8 j$ @$ }* p
       e   extended
" y2 J4 a$ O# a5 i( r  H& g       p   primary partition (1-4)
* ]2 [5 i$ A# L/ U    p3 s1 e$ N+ J% s, r, Y8 m
    Partition number (1-4): 1
: c4 t% v6 D, B* I- e6 }6 g    First cylinder (1-8322, default 1):
8 J" h  {# X# g% }% P  n    Using default value 13 E- B- \+ i& G0 R
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G9 c5 ]8 n8 l- }9 c  e9 ?  ?
    Command (m for help): p
3 ?8 B; _4 z# }' `    Disk /dev/hda: 4294 MB, 4294967296 bytes
  c# O; t$ b; r( j7 j    16 heads, 63 sectors/track, 8322 cylinders
4 a$ M3 e& N+ ]& m    Units = cylinders of 1008 * 512 = 516096 bytes: X1 y1 ]4 k% n3 j1 a# r
       Device Boot    Start       End    Blocks   Id  System
3 }& ~# b6 `# u4 L9 x" m    /dev/hda1             1      1000    503968+  83  Linux
% y5 C# i2 p$ L+ v  r    Command (m for help): w
( k0 C7 R  Q- C6 K    The partition table has been altered!; ?& g2 F( S. q9 e: v
    Calling ioctl() to re-read partition table.
4 D% w2 c8 d; w* k0 C5 ?; c    Syncing disks.
" j+ b0 y# y: k  I    //格式化新分区
0 F. M' g/ `5 h8 l$ M6 _2 K3 M
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
" l: }9 {. A1 {9 n/ U. s+ Y/ N    Filesystem label=
  l5 b& `8 r( D; {! g    OS type: Linux
3 Z+ ^) @; `( H4 _8 Y5 H    Block size=1024 (log=0)9 W2 {0 Y4 H) W( Z5 [1 D& \9 r
    Fragment size=1024 (log=0)% X5 v0 ?% D! \' @
    126480 inodes, 503968 blocks
" U# ^; }/ p( l% ?    25198 blocks (5.00%) reserved for the super user
* n) s& W" {4 K3 t    First data block=18 o) R& i9 n5 G' K0 p
    62 block groups
9 V3 \; f/ {9 y- p) e+ _% k* {    8192 blocks per group, 8192 fragments per group( Y$ c& R, P% J+ n+ n/ h  `' D
    2040 inodes per group
$ [8 [/ r! D0 E$ a; c# p* _8 N    Superblock backups stored on blocks:
5 m- {8 P; _, k            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
, {2 w$ i0 Q3 l  ]! }    Writing inode tables: done                           
; {4 {  O7 B4 o/ x    Creating journal (8192 blocks): done
( M$ D6 O4 g3 ~" g; d: l2 q8 W    Writing superblocks and filesystem accounting information: done
% y0 ?; ]7 ~+ I. h7 {& a5 S# X    This filesystem will be automatically checked every 30 mounts or+ l9 L2 p9 Y' O, `
    180 days, whichever comes first.  Use tune2fs -c or -i to override.5 a" r, w) L5 ~% f+ E$ {, \$ N
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点5 g- D  `( @3 i  a) H0 X. _
    /dev/sda3              3723848    705992   2828692  20% /
4 s. J5 k; q. q    /dev/sda1               101089      9274     86596  10% /boot: p. q0 ~' o/ w/ j
    none                     14520         0     14520   0% /dev/shm6 q6 [/ c/ D. u6 U- r. U
    //挂上新分区
4 Y4 n) \4 A$ p
  1. mount /dev/hda1 /home: F; t. C7 S) t! ]( F" d* k
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
! Y' c3 h( `& a( z( @    /dev/sda3              3723848    705992   2828692  20% /$ b" `; `% \0 n: V! c$ Y
    /dev/sda1               101089      9274     86596  10% /boot
3 ~  i8 k% L3 X    none                     14520         0     14520   0% /dev/shm9 g  q2 P) h: h7 h8 R
    /dev/hda1               488006      8239    454569   2% /home
" r# T1 k% o9 ?- h) N
# _' |# f; x* `: C, N; f4 h0 ^自动挂载:
' T) Z9 i" {7 d( h5 ?2 u3 e
  1.           vi /etc/fstab/ s: \) c, T8 c& ]* ]8 |0 n# h

  2. # _) g  Q0 H9 m
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    ; S+ a$ r7 `, S* G) i
  4. ) T" |, y5 H6 `
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:* T! @. {; p& v
  1.           mount /dev/sdb5 /mnt/ljp1
    * [5 `4 O/ U" x
  2. 5 L& I4 S/ H; u) F2 s* V' v% h
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

( P7 o. W6 F6 z, C$ c7 O7 q  i( Z$ T! e" V9 R

1 H% E' Y# S  t+ i2 f1 K2 x4 [" [$ P
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-10 20:09 , Processed in 0.019933 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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