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

 找回密码
 立即注册
查看: 2748|回复: 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)
& X* c- e* S0 O7 A0 a      or: fdisk /dev/sdc  (for the third SCSI disk)
! Q: y' f0 v3 F1 V4 ?4 u      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)" ]  X9 |3 ?, A* s
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)8 ^! V$ s( B- L' u0 a( X. S, M
      ...
0 a- a( ^" t9 H- n  e, j, e, Y
  1. df -k  m8 s- r3 `% l) u' I
  2. df -lh
    ; M  S1 ^( e% D. [. _" r
  3. 查看有几块硬盘:fdisk -l+ ^6 G. ]1 n4 x. ^1 P
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
, W6 J3 v# D# D3 E  [1 n) T( C    /dev/sda3              3723848    705968   2828716  20% /7 ?3 u4 S0 C4 ]; n9 u$ V) t
    /dev/sda1               101089      9274     86596  10% /boot
% ^8 d! n. N) b9 X9 U" q    none                     14520         0     14520   0% /dev/shm
2 Q& E. w- J3 S! M( ?$ E* u" U    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用7 _' \2 A2 X& Z4 I
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
# I% B" [" q- C) q! D    Building a new DOS disklabel. Changes will remain in memory only,
. ]% c& V: p; T/ l; |7 ?: G$ H    until you decide to write them. After that, of course, the previous
# q# B: L9 }( B- `/ M    content won't be recoverable.. {7 c! w! u: ^  K' l: o0 y; Y7 N
    The number of cylinders for this disk is set to 8322.
# A" s. b% S, ^    There is nothing wrong with that, but this is larger than 1024," B3 J1 K  C: k8 s  y  j( A
    and could in certain setups cause problems with:
  m0 t+ o- J- d    1) software that runs at boot time (e.g., old versions of LILO)8 A$ z2 {& y6 G6 d
    2) booting and partitioning software from other OSs
3 ^* S, H, W+ v- w( {3 L* q       (e.g., DOS FDISK, OS/2 FDISK)4 _6 J% k0 Z" I' m
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
, s& e3 t- c+ m- F1 ^" P; H    Command (m for help): p
& }" f6 ~9 m6 y& s  I1 ]    Disk /dev/hda: 4294 MB, 4294967296 bytes+ U# Q+ S9 d+ Z+ i
    16 heads, 63 sectors/track, 8322 cylinders
" Z$ O, m/ R5 L3 \' W1 W    Units = cylinders of 1008 * 512 = 516096 bytes  K3 t6 l' q# b: k
       Device Boot    Start       End    Blocks   Id  System3 g9 C+ V5 Z7 n3 C% s! w
    Command (m for help): m
* a8 j5 L  T: f    Command action' G( G8 g/ g( b& _/ ?) T0 {/ c; P
       a   toggle a bootable flag# L; Z0 d: ^9 _7 S0 q* m9 U$ i: i
       b   edit bsd disklabel
) k- _, @5 A3 A3 k       c   toggle the dos compatibility flag
* E( i, I- S: Z) `6 ?: L       d   delete a partition. T9 P/ U/ D" [
       l   list known partition types
0 c$ P+ X& Y' o" t/ W" T7 v) z+ O/ k       m   print this menu6 u9 r: X5 L) p$ E, k
       n   add a new partition& Z9 ?& G0 _; u" y2 I0 b8 i- H
       o   create a new empty DOS partition table* d; Y; P! t0 F7 F8 u
       p   print the partition table
  D5 Z1 e$ h3 S1 \) p       q   quit without saving changes
! H# w. ~# }) E       s   create a new empty Sun disklabel+ ^8 d  P0 I6 g' t
       t   change a partition's system id; Y$ A) X; I8 r/ ~' T5 \( O
       u   change display/entry units
" U+ z# d. p9 {       v   verify the partition table/ {3 g$ j, |* y: Q, `3 y7 T
       w   write table to disk and exit
+ P8 N! P( \' z2 J! Q       x   extra functionality (experts only)& u) z3 Q7 a& @' q3 S
    Command (m for help): n; N3 t. n* Q5 d! D+ ^* M' ]
    Command action# G# k$ p  L1 @$ ~
       e   extended6 W/ P0 \/ a2 k6 ?+ S
       p   primary partition (1-4)9 q1 u8 ?0 t0 z/ d* m; }0 ]
    p
  y" ]7 ]* t1 R. y    Partition number (1-4): 1: H( Q! i  e  B3 T0 b7 l
    First cylinder (1-8322, default 1):
