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

 找回密码
 立即注册
查看: 2829|回复: 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)1 T: `* j6 `* I! m4 z
      or: fdisk /dev/sdc  (for the third SCSI disk)7 ?: t9 F5 \! I, H
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
0 B) b$ w5 m( s! L5 T7 r      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)$ \! {3 u& Q5 g" }9 `4 F/ y: \: w
      ...& G$ u+ z: ]) F4 Y# |4 H  }, Z
  1. df -k  M3 y- o2 P0 q! f
  2. df -lh
    & m1 ~+ m3 N7 R# F
  3. 查看有几块硬盘:fdisk -l
    0 k+ H7 Y& |% P0 Y* C! L
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点/ R0 e/ a$ e3 X5 V( k/ u: r  R
    /dev/sda3              3723848    705968   2828716  20% /- a# e# c. g5 c) V0 }* }! ?9 J8 s
    /dev/sda1               101089      9274     86596  10% /boot
9 Q  V; m5 ]  [    none                     14520         0     14520   0% /dev/shm( V+ U4 g, j: |# S7 ?, a
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
+ R: O" p! v# {$ X& q4 P
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
- v' s/ s/ T2 j: h    Building a new DOS disklabel. Changes will remain in memory only,
' q' f* p- |& |* {7 S' l    until you decide to write them. After that, of course, the previous
$ h+ ~8 o1 T) z: o8 {8 A    content won't be recoverable.6 u, l. p+ R5 M1 X1 i
    The number of cylinders for this disk is set to 8322.$ f2 L. f$ m4 b( b# e
    There is nothing wrong with that, but this is larger than 1024,
+ Y! ]4 G) ?  L9 s/ C1 e    and could in certain setups cause problems with:
9 n* j# ^  N- U& b    1) software that runs at boot time (e.g., old versions of LILO)
' {3 M$ |5 J2 r' |    2) booting and partitioning software from other OSs
7 B1 s/ T3 k/ d* w& M       (e.g., DOS FDISK, OS/2 FDISK)- ]4 Q! s  `/ L) `5 F1 P' y
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)! V* H8 J' ^8 t/ q4 E0 b4 T! P+ ]1 m
    Command (m for help): p
* e& T) d5 g8 ~3 c    Disk /dev/hda: 4294 MB, 4294967296 bytes
5 E$ y" v* ]  Y; p    16 heads, 63 sectors/track, 8322 cylinders
, |- H: z/ B* n    Units = cylinders of 1008 * 512 = 516096 bytes
: s1 `1 j" H0 w+ C5 p       Device Boot    Start       End    Blocks   Id  System/ Y: V! E) g2 F" d7 n+ N7 k/ \9 |, S
    Command (m for help): m
+ ], x' z8 S$ }5 d$ ~    Command action
6 O8 u% R1 d+ C, S, J       a   toggle a bootable flag
/ U2 y4 {! |* n. v, h! r0 L       b   edit bsd disklabel
: S1 b0 D! X. j/ U# ~! x       c   toggle the dos compatibility flag, S/ L% ~) e5 {
       d   delete a partition  C: @1 A% {+ c+ [5 C
       l   list known partition types$ h. }( r. P4 G9 X# W/ w, i1 Z* }
       m   print this menu
: j; q- h: t; l8 L6 {' M       n   add a new partition
2 t9 Y# t0 `1 }  p; Y4 Z       o   create a new empty DOS partition table: J3 D# s1 J: _$ Y/ A1 T. e
       p   print the partition table% L, V' B, b9 _- X* V
       q   quit without saving changes! x  V1 j9 [# q. M2 U, D( p
       s   create a new empty Sun disklabel
* |; P7 m! `" S$ k" K6 h; ~       t   change a partition's system id
( o& P) b/ p5 U; Q6 R; M& W       u   change display/entry units" t: }) L' s1 d* w& ^
       v   verify the partition table4 X. A6 T- J* K2 E9 `+ x: D
       w   write table to disk and exit
( t6 [9 E1 }) @+ u* N) e8 p       x   extra functionality (experts only)
' D/ V6 l0 `3 V, `1 ^    Command (m for help): n
' T  t, L/ y$ Y  {! }0 l    Command action
" k0 n$ k2 h8 X( G$ P       e   extended, t( r: r2 X- |0 H  h4 o
       p   primary partition (1-4)9 [! d0 o( M* i  N5 c
    p, w$ g5 O0 _8 N1 {
    Partition number (1-4): 1
# I9 l  r6 P" d! o; j    First cylinder (1-8322, default 1): ' S9 v) G" F) E( V
    Using default value 1
  b% e8 r" P  r$ o* }8 G. U    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G9 h0 p- G; L) u* c, _7 E3 K- b
    Command (m for help): p
# o6 q/ O, F7 c    Disk /dev/hda: 4294 MB, 4294967296 bytes. }& k8 a! |( ~  \; R, q
    16 heads, 63 sectors/track, 8322 cylinders- A, p, U9 ~' b9 _) H7 H& d
    Units = cylinders of 1008 * 512 = 516096 bytes
. {  k& }( f9 I. M       Device Boot    Start       End    Blocks   Id  System6 B3 }1 y$ Y: U9 v* ~* N+ z
    /dev/hda1             1      1000    503968+  83  Linux
- ~$ U2 c: y- R, K    Command (m for help): w
# ?! f3 D+ |( y1 q    The partition table has been altered!1 C* U. n/ j# f1 M8 m/ h  p; u
    Calling ioctl() to re-read partition table.0 _. V" `) b. g) b2 j  }2 p' R+ D
    Syncing disks.- d2 T% A0 G, ^4 }% Y& P
    //格式化新分区: r8 m% g9 K' p4 {
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)5 G% D8 N1 v+ N+ K# v! C
    Filesystem label=# n* L7 u! K  e9 V( x0 Z) z" X
    OS type: Linux: r+ e0 p4 Q1 R. ~/ Y+ V8 l& a
    Block size=1024 (log=0)# }0 _2 y$ A+ a. g
    Fragment size=1024 (log=0); ?8 g, P8 ~5 o8 e: f
    126480 inodes, 503968 blocks( o; U5 v: @5 ?) x, z
    25198 blocks (5.00%) reserved for the super user
8 _- c- Z/ \) k    First data block=19 ^: l( r* |$ R  t0 ]' V9 X
    62 block groups
