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

 找回密码
 立即注册
查看: 2125|回复: 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): m1 e4 v1 M  j1 b: b9 t
      or: fdisk /dev/sdc  (for the third SCSI disk)
* f& t9 o3 X$ _# h- ~' z( t; Z! {      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)2 }9 J' t; S4 a6 n0 w! G3 L& b
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
6 ~/ P' l  m4 b7 @8 P! J4 Q% ^/ c! p      ...% s, |2 X, e5 \0 a
  1. df -k
    : V) N; |5 R( t) I8 r0 f
  2. df -lh
      \3 l9 G9 o" W7 _0 L" N
  3. 查看有几块硬盘:fdisk -l
    & E+ q% [& W! S$ j8 i- ]
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
. d  E7 j9 t" _4 l; B7 \/ Q: R    /dev/sda3              3723848    705968   2828716  20% /6 f# z: v/ _/ c5 l
    /dev/sda1               101089      9274     86596  10% /boot0 H6 f0 V/ p# h: _3 n
    none                     14520         0     14520   0% /dev/shm- s. K9 e, l- U& L2 x! G2 {
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用4 I) ]& N# H% e( J# _# J) @
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
. r6 c  O0 c6 s& u# {    Building a new DOS disklabel. Changes will remain in memory only,
; u0 N  |( }- d4 ~+ m    until you decide to write them. After that, of course, the previous
/ y6 v: f4 a! F" e* `8 ?    content won't be recoverable.4 L3 [& h2 A  N+ K+ ?
    The number of cylinders for this disk is set to 8322.
  {  [, ], ^/ r" W+ Z0 S% n$ f3 e- M7 \    There is nothing wrong with that, but this is larger than 1024,/ q0 P, O* U- D, q7 j4 O
    and could in certain setups cause problems with:- Z) u/ Q  [$ P6 u% E/ H( t. t2 J
    1) software that runs at boot time (e.g., old versions of LILO)' U  G1 V: k1 h
    2) booting and partitioning software from other OSs
