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

 找回密码
 立即注册
查看: 2589|回复: 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 j7 ?; g! x. q: Y      or: fdisk /dev/sdc  (for the third SCSI disk)
4 r$ H8 E. h6 l' z/ i0 [2 R      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
+ U+ g" S* C  R0 f      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices). h( F# z, \+ c5 o
      ...
' Z: a# l* |  ?1 @+ a: u# T
  1. df -k5 K& [' M8 W5 F: L
  2. df -lh
      S- Z1 k+ e* Q( P$ Q# X
  3. 查看有几块硬盘:fdisk -l) \2 q4 M0 a, a8 U% ^& K( D! g
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
# M* V" k5 t6 f7 t6 ]    /dev/sda3              3723848    705968   2828716  20% /" z: J1 i# B( k
    /dev/sda1               101089      9274     86596  10% /boot
# K7 u: p  y" V* o+ Q    none                     14520         0     14520   0% /dev/shm
8 O: h  o- Y$ V& ?    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用: }) {; V( V8 T1 X2 \
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
' C" T' G0 I* C7 y8 l5 m    Building a new DOS disklabel. Changes will remain in memory only,
8 M6 w0 M8 ~" _8 J5 P% i    until you decide to write them. After that, of course, the previous0 \+ D, K9 ~% v0 \+ a
    content won't be recoverable.% Z9 n8 K8 d) F$ t+ J: M5 b
    The number of cylinders for this disk is set to 8322.
+ {; W+ b% C0 O9 Y' m  K) A    There is nothing wrong with that, but this is larger than 1024,3 [; g# s+ f8 R4 K6 t
    and could in certain setups cause problems with:9 w4 h$ Y: H, b' ]
    1) software that runs at boot time (e.g., old versions of LILO)
5 O% s# b* `9 c9 M    2) booting and partitioning software from other OSs# z! @1 B1 l1 m9 ~* N
       (e.g., DOS FDISK, OS/2 FDISK); M7 ?) P4 s1 {
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)! b4 I* |0 J! B7 f3 F: B
    Command (m for help): p
* g! }" M* i) s+ `& J    Disk /dev/hda: 4294 MB, 4294967296 bytes) B1 U$ {9 R: o8 Y9 p! G$ m
    16 heads, 63 sectors/track, 8322 cylinders; k1 Y/ s/ e, R
    Units = cylinders of 1008 * 512 = 516096 bytes
* T  q; s* T4 F5 F       Device Boot    Start       End    Blocks   Id  System
% b9 N( j# m* G9 j    Command (m for help): m
" q( z3 f' Y' S    Command action  \3 o/ A4 v, F) n2 g4 ]) B; \
       a   toggle a bootable flag
& M8 \, O8 r, u       b   edit bsd disklabel( v: F: S4 e3 |3 A6 g4 c
       c   toggle the dos compatibility flag
9 E; U! P0 i) q2 X3 M( c       d   delete a partition( |3 q. S; @+ q8 ?- _1 ]
       l   list known partition types  Q4 S) g- a) D' T+ _, `
       m   print this menu$ |" f# x* N/ X% s- k& M
       n   add a new partition
8 v" V: Z* N2 t  |7 H( Y. @       o   create a new empty DOS partition table
& \* c+ k0 u  q9 ?& Z$ d9 Y       p   print the partition table* f: c' g: F% k9 m
       q   quit without saving changes
