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

 找回密码
 立即注册
查看: 2715|回复: 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)8 C# d3 h8 R* C3 m% V
      or: fdisk /dev/sdc  (for the third SCSI disk)) X& q$ M8 c4 L. h- c. }
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)- E* E4 N& `& g2 t+ X8 m' e
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)& s; d  J) a. {9 ?2 ^; R
      ...! Y5 q" ?5 V* I6 m- u
  1. df -k
    1 Q; w" o& ]0 V" B
  2. df -lh% H! |2 \) U" d0 Q
  3. 查看有几块硬盘:fdisk -l
    ( Y& C. U! X2 h
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点4 o: [; r6 U1 O$ m
    /dev/sda3              3723848    705968   2828716  20% /
" h& \+ {7 R! x, [5 h& t* i! y    /dev/sda1               101089      9274     86596  10% /boot
+ |- G: i2 K; ^  o8 t" O    none                     14520         0     14520   0% /dev/shm
1 q! L2 k' u0 Y. e$ D    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用( ~. S, H: X/ h0 u- W% _" m
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
. Z8 ]# v+ v8 L0 n$ u, C    Building a new DOS disklabel. Changes will remain in memory only,
! L6 j, a* @+ A! i    until you decide to write them. After that, of course, the previous
  J, a* L6 n5 ^$ J    content won't be recoverable.
  R9 R+ {" Q, H( h    The number of cylinders for this disk is set to 8322.+ t3 n: N/ {3 R5 R8 u5 i* Q
    There is nothing wrong with that, but this is larger than 1024,( Q8 m0 K) A- i
    and could in certain setups cause problems with:1 v& I8 d6 s3 ~3 Y
    1) software that runs at boot time (e.g., old versions of LILO)
7 H1 t6 y6 Z4 m0 D0 f    2) booting and partitioning software from other OSs8 ^+ E* M) f" K$ R! G- o  O4 S/ |
       (e.g., DOS FDISK, OS/2 FDISK)  w" }- p4 G  k/ Q( p* u( I4 E
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
+ w1 h0 l6 S5 `$ J5 \5 ~6 O9 C# |    Command (m for help): p
, L9 P) Q6 {8 Z& ^    Disk /dev/hda: 4294 MB, 4294967296 bytes7 l! T9 c( z2 B
    16 heads, 63 sectors/track, 8322 cylinders
- ^% U4 M' B) `; b3 c+ l9 Z    Units = cylinders of 1008 * 512 = 516096 bytes* D4 I$ ]- K. P+ P' d* F
       Device Boot    Start       End    Blocks   Id  System
3 v% H8 v4 m, s# ?" {& H    Command (m for help): m
/ z8 [8 H$ |. j6 U2 N* Y5 D    Command action; |5 w: V# [# g" G8 Y% J
       a   toggle a bootable flag* t' w: A2 e/ W6 e% U' Q
       b   edit bsd disklabel
1 y$ ?, y* w2 Q7 d       c   toggle the dos compatibility flag
! C2 b3 P6 Y+ n) \0 ^& t' H       d   delete a partition6 u4 J8 ]1 t: [3 v+ _( n$ y6 @! x
       l   list known partition types# K. a" p0 f' H4 L
       m   print this menu8 x+ ~3 D* c! t+ B
       n   add a new partition, ?7 ~" `, n# z6 o4 M( u
       o   create a new empty DOS partition table( J( F; ]5 r( h8 k4 F+ X' }
       p   print the partition table4 f( L  M- R* ?0 P) K
       q   quit without saving changes
8 l& U) i+ N; k& Q: e) t5 c% {       s   create a new empty Sun disklabel
2 |4 S0 n, [2 N. E2 O: a       t   change a partition's system id5 [' C- ?) G: E% }' e
       u   change display/entry units  ?/ k* E- {( U6 L  C/ ]
       v   verify the partition table( l7 ?) v/ L) E; [5 i. [
       w   write table to disk and exit
1 x# h0 J  Y6 `5 i) k) L) E- m# P0 w9 Y       x   extra functionality (experts only)
9 J9 D5 [! f) }: ?    Command (m for help): n
* ?; f, P. P1 P+ g! e    Command action* L6 i8 R! @8 t1 y
       e   extended1 F, w; @+ b- \" @" o
       p   primary partition (1-4)8 j" H/ ]0 G' O8 S. g6 ^8 I
    p  m3 z- S3 `/ o5 v2 h
    Partition number (1-4): 1- ]5 e( v+ V( G: Y  {, Y: l+ O" D
    First cylinder (1-8322, default 1): + z$ n6 x4 W  s, I5 o8 ^
    Using default value 1" l1 G$ x. Z* ~! X7 h
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G( Z* ^* a- Q! m4 h4 F
    Command (m for help): p
3 h" D  n& l2 \( L; {    Disk /dev/hda: 4294 MB, 4294967296 bytes* P; d+ I' M! [# I2 f
    16 heads, 63 sectors/track, 8322 cylinders( K( q' S1 H! J( U! Y4 Y
    Units = cylinders of 1008 * 512 = 516096 bytes
4 ^7 ]6 Y& ^, D5 {( L; l/ ~       Device Boot    Start       End    Blocks   Id  System$ W2 C- Y" N5 h8 t4 O, L4 B. s
    /dev/hda1             1      1000    503968+  83  Linux
/ L6 G4 l, i4 E/ `, ]) b0 Z    Command (m for help): w9 _2 S: s& @1 C
    The partition table has been altered!
$ _  B1 V2 r  O3 b: n  x) X    Calling ioctl() to re-read partition table.8 w6 F" N- Q, W: z  H
    Syncing disks.$ |; a% r9 f. A1 C( ]
    //格式化新分区6 m" A( Z# S8 x, g5 k
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)5 d( Y  f- ~$ B6 U3 ?2 @3 `
    Filesystem label=( V3 o, i; N! L+ J! F3 d7 `3 y
    OS type: Linux) n% ]6 [5 s, n( o  N- K, K
    Block size=1024 (log=0)
1 A- R) L" h& f7 a. F    Fragment size=1024 (log=0)7 l: S' }2 w, L  x
    126480 inodes, 503968 blocks& X& L' l/ K1 s5 O, Y- X
    25198 blocks (5.00%) reserved for the super user5 J  K- `1 Z7 v% U  T
    First data block=12 g7 J& w( ?# y1 v! E+ L% t
    62 block groups
( X/ G5 J. I. l( M( ?* ~8 v* J: Z* k    8192 blocks per group, 8192 fragments per group
7 r, j5 a  j% @$ o0 q7 w    2040 inodes per group- c3 ?  v& \! v5 q$ K6 }$ t% q
    Superblock backups stored on blocks: 3 V8 |/ ?/ h% g' w1 a/ y
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014094 ]* l' U0 X6 h3 W" u
    Writing inode tables: done                            6 @% ?; q9 Z3 V6 K# ^, [) ?5 w' X) S
    Creating journal (8192 blocks): done
' Q. j3 |" u3 Y1 I) J* y4 ^. O    Writing superblocks and filesystem accounting information: done. o9 r7 z/ K1 P% P2 h+ {4 {9 v$ P
    This filesystem will be automatically checked every 30 mounts or# T( u9 ?; L9 C' ~4 w# M9 ~
    180 days, whichever comes first.  Use tune2fs -c or -i to override.. g' Q6 \$ m1 A% X$ `% G+ u, n( ?
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点: }- Z! r* m3 u/ h& a, f. L7 l/ }0 R
    /dev/sda3              3723848    705992   2828692  20% /