' x, m* ^5 z/ `" I8 ]7 Z       (e.g., DOS FDISK, OS/2 FDISK)
3 `4 y0 g( ?# Z+ V) Y7 L" y    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
0 e% c/ B* h+ r5 e, \" g1 @! D0 ^    Command (m for help): p# |# a2 |+ ~4 ~' S1 v: _  T9 N
    Disk /dev/hda: 4294 MB, 4294967296 bytes1 ^; I6 i; Y5 Y, j5 w# w# c8 F% Z- Q
    16 heads, 63 sectors/track, 8322 cylinders& x+ j6 x9 b6 h9 P& M$ _6 E! o' R
    Units = cylinders of 1008 * 512 = 516096 bytes9 m+ J( ?& l8 |# Q! Z% W4 P
       Device Boot    Start       End    Blocks   Id  System" S& s5 o5 Q" l- ]7 p% l# P/ P3 S
    Command (m for help): m7 N8 ?* E$ \$ ?' P! E# [) P
    Command action
# w0 r: W, W8 J; p       a   toggle a bootable flag' m: Q; e2 ?, _% V0 Y: f7 f
       b   edit bsd disklabel. c* }. B9 w1 @4 b$ o
       c   toggle the dos compatibility flag
( Q3 N) i6 R; }       d   delete a partition
0 N1 S6 {* ?4 ]6 x. y       l   list known partition types
  w8 {, p- l# T/ t$ `3 E, u       m   print this menu( U& h2 G! W  B, x
       n   add a new partition$ E8 C. v0 I7 ?4 ?2 Z9 O( B+ a1 I
       o   create a new empty DOS partition table9 \* q/ @2 g+ {# L* A3 f4 x- m' Z
       p   print the partition table" p; H! ^# k' V  u8 L2 r
       q   quit without saving changes. L9 f3 y4 Y: O: _/ j
       s   create a new empty Sun disklabel: P8 N- s  v4 ^! T' n
       t   change a partition's system id# @5 y- g: r  S! o7 \/ L- e
       u   change display/entry units
4 ?! g' X# {: b( J       v   verify the partition table0 o% f) k# ?$ `4 Z  \: _
       w   write table to disk and exit
# s* c2 D1 g% P5 {       x   extra functionality (experts only)
0 ]) Q; r/ [) C) x    Command (m for help): n
) N1 c$ f" ^* Z    Command action
" i- o: e* A4 ^2 ~5 v1 ~$ J       e   extended
+ Z0 O4 m" @) S# T  R9 r4 v       p   primary partition (1-4)
9 X' r, M; Y# j5 R$ P! ]9 z2 z    p0 d- e7 Q; M5 m6 J$ E' v
    Partition number (1-4): 1) r/ G% p/ ~1 o6 ?8 y
    First cylinder (1-8322, default 1): ( h# P6 \" Z$ L# j
    Using default value 1  q' z8 C  _) ~# u* a
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G/ F& c$ C3 Q- A* L- R
    Command (m for help): p$ Z9 n8 F& R; p& a' z8 f
    Disk /dev/hda: 4294 MB, 4294967296 bytes
: W. D# P. H: W" o    16 heads, 63 sectors/track, 8322 cylinders
+ D- k3 x3 K, m( B' k( i, |* \/ T    Units = cylinders of 1008 * 512 = 516096 bytes
3 d7 \. ^7 z* [4 t, r5 P" u       Device Boot    Start       End    Blocks   Id  System0 K/ G. a$ ]: m: o7 \
    /dev/hda1             1      1000    503968+  83  Linux
. C0 |% |' m; o    Command (m for help): w
3 Y* I$ ]% N6 H    The partition table has been altered!5 y5 N6 ?. H2 o7 t! @
    Calling ioctl() to re-read partition table.
) m' Q( u" s- O$ b" P    Syncing disks.; g* }! a4 ]+ i0 i( K4 Y
    //格式化新分区
; R1 p5 C. C% B4 M; p% O# q2 F+ i
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)3 k2 t* z$ j* @+ F# ~. e
    Filesystem label=+ d0 c! }  Q1 {" J3 {
    OS type: Linux
- b: m( g% z. A    Block size=1024 (log=0)6 x) ?/ r. N+ U: j  I& H
    Fragment size=1024 (log=0)* p6 D* J* T0 J; X6 T
    126480 inodes, 503968 blocks( R3 F8 n" e1 i' R( b
    25198 blocks (5.00%) reserved for the super user
) ]8 O3 |: r8 k; t, s% Y# \2 q1 n/ J    First data block=1. F3 f, F' [  a4 q0 G
    62 block groups; `% y, J% p6 A
    8192 blocks per group, 8192 fragments per group5 l2 r9 V4 X0 d0 q( s& i; m
    2040 inodes per group, L6 X  Q, |$ d( E1 p3 P6 j
    Superblock backups stored on blocks: 5 h: A) u8 t' v3 V+ z/ H
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014097 P7 ]$ m3 b- M8 i/ k5 e
    Writing inode tables: done                            % t' t* X. \( N7 m# f
    Creating journal (8192 blocks): done
2 b: i7 o& ~1 H: a" h' J    Writing superblocks and filesystem accounting information: done
% u, Z4 S9 G2 g    This filesystem will be automatically checked every 30 mounts or
( y6 u; y3 B. K* _    180 days, whichever comes first.  Use tune2fs -c or -i to override.( U- [3 G  U  X' b. u
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
! Y7 }( T0 i% Y1 b    /dev/sda3              3723848    705992   2828692  20% /: I5 t; h7 O. M& i# D
    /dev/sda1               101089      9274     86596  10% /boot8 Y. h( w. T' I: E$ e6 o
    none                     14520         0     14520   0% /dev/shm4 z. ]5 A( a. \9 H: w
    //挂上新分区8 ]" f4 A1 [, r$ S) V0 Q
  1. mount /dev/hda1 /home" {: q8 b5 a" \$ q
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
' @* h. f8 O/ D, O- s    /dev/sda3              3723848    705992   2828692  20% /* {: ~" n1 ]' d% ?* z6 ?
    /dev/sda1               101089      9274     86596  10% /boot" Y. n/ M/ q; _) n1 t) V
    none                     14520         0     14520   0% /dev/shm
. E( j  o% n! _2 g. q, a    /dev/hda1               488006      8239    454569   2% /home* R- L$ v5 }" e: f/ _  n
5 p: U7 P: t+ e3 d1 s) F
自动挂载:
0 u: G; `# R9 @) v, v
  1.           vi /etc/fstab
    3 R( s( a4 h5 h% t

  2. . w2 E& F7 L5 y; o# n' f
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    : m* u9 a! G- J- v; Z
  4. + n+ s: {3 d8 \
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
6 R$ d* ~  Q+ `; x. l; N
  1.           mount /dev/sdb5 /mnt/ljp1
    6 V5 n7 K+ p+ D; Z

  2. * C% R2 K& f# O) {" \7 w
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

' S4 D8 t( m' j( N" `8 {
) s0 c& U  X" i, O  `$ Z( {# D1 Z3 D
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-4-3 09:34 , Processed in 0.029040 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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