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

 找回密码
 立即注册
查看: 2767|回复: 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)
# `- M, m7 k* M) Z9 U7 C" W      or: fdisk /dev/sdc  (for the third SCSI disk). Y9 I& G) o- n
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
: \& P* F2 n9 v/ v$ o0 J! |7 I4 m      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
  x' E- z% h5 w      ...
# Y4 |5 `) N1 @/ |) V
  1. df -k& l5 k# I, P* Q* J8 Z: m0 I. D2 q" [% d
  2. df -lh
    # {7 I& }! q- O4 N
  3. 查看有几块硬盘:fdisk -l3 h/ I  [# S% T8 P2 R
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
  H" R1 ~8 X" A    /dev/sda3              3723848    705968   2828716  20% /
+ a8 E0 M1 H  d4 [    /dev/sda1               101089      9274     86596  10% /boot
& j/ n! Z9 L2 |1 l    none                     14520         0     14520   0% /dev/shm
0 i5 d$ D- L+ f1 j  y6 I    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
% B/ g1 m2 M; b5 P
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
9 J+ t( a  G1 s$ T+ V    Building a new DOS disklabel. Changes will remain in memory only,
. e  n' R, M/ Z' i8 N    until you decide to write them. After that, of course, the previous. m3 b! c! W2 m# a7 ~  `$ p
    content won't be recoverable.
/ u5 f, m  Z9 M9 a5 ^6 v    The number of cylinders for this disk is set to 8322.) c5 O! H" t3 G
    There is nothing wrong with that, but this is larger than 1024,
1 @* c) Y0 ~- A7 R, T    and could in certain setups cause problems with:
: h2 n' O# {1 a& u- W    1) software that runs at boot time (e.g., old versions of LILO)
5 p% y! ?4 m' _3 _+ L    2) booting and partitioning software from other OSs0 S1 `- S+ a/ ~7 }8 W, ~, L
       (e.g., DOS FDISK, OS/2 FDISK)5 m$ p: F; y8 Z8 W! U
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite), v7 R; v8 s9 G, `" N! F4 i9 o5 t6 e
    Command (m for help): p
& v# M- R' E+ m    Disk /dev/hda: 4294 MB, 4294967296 bytes8 G# ~7 V+ G8 X& B
    16 heads, 63 sectors/track, 8322 cylinders" u+ @  m- R: X, z$ M
    Units = cylinders of 1008 * 512 = 516096 bytes
; G" \. v, z  f       Device Boot    Start       End    Blocks   Id  System
. N  q- H$ L8 k: e! N1 n( f' K    Command (m for help): m
' N" O5 B# q, c    Command action% U" Y0 R) y! M6 ]
       a   toggle a bootable flag) j* A3 l0 W* C! V8 p
       b   edit bsd disklabel2 y0 Q# w* S4 n4 i& Z. }$ b
       c   toggle the dos compatibility flag
0 E" U5 j( G7 v# w7 A! z1 |       d   delete a partition
( l* J& h2 b/ j% H5 S  N( c1 c  y" c" ^       l   list known partition types- @+ Q3 d* N4 B5 k6 F8 G4 s
       m   print this menu+ N! C/ n. t, k( _% S" R) G- w7 P
       n   add a new partition/ B& [4 q  q. s, d7 }! U2 C# t
       o   create a new empty DOS partition table3 M, s5 M" D% U- ~. H
       p   print the partition table( s+ _% a* M& ~0 w! z* Q( p
       q   quit without saving changes, w, ?" @6 g# A, O1 Y9 V; Q
       s   create a new empty Sun disklabel4 A/ x' X* O) k5 n
       t   change a partition's system id, a1 S+ v; r& B, m
       u   change display/entry units
+ `1 C( |4 F) A- b7 z, |       v   verify the partition table
" y( n2 }& R- y       w   write table to disk and exit
) `# \  o" I" O# }       x   extra functionality (experts only)& Q. {. y4 e: u9 n2 t$ g
    Command (m for help): n' z' d! T$ h3 h( l, U
    Command action& e1 N( m0 Y" J( Y. ?8 C" |# {
       e   extended
2 p3 l/ {8 A& @       p   primary partition (1-4)
1 j: S4 A% y' H    p; \6 r1 G# p2 ?3 U+ O8 X. f' u
    Partition number (1-4): 1
$ w" O. ^* a+ s    First cylinder (1-8322, default 1): 2 O( Z9 A' @5 w8 {, I
    Using default value 1' P# V; O7 @0 J5 h5 H/ x
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
6 ^7 I' W$ e* T& C8 M2 F    Command (m for help): p
$ ~( U* {9 A: V    Disk /dev/hda: 4294 MB, 4294967296 bytes! j7 ^: t" ?5 T( ~1 Q& {5 h" A& o3 H. E
    16 heads, 63 sectors/track, 8322 cylinders4 Y. a4 J/ w$ S) @4 M
    Units = cylinders of 1008 * 512 = 516096 bytes
1 X* ?: W) P$ }! g2 `+ N       Device Boot    Start       End    Blocks   Id  System* |4 Z; e1 |" U6 R
    /dev/hda1             1      1000    503968+  83  Linux5 ?1 A. m! L% q6 C
    Command (m for help): w