$ h  y: {! V! H8 [  i" y/ A2 y" ~    Using default value 1
$ S* `- b& v3 w$ J& _, {    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G2 Z5 j2 }% Q- X
    Command (m for help): p# l) F% B* F, A& x
    Disk /dev/hda: 4294 MB, 4294967296 bytes
3 @+ `: p$ C8 t) s5 D    16 heads, 63 sectors/track, 8322 cylinders
% o7 P/ G0 ~4 ]& |/ u0 V2 D    Units = cylinders of 1008 * 512 = 516096 bytes4 _  b, F0 }* m: e
       Device Boot    Start       End    Blocks   Id  System; ^7 Q* c, b, I* R; ?/ I
    /dev/hda1             1      1000    503968+  83  Linux) ?0 Y; b8 `6 m( r8 D
    Command (m for help): w, {% }  E8 n* G% q+ M
    The partition table has been altered!2 d8 A0 F# _3 I$ M! l9 H7 n6 _) U
    Calling ioctl() to re-read partition table.
* _& \% {& |, {2 G7 K/ p    Syncing disks.
* {3 F: S- K; e( W' ?    //格式化新分区
$ y1 K$ r; E7 _' i; T! o& m- q
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
/ l2 m/ E5 Q9 ~7 f  c    Filesystem label=
2 z6 S& i% i- w5 }% x# u( W3 B    OS type: Linux
; g+ d4 l- T) y3 o$ S! T    Block size=1024 (log=0)0 y' r. z: k- \3 L. t3 F
    Fragment size=1024 (log=0)# L. B! [1 v) `+ D( P: c' ^+ Y- ?: b
    126480 inodes, 503968 blocks6 C1 m9 ~  J7 _- P( U
    25198 blocks (5.00%) reserved for the super user; I/ W- ?8 I. u( X
    First data block=1
8 d9 M& e5 K  T* W    62 block groups
3 k) @$ z! ^: l, q3 k$ j    8192 blocks per group, 8192 fragments per group
6 N8 g8 w0 e4 [0 U/ X( H$ K! K    2040 inodes per group' D0 y: f4 h: X( x
    Superblock backups stored on blocks:
* E# W6 S0 X5 Y. h8 u            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409; C" s2 a1 p* |
    Writing inode tables: done                            ' H. }6 l, c9 `" O! W
    Creating journal (8192 blocks): done% g1 \, c3 V7 K2 F0 y9 {8 w
    Writing superblocks and filesystem accounting information: done7 U) v/ H; k8 ?8 i8 A  w
    This filesystem will be automatically checked every 30 mounts or
, Z! n* ~' Z; y+ w( n    180 days, whichever comes first.  Use tune2fs -c or -i to override.- S& Q  U8 ?( U' p
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
, N* w/ e  z6 w! h, L" Z    /dev/sda3              3723848    705992   2828692  20% /
4 y( Z: C8 o' i0 c- ]    /dev/sda1               101089      9274     86596  10% /boot
8 _0 `8 {. X) F& q8 L    none                     14520         0     14520   0% /dev/shm3 h# G2 K& ]! f2 o: G
    //挂上新分区) T5 D; G: K2 U
  1. mount /dev/hda1 /home/ k- F8 o$ y! G+ i; e6 I  |
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
9 i" m* v7 b8 h# y6 h' l    /dev/sda3              3723848    705992   2828692  20% /0 r+ G# \( {. C/ W8 }- L
    /dev/sda1               101089      9274     86596  10% /boot
% l9 G( s+ B& z4 G8 h0 z9 D    none                     14520         0     14520   0% /dev/shm7 k4 |' B* |# Z. Y& O0 v; B
    /dev/hda1               488006      8239    454569   2% /home
* j$ G6 p' Q3 l# U6 X7 N& b1 e
1 v# B( O# X. C' V5 N* _% N. k" O自动挂载:
4 I4 }/ T' g$ S# _' j1 b; _4 H6 @
  1.           vi /etc/fstab
    + c' b6 N; [- @

  2. " M7 A& M8 o* `( ?( o; d  G) J6 T
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 05 g- ^0 i, x) I

  4. 4 E' a- u, i3 b. V
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
2 B5 m# _  s2 E( \& O
  1.           mount /dev/sdb5 /mnt/ljp1
    , @, ?- R' T8 J
  2. 7 v& v9 _. w3 a+ F8 a
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

' v0 a/ |: h6 k( M$ A; R
4 V9 Z9 y; b; i) v. c8 A: H) ?
9 l9 ~! v, e" I) R' ]/ R1 Q, t8 g9 n! Q
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-8 03:00 , Processed in 0.025846 second(s), 24 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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