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

 找回密码
 立即注册
查看: 2826|回复: 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)7 w! l$ x3 p  T- `  J6 N. F* N
      or: fdisk /dev/sdc  (for the third SCSI disk)
" V) c# j* |0 p. X' G      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
- X* u# k3 L2 ]) O- l- l5 Y8 s8 Y! a      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)! D! w. [6 u+ t: c6 v1 ^
      ...$ A& P! x. d) c! W% A- p" x
  1. df -k* Q: S4 q4 h( `5 s  d& B0 M
  2. df -lh2 M7 F  }4 @* H1 ?1 V: `+ z
  3. 查看有几块硬盘:fdisk -l
    : {3 n$ b0 s& z9 s$ q
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点2 W- W( P4 k& E8 ?; S+ x( T
    /dev/sda3              3723848    705968   2828716  20% /" v& t! O! X6 p0 g3 V( b$ u
    /dev/sda1               101089      9274     86596  10% /boot
' ^* a* A" r$ C    none                     14520         0     14520   0% /dev/shm
  a: a3 |3 ~! S( [, I, l) ~  Q$ W    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
! e- z: H/ x) C1 b
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel# l  {0 N9 O! Q2 D( m4 w% z' t
    Building a new DOS disklabel. Changes will remain in memory only,
6 K6 x. ^" t( y2 u! p    until you decide to write them. After that, of course, the previous
3 O* m' l9 p5 }! |! g9 u    content won't be recoverable.
  S6 W$ @% G8 L; m    The number of cylinders for this disk is set to 8322.
8 f! T+ z9 u0 {* O2 I% G    There is nothing wrong with that, but this is larger than 1024,
% z# h: n8 I1 l2 r, W/ _9 [    and could in certain setups cause problems with:
* G! ~; D7 x* {; ~5 g    1) software that runs at boot time (e.g., old versions of LILO)
! ~. G! F0 J* N# p7 i% o0 Z+ f    2) booting and partitioning software from other OSs) v8 N$ k& ?% `% i; E3 i9 e
       (e.g., DOS FDISK, OS/2 FDISK)/ O1 w: r3 b$ m
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)8 o# m7 J( m  U. U" z
    Command (m for help): p/ t9 r& e9 V. l  H2 q
    Disk /dev/hda: 4294 MB, 4294967296 bytes. D( `. q- T2 e1 U  c4 l2 Y
    16 heads, 63 sectors/track, 8322 cylinders
3 E. L1 ^6 l& C6 k% l    Units = cylinders of 1008 * 512 = 516096 bytes
7 ^4 u3 u* [- B/ e& ?# E       Device Boot    Start       End    Blocks   Id  System
3 ?( J) J6 a7 i1 T2 |0 v    Command (m for help): m
( [/ C1 D5 O/ T7 I6 I2 i    Command action
( i# d8 Z, Q" G$ M0 j- A       a   toggle a bootable flag
8 @/ z" r& ^1 X; o3 E       b   edit bsd disklabel
. v- f3 J0 j' Y/ H' @( p% z/ X1 Z       c   toggle the dos compatibility flag
+ v1 K2 |" _# Y       d   delete a partition
" `0 [" H- k4 {, A4 B* |' B5 m6 n( @       l   list known partition types
! m* U4 |; A3 k" Z       m   print this menu
1 s5 N& {5 ?( [$ n& V       n   add a new partition+ d7 m' G! f8 E& n) e" y. k% |
       o   create a new empty DOS partition table
$ w% A" e2 M" Y0 [" U5 N       p   print the partition table
  N* T6 ]  k' `5 y9 B4 `5 o, r       q   quit without saving changes
# w8 U. s; v3 }       s   create a new empty Sun disklabel
$ z( M+ ]! i7 q       t   change a partition's system id! p( h* v$ c  Z0 H' l3 e
       u   change display/entry units
' e" H, _2 A1 [# L6 i( u       v   verify the partition table; T0 D$ |, f1 F7 C) {+ m- b
       w   write table to disk and exit$ P! n; g4 y0 c4 @6 f/ Q) H* p
       x   extra functionality (experts only)
! b( W: `1 v8 _# P4 h8 J    Command (m for help): n
7 w, U$ G* ?5 y+ m8 f3 u    Command action
$ Z  L7 ?1 M$ V0 s       e   extended  N! S0 Z  g* ]- O
       p   primary partition (1-4)
0 m0 X* y1 B1 K4 y    p
" W0 Y  t! l) V& G7 z8 R$ z    Partition number (1-4): 1
: c+ m; G+ I" v/ s& h% l    First cylinder (1-8322, default 1):
7 V3 K7 m" k+ l5 F    Using default value 1
. k0 x5 E/ Q: v! R; a    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G3 ~4 `. }+ b* ]( d- q) k2 i: L
    Command (m for help): p# N4 _! N, D4 m4 J- }/ c* h/ l
    Disk /dev/hda: 4294 MB, 4294967296 bytes3 X4 J0 u3 x& e  _4 ~4 T
    16 heads, 63 sectors/track, 8322 cylinders; s: [0 [, F" |2 y3 }
    Units = cylinders of 1008 * 512 = 516096 bytes) S3 A8 A$ ^1 a' {3 @! l% l
       Device Boot    Start       End    Blocks   Id  System
# H" |' C2 E' B1 w3 J7 z, E    /dev/hda1             1      1000    503968+  83  Linux; A' r- y7 a- Z6 O0 b8 V
    Command (m for help): w
8 R6 {7 d( T) m' p0 X% m3 m    The partition table has been altered!
$ v  }1 T) r' J3 J! i( J. Q( q    Calling ioctl() to re-read partition table.3 I2 C3 e; k% _. l, [7 x9 M( K1 Q
    Syncing disks.- Z% n+ S/ [$ A; v  ?/ X+ \* M' ~3 \
    //格式化新分区
2 d+ v! p, R5 x$ R8 e/ o3 X1 x
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
: K# ?! _/ z# \, e% ^; Y    Filesystem label=3 j  p8 b: g, v2 U0 F" C% N
    OS type: Linux: U, o2 i& p& Q) }! D+ _7 W/ `8 }
    Block size=1024 (log=0)+ Z9 B9 ]4 b1 r7 m
    Fragment size=1024 (log=0)
5 A% J. Q2 V- R% ^& y    126480 inodes, 503968 blocks
) e% A* O6 P! v/ }    25198 blocks (5.00%) reserved for the super user
( e% N5 q3 C( z# {" N0 B% h8 \2 h7 ?    First data block=14 V9 d3 _3 _2 n
    62 block groups
( [! O4 c2 y  K0 [    8192 blocks per group, 8192 fragments per group% b: K+ _* _8 |+ I
    2040 inodes per group
% [/ r. I( x- Y! P3 ~    Superblock backups stored on blocks: 2 u7 X4 }) H0 l
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409) D, ^: }: K' y$ j9 A
    Writing inode tables: done                            # |: G! F- |! c' Y) m  z" @
    Creating journal (8192 blocks): done
) y8 b( P* B4 I5 {4 L) L% r    Writing superblocks and filesystem accounting information: done
4 \7 b0 o0 L) u    This filesystem will be automatically checked every 30 mounts or3 e0 W0 t$ W& P- g6 A2 a5 t9 w+ @
    180 days, whichever comes first.  Use tune2fs -c or -i to override.& d0 z# @6 l4 I" A0 X! c0 L
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
! e/ `1 L1 k" z6 c' D2 M    /dev/sda3              3723848    705992   2828692  20% /
: n' X3 w' y5 O2 v! F: _, M    /dev/sda1               101089      9274     86596  10% /boot. Z+ \( g. U" N  W9 g, m# d
    none                     14520         0     14520   0% /dev/shm" G5 j8 y  j5 S, H; x
    //挂上新分区
  j5 _8 V. W" x/ L6 {- f
  1. mount /dev/hda1 /home
    + J$ ^0 e3 K, K4 ~( Q6 v
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点6 H; C, p% C* s3 _6 U" p
    /dev/sda3              3723848    705992   2828692  20% /
6 y9 W: ]. _' m5 {, S) O3 d6 A) Y    /dev/sda1               101089      9274     86596  10% /boot" |! [" k* T# Z' `4 G( [9 A
    none                     14520         0     14520   0% /dev/shm3 n" H5 C2 F  `6 I: l7 [( x2 T! W: J8 u
    /dev/hda1               488006      8239    454569   2% /home
# ^4 A; }" Z9 |4 h4 B+ ^
8 z6 J. G: I, l' O自动挂载:: j) o0 s( f. a# Q+ S
  1.           vi /etc/fstab
    / |. t* Z1 a3 i/ b/ \+ W

  2. ( h# H0 J! ~# S, {2 I9 A
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    / A5 L; g4 w( E- T* q" \/ S

  4. 6 T+ _) u0 x. C
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:% o8 q: I+ f+ p) s0 G/ v0 ]
  1.           mount /dev/sdb5 /mnt/ljp1
    8 |$ p" T! j( l6 @) @2 b

  2. + j' x+ I! r8 P" \4 s# P( `
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

% g! j, g. p9 U" }/ Z5 r
7 G5 w. ~% v0 c# A& s) k& w: m1 J, J) S- W
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-21 23:42 , Processed in 0.011422 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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