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

 找回密码
 立即注册
查看: 2835|回复: 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)
2 Q4 p) l* J! L8 R' B      or: fdisk /dev/sdc  (for the third SCSI disk)3 K8 C  }5 m- q/ r0 u- H
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
1 T9 Q1 k9 V* G+ V% y1 p) H      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)% K1 D* h  _  u3 _" J2 j( ~! H
      ...
( l& D* d6 L( A* f. m' F
  1. df -k
    6 A0 n+ H/ E$ N5 D
  2. df -lh) j4 Z2 r0 M2 m# m- }0 J
  3. 查看有几块硬盘:fdisk -l
    2 Z) }+ G6 K8 J; }3 e* X8 u
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
7 e5 H1 }3 Y) `+ }' Q( w/ |( [% o: N    /dev/sda3              3723848    705968   2828716  20% /
, Y3 S8 m% s; y' a' F# `5 N    /dev/sda1               101089      9274     86596  10% /boot" }8 t& h4 G) K6 _4 o) b) y+ r$ \6 s- D
    none                     14520         0     14520   0% /dev/shm
2 Q  R. E/ F& f6 E1 S" z    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用- s4 P1 m* w5 M3 T* g+ x
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel7 r1 K6 K. M. ^8 w* j6 O5 B
    Building a new DOS disklabel. Changes will remain in memory only,
1 _8 p* a2 E, R0 z: H2 a; h    until you decide to write them. After that, of course, the previous
, w. L. x: m5 m3 k' A5 l6 v- X    content won't be recoverable.
; U4 p" ~9 |9 \" E6 \1 B+ j$ U    The number of cylinders for this disk is set to 8322.
+ Z0 K* }# k) F2 o4 i    There is nothing wrong with that, but this is larger than 1024,
  i  p: w3 C' w9 h/ E* p    and could in certain setups cause problems with:! h6 y& j8 s) b
    1) software that runs at boot time (e.g., old versions of LILO). C0 `9 p) A, ~/ t- f: o  H+ ^! b
    2) booting and partitioning software from other OSs* m* m& C& M  }" b$ e( x
       (e.g., DOS FDISK, OS/2 FDISK)
" F# S" j8 e% _6 a" ^; p7 S$ L    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)8 r7 T0 B5 B. i  ?
    Command (m for help): p
7 p+ p' a3 _& x$ I7 P    Disk /dev/hda: 4294 MB, 4294967296 bytes
- i8 z! I/ J+ J    16 heads, 63 sectors/track, 8322 cylinders3 {& [/ f  E% ]% I
    Units = cylinders of 1008 * 512 = 516096 bytes
6 O0 d' r2 E' w       Device Boot    Start       End    Blocks   Id  System
0 }$ B" g' [8 a5 n    Command (m for help): m
# S8 J6 n" ^* c4 U  U/ e    Command action
# I: R/ Q: {* M) w- X& V0 X/ j2 U  x       a   toggle a bootable flag
+ S) R* I  a- L5 U6 U       b   edit bsd disklabel% W1 I9 R( S6 E3 s+ M# X
       c   toggle the dos compatibility flag
$ _' ~, _+ {9 C, W! \: J) }       d   delete a partition
+ D* n# d+ ?6 M- d       l   list known partition types6 A4 @3 s( @) V) ?; F9 r8 U
       m   print this menu
! v+ o* B6 c" |$ ?5 Y0 i, J8 h1 B       n   add a new partition
# j5 J0 z  j$ x. A* ^& @  }" W( z       o   create a new empty DOS partition table
$ \9 s& X' }2 l. v5 R9 r( m: r8 w8 C       p   print the partition table) O- M7 h2 w9 K5 G1 z
       q   quit without saving changes3 I( J* ^) M. m
       s   create a new empty Sun disklabel
7 }8 ^6 v. a  K' a$ R9 x) x       t   change a partition's system id
6 q( p8 |% G+ W( ]       u   change display/entry units1 p9 C, M7 {6 G( I  U
       v   verify the partition table
) B4 O+ B: L* b; C       w   write table to disk and exit& ]; B$ C5 r8 b. M" c+ f
       x   extra functionality (experts only)3 |$ L$ z  z' h+ R: u
    Command (m for help): n
1 ^4 k2 M$ z# m# j3 W+ b# B6 W; v8 I    Command action' {- U5 I4 f! j# r
       e   extended
4 q" K/ ~4 a8 d9 N) c       p   primary partition (1-4)
* q+ R1 s7 d  _    p. d2 P9 D$ {3 g" W
    Partition number (1-4): 1* c# w( q5 j/ g* a$ q3 `6 V3 V
    First cylinder (1-8322, default 1):