4 R7 C3 I& X3 W2 m0 Q- a    /dev/sda1               101089      9274     86596  10% /boot
. V2 [5 B# Z. j- b2 z* |    none                     14520         0     14520   0% /dev/shm
) U3 s/ f' S1 o8 p5 b    //挂上新分区7 \3 V5 c0 I- b, l1 R3 Q* M
  1. mount /dev/hda1 /home2 n) A9 k9 D4 L3 n8 Y9 C
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
# J" i0 M3 d# r* Z- R5 z1 Y    /dev/sda3              3723848    705992   2828692  20% /' j7 |/ c. c' f: _/ c' Q8 J
    /dev/sda1               101089      9274     86596  10% /boot
; j; J6 d6 c% b! Y# H    none                     14520         0     14520   0% /dev/shm
0 R9 E) f8 b( C/ U1 a/ F0 `    /dev/hda1               488006      8239    454569   2% /home2 }" q' Z9 ~, @* z, ?1 j2 u

$ D: A* g: {0 q3 k% H  p自动挂载:8 U7 B  X! T0 s, K8 d1 V
  1.           vi /etc/fstab5 y  l2 W4 B) [0 X

  2. 3 h3 X+ B$ i! v4 H9 G* S: `7 R
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0. v: ~" f; L6 u! }% P
  4. : ^7 k$ I! X$ \8 w6 F  t  E
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:1 j" {! r& e8 e( M. h: h
  1.           mount /dev/sdb5 /mnt/ljp16 b# {7 q4 i* F0 P" ^% l6 k

  2. 8 N' U' l7 X5 o( d: G
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

3 O: A. B! ^& X* N& ^* G
9 f8 p  z' Q* y1 {) D0 j; F. e/ }# d7 G+ r
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-27 23:25 , Processed in 0.033651 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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