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

 找回密码
 立即注册
查看: 2727|回复: 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)) m2 C% |" f8 W
      or: fdisk /dev/sdc  (for the third SCSI disk)2 e! s- A0 _. ]; M8 Q6 G. \" V
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
0 k. H% @$ g0 @0 _      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
8 K. e4 }0 {/ ~7 y( Y      ...; Z) X$ j3 e; B  `5 t+ p
  1. df -k  E5 ~. y9 d1 Y& m
  2. df -lh
    ' g1 J. d0 y; S3 u2 k: |
  3. 查看有几块硬盘:fdisk -l
    * e1 `: X  p. i
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点( }7 b9 G! u" S2 W: c( |
    /dev/sda3              3723848    705968   2828716  20% /9 E% }" f, N6 J! P8 k( b, C; l' }
    /dev/sda1               101089      9274     86596  10% /boot( a- @5 n5 A( t7 b+ w8 X% J
    none                     14520         0     14520   0% /dev/shm/ e- C# k$ f& l6 a; V- K  X# j
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用3 b: p' J+ |  v! Z9 ]" o5 J
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
0 I; @3 P& I+ a0 W9 G/ J: p    Building a new DOS disklabel. Changes will remain in memory only,
8 \" @8 l' W$ f; }: b: a" M8 I0 Z    until you decide to write them. After that, of course, the previous& Y8 b8 B/ h% F5 ^8 h- |  L
    content won't be recoverable.+ X; h0 Q: f2 f4 d  ^3 U& ?
    The number of cylinders for this disk is set to 8322.
0 B1 b3 {" N9 h    There is nothing wrong with that, but this is larger than 1024,  t& ]( f0 \8 ^" `% q
    and could in certain setups cause problems with:. U( W  R' y" D8 @1 `& I! C
    1) software that runs at boot time (e.g., old versions of LILO)9 V8 R9 d# y( V- O2 c
    2) booting and partitioning software from other OSs
& y& v" M- p4 z/ f4 V: g6 Q- L       (e.g., DOS FDISK, OS/2 FDISK)8 N1 d( s# l7 o
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
1 O- N# |9 e. d    Command (m for help): p# v) Z! i/ F, k- ^
    Disk /dev/hda: 4294 MB, 4294967296 bytes2 W0 p  O! S$ s9 M7 Y# Z; Q9 k
    16 heads, 63 sectors/track, 8322 cylinders
. {. a7 q% u# H  x" B. T    Units = cylinders of 1008 * 512 = 516096 bytes
, Z2 v2 R' H) w* Q3 u       Device Boot    Start       End    Blocks   Id  System" f* ^6 |  m0 H
    Command (m for help): m
- g3 H7 J) C4 t    Command action
& q; y8 M& n& [" E. o# H6 W       a   toggle a bootable flag
; e/ Z) u: R+ Q# L: ?       b   edit bsd disklabel
; g: J& N; d& v" e5 E8 z, A" {       c   toggle the dos compatibility flag
: S' Z; B8 J9 q; O       d   delete a partition' ^. G+ [6 w& s: y" d! g% e- N
       l   list known partition types
. D& d8 v& w- c9 M: t       m   print this menu
: c& K4 F, E% n       n   add a new partition
3 {1 j5 }: I9 z, m       o   create a new empty DOS partition table1 ^6 `# v( @  [# a1 `2 m, W( C
       p   print the partition table9 z  y/ d( i  @4 S7 F: u
       q   quit without saving changes1 S2 @& U+ u* M0 I& n
       s   create a new empty Sun disklabel
4 ^( l, F. |+ Z2 w5 P4 A1 G       t   change a partition's system id1 d0 e# [* v: G/ t, C1 h
       u   change display/entry units
/ X. H1 Z/ g& C; D% c       v   verify the partition table2 d4 u/ q2 i0 ^3 A2 q9 _
       w   write table to disk and exit: `2 y6 r7 }/ p# R* K; ~2 }
       x   extra functionality (experts only)
2 ]7 W3 k4 \1 }5 m5 j% T, S( E- I+ g; R    Command (m for help): n5 Y: Z# p( o5 A2 L
    Command action& z( g; \4 M: r1 c/ E
       e   extended3 h5 W* F' H+ o+ E) z5 W
       p   primary partition (1-4)8 H: B. A- V4 O. ]6 w5 C; Q
    p  r% C- C$ I+ s2 k' E2 ^
    Partition number (1-4): 1* t7 X7 x: e# L# R4 A# p! y4 H
    First cylinder (1-8322, default 1):
  Y0 f5 ^4 S; G0 O, i' u) A$ }" z, [; Q    Using default value 1
/ W" }" m* ]' _    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
) b8 |* e' ]" F. z& I9 d& v5 ?7 u    Command (m for help): p$ X  m0 D, R. T# D
    Disk /dev/hda: 4294 MB, 4294967296 bytes1 b6 ?, n0 k# g
    16 heads, 63 sectors/track, 8322 cylinders9 I) v5 @+ B- H7 O  `5 z# v
    Units = cylinders of 1008 * 512 = 516096 bytes5 u! Z- Q$ N8 K; B2 x  S. o
       Device Boot    Start       End    Blocks   Id  System
5 p& t' Y9 u- f( j* e    /dev/hda1             1      1000    503968+  83  Linux
3 V  p/ W, b: d8 F4 ]    Command (m for help): w
; B1 W! `8 F" B9 m7 B    The partition table has been altered!' ~, T- s: U; x3 G1 n1 W4 k
    Calling ioctl() to re-read partition table.# n/ o7 w/ g0 q) I
    Syncing disks.# W/ B2 U  V5 x# ~
    //格式化新分区
. A$ J% q5 J( y
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)- ^0 L0 ~+ h1 C  n0 v- D* d  ~# {
    Filesystem label=
+ H' M* Q. j! i3 o7 n    OS type: Linux
' a+ e0 ^1 O1 A    Block size=1024 (log=0)
5 l( Z* ^: z7 ?& g    Fragment size=1024 (log=0)
1 \  `. U; c9 V) n5 o5 p& E    126480 inodes, 503968 blocks" o# w, X7 R% T+ w% p' s( R
    25198 blocks (5.00%) reserved for the super user4 b- b4 M: }- ~8 T# \% |
    First data block=10 O+ o& N/ q" ]3 S' J8 ]9 `
    62 block groups
% ?# \3 ]* M7 C. Z    8192 blocks per group, 8192 fragments per group
3 Q+ i# ~7 |% U/ ?    2040 inodes per group
2 t! ], P+ z8 v    Superblock backups stored on blocks: + L) z3 [0 ~1 L1 |/ ?; |/ Z. Y  T1 V
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409! n' [- [% ?1 w1 O+ _2 A
    Writing inode tables: done                            ' Q* _0 J$ P  p2 n
    Creating journal (8192 blocks): done! d% Y  r7 D/ l8 M- Y0 E
    Writing superblocks and filesystem accounting information: done
9 F/ Z% s) V$ ~/ b$ t6 X. x( O    This filesystem will be automatically checked every 30 mounts or  f6 y" ?  o1 d  G$ K7 M
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
7 [& j) J! n( ?' Q0 ?% r
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
/ i1 `% F6 r% N9 c5 d0 r* A, F    /dev/sda3              3723848    705992   2828692  20% /
3 |) ^5 P# c2 |- v    /dev/sda1               101089      9274     86596  10% /boot
* m3 z% i' Q+ @8 r5 U0 D7 _) C4 u    none                     14520         0     14520   0% /dev/shm
# `% T6 q  }# e( a3 i    //挂上新分区
6 L6 l' \6 Q# g
  1. mount /dev/hda1 /home; c3 w& B- l- G4 b( M. s4 o1 k7 ~
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点$ F" z- b/ ^8 D8 E' _/ n1 A" w
    /dev/sda3              3723848    705992   2828692  20% /
; U" U1 |5 N/ \    /dev/sda1               101089      9274     86596  10% /boot
1 V2 F/ \6 g. _1 _    none                     14520         0     14520   0% /dev/shm
7 U- R$ Q8 G: c& u& Z; b# W7 p. x. a    /dev/hda1               488006      8239    454569   2% /home
' @( d) u" w% o  l+ ]' j& l! Z6 \3 f0 H- ~
自动挂载:5 l4 W, V8 q( P' h: p2 a& k
  1.           vi /etc/fstab" z7 }) \; g: C& V
  2. " t' e- W" Q7 @; ~4 q
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    , p) J! K1 p% J) {) s: K, l
  4. 4 N! p" C% f" K$ {& i% p  v
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
2 M) C2 B  \. E, t2 |
  1.           mount /dev/sdb5 /mnt/ljp1
    . l; ?5 x7 B5 J4 p+ c: \( p
  2. - n; B: O* v  i
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
/ T4 x5 G& u/ T5 q% U' `
0 g% {( A0 H) ?/ Z
3 T0 D8 _# u# W
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-1 10:17 , Processed in 0.011776 second(s), 10 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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