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

 找回密码
 立即注册
查看: 2571|回复: 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)( ^: L; j% ^9 g  R1 o6 f8 f; Y7 r
      or: fdisk /dev/sdc  (for the third SCSI disk)
' g0 C/ T, @! R' h7 @1 w      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
8 k" _3 C; }2 i4 {2 j4 K      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
0 C4 L3 l/ S0 _1 |$ E8 X7 G& j      ..., u. Z' ?# T- ^! _3 i
  1. df -k9 c4 H' t( Q8 @, b' p
  2. df -lh8 p' z& i3 n0 M  X, V
  3. 查看有几块硬盘:fdisk -l) f4 S, B6 U( ~; M, W7 U1 Y
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
$ Y, m7 v7 ^1 E  L$ A    /dev/sda3              3723848    705968   2828716  20% /6 o, x9 N/ B+ {+ W  H3 R- P
    /dev/sda1               101089      9274     86596  10% /boot! y/ R: Y4 X( U3 k- J# X
    none                     14520         0     14520   0% /dev/shm
8 ?4 W& Q# `  G+ ?& X+ R2 Y    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
7 I: ?1 k# T2 z; H+ i7 B4 M
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel8 a) J" R8 I' x' _5 X
    Building a new DOS disklabel. Changes will remain in memory only,
2 K. a/ O0 T+ I* ]0 ]5 a- r    until you decide to write them. After that, of course, the previous
/ U/ [  F( O( o9 ?    content won't be recoverable.
9 q! d# z& i) Z* k5 S9 h    The number of cylinders for this disk is set to 8322.
4 ^7 o7 E0 b0 J& k6 y; M    There is nothing wrong with that, but this is larger than 1024,
% K, ?6 H$ A, @7 U: `4 c3 C    and could in certain setups cause problems with:
# H4 \: K% t; a9 t- k3 P    1) software that runs at boot time (e.g., old versions of LILO): E" [' p2 E. W& ~- n' K( K
    2) booting and partitioning software from other OSs
% d; p. T- P* N/ c2 h- S       (e.g., DOS FDISK, OS/2 FDISK)
  d2 P; Y% o9 ?7 \. r    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
  L' P! r2 s8 N& W5 ^2 d2 Y0 I    Command (m for help): p. j7 L/ O4 ^% [+ C7 F3 H8 r) _- o
    Disk /dev/hda: 4294 MB, 4294967296 bytes: D8 c6 k8 D) z! ^5 ?' b
    16 heads, 63 sectors/track, 8322 cylinders, l! _, o. ~0 U5 {6 L- [, [" c
    Units = cylinders of 1008 * 512 = 516096 bytes- ?$ n# e, O: h
       Device Boot    Start       End    Blocks   Id  System
* h9 u* O1 z* y" h    Command (m for help): m
* O  m3 C9 z3 P# E( K( |    Command action
" O- G' G% J' |0 [" R       a   toggle a bootable flag
- l! b1 Q/ E. y" U7 r' Z       b   edit bsd disklabel
6 K/ b+ h1 o3 ~4 ^! b/ n       c   toggle the dos compatibility flag
" v/ b4 a: r3 o$ P& `       d   delete a partition
/ }" c  ]# _& X8 l7 `       l   list known partition types$ ^6 _$ {% E* H
       m   print this menu; Y' K& Z1 W. I! z4 q' j1 R: r
       n   add a new partition
0 T0 Y: N! R7 G. {. [       o   create a new empty DOS partition table3 ~9 Y  L: |1 [" H
       p   print the partition table
. r  U. f1 c' j2 U       q   quit without saving changes
" {8 x# j9 N/ z       s   create a new empty Sun disklabel
: p& e0 ?* t% x/ F% _       t   change a partition's system id
* _! E  l9 ]# Y; J- F5 ~" }1 \" G       u   change display/entry units$ t* [0 D- ~. F% r& B* a3 Z5 ?) P
       v   verify the partition table4 i6 Y8 D  y" I
       w   write table to disk and exit+ {, T. Q& ?% S
       x   extra functionality (experts only)
; }: |+ F* _( ^- D9 W$ Z& B# |- ?7 x    Command (m for help): n
5 L9 h1 b8 D5 E) x8 o2 D3 c. Z    Command action& [$ m* N* V+ x' M# m' c3 E
       e   extended, F- W/ d$ |+ P: |
       p   primary partition (1-4)& N, w# d. T$ ?, y3 Q# k3 H6 Q
    p0 S; Z+ }& T. L0 [
    Partition number (1-4): 1
# j4 |4 C$ b( [, B4 {    First cylinder (1-8322, default 1): 3 m" C+ T& E- a) \7 ^
    Using default value 1
6 v; g+ U* _5 s2 B, x$ U    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
9 n0 x' b6 z1 O* x8 B6 E    Command (m for help): p
6 @, g' ?2 G. _3 S% ?+ w- O! H    Disk /dev/hda: 4294 MB, 4294967296 bytes6 V0 s$ ]% i' a8 B
    16 heads, 63 sectors/track, 8322 cylinders
  R0 j' x: {+ p% m; [    Units = cylinders of 1008 * 512 = 516096 bytes
9 ]9 o# E' C: U% ?% e' K: i       Device Boot    Start       End    Blocks   Id  System+ F2 A; L% O5 a/ m
    /dev/hda1             1      1000    503968+  83  Linux
- U& o8 ~. A& h# }. E    Command (m for help): w
6 v) H3 V1 N$ Y  Z6 o2 C8 m& g    The partition table has been altered!: V8 d' t- ]8 Y
    Calling ioctl() to re-read partition table.6 Y& W' e: w/ T& t( B
    Syncing disks." ]: h3 p. \& t) `' ]* P. a2 v( a8 V
    //格式化新分区
  P7 A5 O: p3 [* n
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
  v7 B% E0 P: }# l! ]! e2 E  b1 d, D    Filesystem label=
3 x+ u6 m1 Q8 o7 g    OS type: Linux2 E( V, {6 J& H$ S; v. V
    Block size=1024 (log=0). v" L+ |* n8 L) h3 u
    Fragment size=1024 (log=0)4 k7 D3 q" r9 {& D& F
    126480 inodes, 503968 blocks
5 R2 g$ Y  h& d2 u. ~& U    25198 blocks (5.00%) reserved for the super user
7 D0 w0 ~: R- [: Q( W- ]8 v, o    First data block=1' e1 c: N, r  w( B4 Y  D
    62 block groups! W, C* F1 U" D* v1 q: N
    8192 blocks per group, 8192 fragments per group7 s( w' Z: M. h5 ?9 y$ O" B
    2040 inodes per group+ q9 \/ r% {: T9 P5 R
    Superblock backups stored on blocks: ) P5 u$ U1 ]2 \9 [+ H
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409; i# q1 E1 q; v: N) a& O" x" m
    Writing inode tables: done                           
" F5 h9 z# l  D    Creating journal (8192 blocks): done
, v: g9 W) q# D1 ?8 P7 s    Writing superblocks and filesystem accounting information: done
6 n% p7 [  p+ E7 [; J+ N; U% q    This filesystem will be automatically checked every 30 mounts or$ M9 m' A; x8 G$ [
    180 days, whichever comes first.  Use tune2fs -c or -i to override., K, j3 D, N/ i/ q/ f/ O
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
1 }/ O1 U0 e7 j& _6 c  \+ C    /dev/sda3              3723848    705992   2828692  20% /
, j  B; B6 j6 w: V2 q- \" N6 j, \& b    /dev/sda1               101089      9274     86596  10% /boot7 b1 P& H1 \$ f& t& @$ `
    none                     14520         0     14520   0% /dev/shm
$ a8 b3 h' f6 t    //挂上新分区
7 A  {4 h; o2 I% ?% p" d
  1. mount /dev/hda1 /home
    1 f5 F" o, R- z/ N6 R# Z( }# M
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点: b9 k# g* d7 J. G' y8 @7 A
    /dev/sda3              3723848    705992   2828692  20% /
+ l1 g4 M3 Y7 N% E    /dev/sda1               101089      9274     86596  10% /boot
+ y* n2 n( e+ @0 Z5 n    none                     14520         0     14520   0% /dev/shm/ G3 v. B( x+ T+ ]0 W& X& k; o
    /dev/hda1               488006      8239    454569   2% /home. V" C8 j  H4 Q* d0 M; V
+ Q! ~! g# F) l, S. K0 ?
自动挂载:5 E* @* O; O. x& }& ]
  1.           vi /etc/fstab
    + I) e% i- K( D

  2. 6 z6 q) r" o9 g  C- M! W" Q0 p
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    : |3 X& a% O+ t! b2 r
  4. 0 d4 v7 s# K& y  D6 X" c
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:% q: x; [3 V/ M2 F4 N
  1.           mount /dev/sdb5 /mnt/ljp1
    ! Q/ x  I* h) ]; p3 N9 Y. @

  2. ) @* J2 o7 q* a8 X9 y& ~
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

6 ]; Z4 H- P0 t5 q7 w; s6 S1 p' t6 M6 V& T- `$ n
1 {# z; r' ?* c. b5 w  s
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-19 17:00 , Processed in 0.035674 second(s), 18 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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