4 B# S8 _1 g! ?% {! I/ r       s   create a new empty Sun disklabel
6 E1 P) Y$ {- H% a! d3 A       t   change a partition's system id
* K, X+ f7 {$ g% q       u   change display/entry units4 O  f1 c* w2 o2 X& H0 x, O
       v   verify the partition table. _8 H% `$ W4 N$ H; c; a( g0 M
       w   write table to disk and exit. @1 ]! s% m4 B3 s1 |6 s
       x   extra functionality (experts only)
+ G# K5 Q! X' r' ~1 @3 B" P    Command (m for help): n6 C, D# b% m6 J- u; T
    Command action: F/ a  ~5 W0 R
       e   extended6 O1 G" `# r2 C1 M- j, _
       p   primary partition (1-4)
+ m4 c" f% k6 j8 W) Y6 b    p
9 F( I. c, ]8 ~    Partition number (1-4): 1
2 z* i) z6 o; B% e: o$ w    First cylinder (1-8322, default 1): ( w8 @% e+ `% i, f& \3 r
    Using default value 1( i4 j8 Z, b; h# T+ Q; E
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G+ K: f) U7 r" Q# C' E% u2 Z
    Command (m for help): p
1 \* g8 Z' B% t4 I    Disk /dev/hda: 4294 MB, 4294967296 bytes9 ~4 G) Q; f, e5 m& N: v: L
    16 heads, 63 sectors/track, 8322 cylinders2 _1 }+ K; T. m  q% q: X- D1 O
    Units = cylinders of 1008 * 512 = 516096 bytes5 \0 i! V$ N5 D+ X8 \" a8 y
       Device Boot    Start       End    Blocks   Id  System; e! |/ G- N+ v; u' K  L) m+ n
    /dev/hda1             1      1000    503968+  83  Linux9 ?# }0 T: j/ Z; _: s7 A
    Command (m for help): w
1 A4 }- a# f3 O+ U: R' }9 M    The partition table has been altered!+ j( Y$ T/ U# L. o$ v# G
    Calling ioctl() to re-read partition table.7 T0 v8 |) G. z! S  z7 m( X& G
    Syncing disks.) K7 I( [3 x! H# [8 M4 o7 W: |
    //格式化新分区
, P# P! P' I* q7 @5 [
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)0 D8 K3 A- v; h# k% n* U
    Filesystem label=9 c- _3 P0 l& G7 p4 N
    OS type: Linux. i4 d* T, k8 r3 F' ?, J; s7 _; c
    Block size=1024 (log=0)
5 x$ P' s% G: N, ^  O' Q    Fragment size=1024 (log=0), @" X% O/ q2 t: x$ d) T: f  _1 x
    126480 inodes, 503968 blocks
6 ]" S4 P2 r. F5 P0 f# b: w/ h6 D    25198 blocks (5.00%) reserved for the super user6 @, z+ y: N4 w5 R. U
    First data block=16 s5 w9 t. e5 Q
    62 block groups1 d4 P  y9 C) [! _4 m( N7 s4 d! Q
    8192 blocks per group, 8192 fragments per group: M: H1 C' N) j- J/ A9 W3 i* D
    2040 inodes per group# Y' ]/ x! p; l# _1 k+ c' f2 c
    Superblock backups stored on blocks: ; L0 v/ z9 Z3 T9 R
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
* e' R1 Y+ p3 U# F- |- ?. w8 m    Writing inode tables: done                           
; H1 A3 _7 \8 P8 o4 L  p, `    Creating journal (8192 blocks): done5 o/ U, [0 B5 x( ^2 S
    Writing superblocks and filesystem accounting information: done
9 f7 ^. V5 ?( E3 z    This filesystem will be automatically checked every 30 mounts or
7 R  X# P; I7 |) K9 I3 ?6 O    180 days, whichever comes first.  Use tune2fs -c or -i to override.  ]! h- V! @  N: M5 G* Z
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点, O; @! f) ]' V2 S; D
    /dev/sda3              3723848    705992   2828692  20% /( z/ S9 ^* d& H9 ]6 n+ n. ?
    /dev/sda1               101089      9274     86596  10% /boot
; i5 ]; |. I8 J, }9 Y( W    none                     14520         0     14520   0% /dev/shm
( H/ v0 N/ v: s( u3 I    //挂上新分区
& S: ~% r5 v% t+ x" V- w- R
  1. mount /dev/hda1 /home
    0 k, G, y3 G6 J. o* H- Z( B
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点+ ^" H$ R1 Y9 c6 }1 U
    /dev/sda3              3723848    705992   2828692  20% /
4 N! f/ D8 g& s) I8 t: z( e    /dev/sda1               101089      9274     86596  10% /boot) T! n& X4 e  {7 s4 o
    none                     14520         0     14520   0% /dev/shm' u( q, i# I  N
    /dev/hda1               488006      8239    454569   2% /home1 p: _7 C: E1 R$ t; o) k

( J! `) V" z3 p3 _0 q+ A自动挂载:4 A  w8 k* i: _$ b- m
  1.           vi /etc/fstab
    ) l2 n) c, p. ]4 N
  2.   @1 E* A9 U" n# k) ~+ \, ~; H
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    - F, ^$ ]: v! |4 o

  4.   C" [- m* D6 u! Z$ p% Y; F
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
; y, d+ ?: V4 s, m: A
  1.           mount /dev/sdb5 /mnt/ljp1" j3 E  q' w( s) ]8 y2 W
  2.   v( o& @& L) W3 n
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

/ N! K- T# Y6 ]- F6 y
% g# q+ J7 v( I; a2 d# U+ w0 l5 w
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-24 16:57 , Processed in 0.030208 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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