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

 找回密码
 立即注册
查看: 2709|回复: 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)* N1 r- Z: e% q
      or: fdisk /dev/sdc  (for the third SCSI disk)
: Y0 @+ I+ M2 }! S" N, }  I      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
# {$ W" U1 |, ?- X      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)8 D3 n9 T! s% m' b) p1 d
      ...! T, `- w% ~3 ?. \5 a
  1. df -k* _' e9 L. N( A  _% L
  2. df -lh# @( g/ g, C$ S% k5 k
  3. 查看有几块硬盘:fdisk -l
    - b( M. {" ~9 L' Z7 R
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点/ T  q- [% q8 J; `7 ~7 a
    /dev/sda3              3723848    705968   2828716  20% /
. @9 V0 X/ i$ q* [    /dev/sda1               101089      9274     86596  10% /boot
2 c& B, y5 Y- i7 m9 q2 x; k    none                     14520         0     14520   0% /dev/shm# T% e2 D7 I5 V4 z! Y& X
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
8 n/ V4 O+ \' ]! d5 A
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
) J! _% P4 j0 p& W5 J* Q    Building a new DOS disklabel. Changes will remain in memory only,
& k4 B* f& I! o0 t( q6 O% z' R1 t    until you decide to write them. After that, of course, the previous4 ~. X# A' ~0 p. b+ y& `7 n0 y) ]
    content won't be recoverable.
2 e0 e- |3 c. n+ x0 b7 P    The number of cylinders for this disk is set to 8322.
9 H& M1 i4 j3 L    There is nothing wrong with that, but this is larger than 1024,. O6 W! C, X4 _0 l3 M
    and could in certain setups cause problems with:
) U' G+ @4 |; u, Z5 M. I    1) software that runs at boot time (e.g., old versions of LILO)
, S5 d+ Z* ?* r4 b    2) booting and partitioning software from other OSs& w- N. Y; n& H) `* |, {% T4 a# d
       (e.g., DOS FDISK, OS/2 FDISK)
! V' P5 ]) v$ t( m2 ?    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)# v6 O) Q9 w0 e5 m. D( U
    Command (m for help): p
# j- F, L0 J% {+ z1 y% P    Disk /dev/hda: 4294 MB, 4294967296 bytes
& |7 t, i6 X. n+ o1 h    16 heads, 63 sectors/track, 8322 cylinders
' M0 B" Q( ?6 k' q    Units = cylinders of 1008 * 512 = 516096 bytes
: N) Q2 ^- e: V       Device Boot    Start       End    Blocks   Id  System
) W9 n2 s' k# {  v0 M7 ]    Command (m for help): m
2 v/ C% p( A/ q0 ?3 _  K    Command action6 F  L# q; e7 |4 z. o6 v
       a   toggle a bootable flag
! l( z& I$ S/ v4 V$ @, e       b   edit bsd disklabel& v0 s* Y, L) W/ S& Y* }
       c   toggle the dos compatibility flag9 \  Z( P* W* }( y! R
       d   delete a partition! N/ ~$ `; A1 f# k8 ?" T
       l   list known partition types
$ ]4 ?. |) ?/ |' k7 T       m   print this menu
2 u* X% s8 F! B- J       n   add a new partition
& i2 z0 A# X4 H5 r       o   create a new empty DOS partition table
8 h+ y# o1 x5 X+ X       p   print the partition table
1 [" F4 y; B/ M, S       q   quit without saving changes
/ p9 G/ O4 q; C3 s       s   create a new empty Sun disklabel' a/ E- L  ~& q1 b# I& i* \5 j
       t   change a partition's system id) t6 g! r3 K1 K/ k  N* K2 h
       u   change display/entry units
# d3 C$ S- N  n  H8 p       v   verify the partition table
6 i7 i; h* U6 @# E3 Z       w   write table to disk and exit
/ Z7 p$ y6 v4 l+ o       x   extra functionality (experts only)
- g" b! U1 y7 F; \    Command (m for help): n) V& k7 k. D& q9 P
    Command action
' t5 e* s! N+ J- D       e   extended  \1 p7 }! N0 c' W8 a3 ?
       p   primary partition (1-4)+ V% V/ ?8 L. g$ }# n5 U
    p& T: n, |# G& F6 ^4 n0 O
    Partition number (1-4): 1
8 ]0 H( k* U9 ~4 u( |    First cylinder (1-8322, default 1):
* {. e+ ]  r. M    Using default value 1' v; ]. S' y! t6 n' V$ F& k) v& I
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G, U8 W: e# j/ }- A8 U
    Command (m for help): p' v; Y9 X7 p; H8 M
    Disk /dev/hda: 4294 MB, 4294967296 bytes, P4 Z! s7 e8 {- n% |
    16 heads, 63 sectors/track, 8322 cylinders" n: V1 U/ k5 ?5 H" C  {# B
    Units = cylinders of 1008 * 512 = 516096 bytes+ |  j1 e. s0 c5 R
       Device Boot    Start       End    Blocks   Id  System
5 {7 J  ~$ |! i: s: O    /dev/hda1             1      1000    503968+  83  Linux( k, j4 g0 l5 S. w- e  ^. _% A$ a, X
    Command (m for help): w- _! D( P7 \0 G! k: m
    The partition table has been altered!
6 Y2 D5 }5 Z) E1 I    Calling ioctl() to re-read partition table.8 v: V: q4 b2 t
    Syncing disks.9 l/ o( o. P: U" i. r
    //格式化新分区
7 I7 P$ [8 |1 w
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
1 M9 T( f$ R. |& }. a, ~6 D$ @; O    Filesystem label=& D6 v; m* y% J% Y- y9 i5 i$ G7 I
    OS type: Linux: n$ ~2 b& d# B* N" k; ?
    Block size=1024 (log=0)
6 u$ m; I* P5 p, I    Fragment size=1024 (log=0)
/ @4 c+ z; e' j, m" t" F    126480 inodes, 503968 blocks
% O- Z$ t/ @* i9 g2 E  G' O6 m    25198 blocks (5.00%) reserved for the super user6 U2 E" F7 l& M& P
    First data block=1
7 C' Q9 @) b: s  u, i0 o1 o    62 block groups4 ?0 r4 o5 H- c  Y/ B& u6 C+ ]% f# Y
    8192 blocks per group, 8192 fragments per group
6 |4 d$ E, @! t( C+ @2 z+ z    2040 inodes per group
' y1 p+ `9 ~* z# J0 }  L    Superblock backups stored on blocks:
8 q+ r" O  f: Q2 F' w2 C            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
+ Y# t1 l1 W' s! E$ |. p    Writing inode tables: done                            ) T5 l# ^5 j; U3 X4 O4 h# }
    Creating journal (8192 blocks): done4 I% |! S6 L1 _2 \: N: |" C
    Writing superblocks and filesystem accounting information: done
9 h+ N* @" ]% I# e! l2 g0 {    This filesystem will be automatically checked every 30 mounts or
* ^5 {; b- i9 F; D    180 days, whichever comes first.  Use tune2fs -c or -i to override.' b) h$ A4 W+ e% ^# F& J2 n% R2 O  h
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点/ P& ?  W9 N1 p: U, m0 v  m5 p5 J
    /dev/sda3              3723848    705992   2828692  20% /1 M" l3 w! x) ^: w( f/ g
    /dev/sda1               101089      9274     86596  10% /boot6 ~1 s' R9 E  l
    none                     14520         0     14520   0% /dev/shm
/ G7 u, i% J- q$ f- }1 h1 a    //挂上新分区9 ], w* k2 u7 K! }
  1. mount /dev/hda1 /home1 c" ^. O4 ]+ b
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
6 V* N) f4 K" j8 J: D3 Y    /dev/sda3              3723848    705992   2828692  20% /
4 ^+ Q* o6 U. q    /dev/sda1               101089      9274     86596  10% /boot7 w$ n) [% ?- \$ b6 @8 }
    none                     14520         0     14520   0% /dev/shm4 d) j8 r+ |* z3 Q
    /dev/hda1               488006      8239    454569   2% /home" H$ W) u. o9 _* h9 S

, i0 v8 k* b* a! y8 Z自动挂载:
+ }' @. N; w* h# p
  1.           vi /etc/fstab0 F( B) B) C7 \* H' B

  2. 0 n! _+ O* i6 q4 Q' M5 L8 F- z. V
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0+ u4 y: L# @1 k! {1 J

  4. # \: t9 r1 `2 e& G- k7 [$ l
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:1 v' e7 y1 m9 V. ~) e$ ~
  1.           mount /dev/sdb5 /mnt/ljp1
      y! ~" E2 ]" n8 @% b, ^+ M
  2. ; a% p! @# t$ P2 X
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

# ?6 p; M/ P, @6 n* f' N! s" R/ O1 }4 g* G7 _! e

# D" _2 @; `! ]: B% n- L
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-25 09:30 , Processed in 0.008768 second(s), 6 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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