" L, [- M  T" X. f3 E! ?    Using default value 1
- U4 L* ^5 j2 ~: x0 e    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G4 N- N0 E# R( o8 @% Q. D
    Command (m for help): p+ d% s' C: s, |2 ~! c7 t* n, y
    Disk /dev/hda: 4294 MB, 4294967296 bytes
. C( c9 X! L% O& ?1 B' D; O4 n    16 heads, 63 sectors/track, 8322 cylinders
/ `$ s! Z' [: Y4 T    Units = cylinders of 1008 * 512 = 516096 bytes
' @' Y1 ^3 f  E. j8 g  o+ T       Device Boot    Start       End    Blocks   Id  System2 S7 C# ~0 U) v1 v
    /dev/hda1             1      1000    503968+  83  Linux8 q5 I0 W5 j1 A! a- M
    Command (m for help): w! S3 H: C  F% T. g* Q! o
    The partition table has been altered!
: {6 [* M% y+ [) a9 O% A% b    Calling ioctl() to re-read partition table.$ w0 g0 t" _! X# t2 F
    Syncing disks.
3 z. F/ {$ z4 d( N3 \    //格式化新分区; ]/ d9 M8 Y8 x2 y% A
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
4 k% L: p" t, J7 _& M# ~$ P    Filesystem label=/ \/ ~( k% p" s6 N  F6 J; A
    OS type: Linux
- W4 }8 O1 Z2 Y. M% M    Block size=1024 (log=0)
5 U6 Z6 ~4 t' K! a& b/ ?    Fragment size=1024 (log=0)
5 [' o  R0 [) C/ s! w  U    126480 inodes, 503968 blocks: b: g, d4 ^% x, e3 e, t6 A
    25198 blocks (5.00%) reserved for the super user3 e. r/ M- O) n/ x  ]
    First data block=1
2 {1 \8 v% |+ t- ^    62 block groups  z# f: ~7 m; Y9 z) C
    8192 blocks per group, 8192 fragments per group, j6 V* g0 L" E5 w4 n
    2040 inodes per group
2 b0 u  D9 F9 V7 L. q# @& |4 E    Superblock backups stored on blocks: , C, G1 U% h; J1 @% J
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
7 |4 `. d8 Q$ m. v( c( G    Writing inode tables: done                           
+ v2 H4 I/ T1 @. `5 J    Creating journal (8192 blocks): done
- [: s8 N* ^$ Z    Writing superblocks and filesystem accounting information: done5 X+ ]) x# z+ Y
    This filesystem will be automatically checked every 30 mounts or& n  R) q$ H- a. s/ L( y$ T
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
5 y, Y2 K/ y' O6 O0 o
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
. W' n( C  }; W+ R+ j4 e! m    /dev/sda3              3723848    705992   2828692  20% /
- i0 `& p* a# ~7 i    /dev/sda1               101089      9274     86596  10% /boot8 G. a9 r* E. ]; t* z1 ^2 q
    none                     14520         0     14520   0% /dev/shm+ ~; G0 q8 i, X
    //挂上新分区: W/ Z* y- r% t0 q+ S$ \
  1. mount /dev/hda1 /home. \/ a! B; d! f  f4 I; {( O
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
1 g3 R: G8 N5 k; I& ~1 ~0 b    /dev/sda3              3723848    705992   2828692  20% /% U  v/ l9 ]- {! x& `, v
    /dev/sda1               101089      9274     86596  10% /boot$ Y$ y/ S) e4 `$ W. l% u/ F
    none                     14520         0     14520   0% /dev/shm$ I7 K6 W. G& \  y  Y
    /dev/hda1               488006      8239    454569   2% /home
! d7 a7 u9 P$ R5 x
; D2 S4 I) j/ Y: D* T+ Y自动挂载:
/ z. O9 `; J/ r7 Q7 d9 T
  1.           vi /etc/fstab. M- ^3 i9 J" E3 ]" \6 E5 V

  2. ; G( |; q& s/ q- T
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    5 I  n- k# z& N

  4. - i4 G' L$ p6 e$ i" w# T/ }( v0 N
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
7 B( N) s( x( t, c. p
  1.           mount /dev/sdb5 /mnt/ljp1$ H  b% E  G) P+ x' j* O8 ]  t3 Q+ G
  2. 1 c7 Y) u5 C# [$ o& f5 e
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
% `! a: k4 w0 E8 O" M$ ^" {
# ~4 j, B0 T) \5 v* ?5 d

% N9 S- y6 k- C' H, k/ W, X
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-23 08:36 , Processed in 0.010372 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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