1 z; z4 i0 {7 P" G2 b* t9 `    The partition table has been altered!* `' s# V9 [) Y$ d# L
    Calling ioctl() to re-read partition table.
; c0 O9 i6 X  w  e9 J1 X    Syncing disks.
+ d4 }+ ^/ Q$ R: c- u+ C! D    //格式化新分区! A4 s" M/ l; l7 ^# N/ d( |
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)- C' c7 s$ {$ B* h" q; g
    Filesystem label=
9 U( e4 ^# y( S7 o: B8 X" u+ `, B    OS type: Linux
  l. C  U+ x; q3 f- j9 T    Block size=1024 (log=0)
( E# R  @: K# n# p4 T    Fragment size=1024 (log=0)
. }' C9 N, T3 F9 K  Y8 b  r    126480 inodes, 503968 blocks5 F2 f* [% N2 k) D2 Q
    25198 blocks (5.00%) reserved for the super user1 Y7 |: ?' ~; I) D2 D" w
    First data block=1
0 t4 g3 {  A# M) G* L, m' v    62 block groups; e4 v8 i, y0 S# M$ J5 H5 ^
    8192 blocks per group, 8192 fragments per group
) V5 F; ?& P- Q9 H    2040 inodes per group/ n, Z: N; B- v& g! T0 g
    Superblock backups stored on blocks: , V1 m( D3 t/ s
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409. ^' s0 E1 r2 Q0 j9 @/ H% _8 v; z4 p
    Writing inode tables: done                           
8 Z- ]: Z- W3 ?4 a    Creating journal (8192 blocks): done- y" |/ \9 J$ ~
    Writing superblocks and filesystem accounting information: done
/ I# h* n8 c9 [( @! B. L    This filesystem will be automatically checked every 30 mounts or
" D) Y: J/ c& N6 a0 K3 D6 j    180 days, whichever comes first.  Use tune2fs -c or -i to override.
  M6 N( Q5 ?- r
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点% K+ o2 E' G2 [8 H' H
    /dev/sda3              3723848    705992   2828692  20% // D- d( [# h8 @! y+ v
    /dev/sda1               101089      9274     86596  10% /boot4 n7 n5 W: W# N
    none                     14520         0     14520   0% /dev/shm
) f6 V# x' Q# h: L% z" y    //挂上新分区
- e0 l+ n7 M* Q+ y
  1. mount /dev/hda1 /home. h6 v" H. ?; G) `/ n
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
8 A  H! ?! P2 z, u3 w, w2 k    /dev/sda3              3723848    705992   2828692  20% /
' [7 B1 j5 V/ T4 ^: U& p7 T    /dev/sda1               101089      9274     86596  10% /boot
5 f% n+ I* Q% p9 b2 O$ `) X    none                     14520         0     14520   0% /dev/shm
% B% ]* x9 `  |% d4 M+ R' e4 b    /dev/hda1               488006      8239    454569   2% /home! d8 a$ x; I4 O) _8 S
0 G; Y" H" Z* G( r
自动挂载:
% n2 _% f- Z) O* F
  1.           vi /etc/fstab& r) I* |. ]  ]8 l

  2. + R0 O! w% H& j0 i6 I9 m. n2 M
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 08 u7 m) P: G' E

  4. * I/ C5 n2 [7 X& G
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
( r- }; L; O  J  c
  1.           mount /dev/sdb5 /mnt/ljp1
    & a/ z% k/ F' W' l5 N7 I

  2. + [7 s2 z5 Y+ `; P4 N% i! t' i
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
8 n/ a" {' }8 ?" Q* L

$ P7 C7 Z# |+ k1 M" y5 Y5 [7 n# v0 x+ e+ H: F
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-12 01:56 , Processed in 0.011664 second(s), 6 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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