, [. q; J, n! i( D2 w6 N6 d3 o0 c2 i    8192 blocks per group, 8192 fragments per group
5 x  ?5 W3 O3 O0 y8 v: t, Z    2040 inodes per group
8 k9 u( V) Q/ `$ l' H) j5 f/ S    Superblock backups stored on blocks: - L* u9 a4 }( o4 S5 E3 M
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409: T  G2 c8 m. Z
    Writing inode tables: done                              O1 p( e8 ]( e* m) S8 v
    Creating journal (8192 blocks): done7 U3 |, E$ ^2 Y( U( N( |3 H. M
    Writing superblocks and filesystem accounting information: done
; }: T4 I3 m  [# j  y0 Z5 ^& a) R2 C    This filesystem will be automatically checked every 30 mounts or+ `9 _* N9 u0 J) p+ d* s
    180 days, whichever comes first.  Use tune2fs -c or -i to override.- Y; r5 Z* S0 F& I- O/ z& \- T( L! {
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
% r, t# I# n8 ]! s    /dev/sda3              3723848    705992   2828692  20% /- |. k2 e6 ^7 |7 u2 ]7 |" p
    /dev/sda1               101089      9274     86596  10% /boot* K  @3 j( s7 @
    none                     14520         0     14520   0% /dev/shm
8 x, J7 ]  k' x  p- G    //挂上新分区
) @! }! t# U4 r0 q3 m0 p
  1. mount /dev/hda1 /home2 Q; I, [! h* K9 D
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点4 a4 V/ q1 {) F+ ]9 N
    /dev/sda3              3723848    705992   2828692  20% /
3 U; M! Z2 t; i% v9 @1 S    /dev/sda1               101089      9274     86596  10% /boot# p% b8 m' t+ j4 d. O' J/ [- }
    none                     14520         0     14520   0% /dev/shm
5 B0 Y" `/ \  a% P6 B: A    /dev/hda1               488006      8239    454569   2% /home6 o3 |5 x, k7 K" o
3 ^: \5 P8 d5 A
自动挂载:
- v3 |' O" b) Y6 |7 `/ V9 E
  1.           vi /etc/fstab
    * x: }+ B6 a$ t, h9 n

  2. 0 w  j! N, s, v
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0: d6 K$ ?, u% P1 z- t( U

  4. 4 L4 t& I1 b( U
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:! s  o- t. M7 M# n; S/ d# A
  1.           mount /dev/sdb5 /mnt/ljp1
    / e3 @+ T6 l9 f' l
  2. % |: j* u* k8 `, z: x
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

5 E. X" G( K  v: R% P1 {' H9 q& U1 ~3 p

% e# T8 _' W% a6 d$ e7 c4 |" y
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-22 06:54 , Processed in 0.016880 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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