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

 找回密码
 立即注册
查看: 2204|回复: 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)
' _9 X4 e+ x* R3 [' M/ a- T$ D* v. o      or: fdisk /dev/sdc  (for the third SCSI disk)
- l5 x# P# n3 f* t6 y$ `$ L      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)& u( A' N6 [7 g7 e! k3 Y/ v( e
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices), b  I* j  S$ p2 H
      ..., @9 P  h' s! a0 F2 a8 |' h+ P" _
  1. df -k* D* Z  g) b- e/ `$ m+ ~
  2. df -lh
    ; v- o4 z* @2 d( m
  3. 查看有几块硬盘:fdisk -l
    * u6 C  L6 N1 K
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
  e& U- I3 r& W8 Q2 w7 Y1 N5 {    /dev/sda3              3723848    705968   2828716  20% /
! p+ U: F0 v5 N3 b) c& N    /dev/sda1               101089      9274     86596  10% /boot" J- Z/ \9 W8 X, _6 ]3 g, V% j
    none                     14520         0     14520   0% /dev/shm9 M+ L% D' S& ?0 {
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
2 a, Q& \, W9 L! d7 E
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel( k* Q( z* J6 d9 s  y5 Q7 q
    Building a new DOS disklabel. Changes will remain in memory only,
5 `: G0 D3 I) W% g2 K/ P* e: c    until you decide to write them. After that, of course, the previous. q) x1 K3 |6 s
    content won't be recoverable.. ?8 D& g; X& M- p% p* z
    The number of cylinders for this disk is set to 8322.
6 g5 C4 m" G: z5 _0 M* i/ |    There is nothing wrong with that, but this is larger than 1024,
' o: o0 ~. c6 p. I, o9 T1 _    and could in certain setups cause problems with:# H) c% J. V! o  {
    1) software that runs at boot time (e.g., old versions of LILO)1 h/ H' B' D# `
    2) booting and partitioning software from other OSs
, E/ l/ b) [$ K. A# a       (e.g., DOS FDISK, OS/2 FDISK)( o+ L  r% |' Q1 `* ]7 P9 L: P9 Z
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)" E7 b  z7 |; _5 J- n
    Command (m for help): p
( |$ h1 R2 D7 F* G    Disk /dev/hda: 4294 MB, 4294967296 bytes
9 v$ V2 @' d- n( S) S. ]# H5 ]% L* A    16 heads, 63 sectors/track, 8322 cylinders
$ q) s2 p; p2 B" h5 o    Units = cylinders of 1008 * 512 = 516096 bytes. d# H  e9 u. g7 u' {
       Device Boot    Start       End    Blocks   Id  System
& x3 B% Z; g8 R  j# L1 ]; l; I$ q    Command (m for help): m
) G7 O+ p& ^6 U/ J8 M- q4 H    Command action
2 f9 u0 G; E9 b. }( J, M- O) ?. F  L       a   toggle a bootable flag/ R2 I/ Y8 L6 ?) G4 ?( U& v0 G, T
       b   edit bsd disklabel6 r0 F8 @% v$ o7 }
       c   toggle the dos compatibility flag
' r, Z, @) \( u% T       d   delete a partition
+ G0 {: k$ L7 F# I1 B       l   list known partition types! |6 C& R, ?2 j- z
       m   print this menu
" \; x* w! E% d) q: B8 K/ s- n       n   add a new partition1 Z/ H# C+ j' I1 u  r
       o   create a new empty DOS partition table
4 H) C/ C% w- u) N" j) }7 j       p   print the partition table
9 \. R+ f; N: c% D       q   quit without saving changes. o2 r8 O9 Q6 p! Z4 m
       s   create a new empty Sun disklabel
; G/ K- i$ i. F. Z& ?" t       t   change a partition's system id3 F; _" U; t3 g" N6 ?
       u   change display/entry units! K0 h2 W& i1 C
       v   verify the partition table
, a( j  L! u/ G+ B; l  }       w   write table to disk and exit9 a2 j$ g. o5 g
       x   extra functionality (experts only)/ l2 w; Z% m+ E6 z( a1 q
    Command (m for help): n
) Z! s4 h! C% m! M% Z+ S7 u! p/ W" E    Command action
. B0 V5 s$ |8 |$ [       e   extended
5 i& c; m( H- d" ~6 f; ~) a  V       p   primary partition (1-4)
/ y7 j9 v) Q6 H, L# q( }    p, N3 S$ r6 [4 B
    Partition number (1-4): 1
6 Q" z' I6 ~+ v! ]# \    First cylinder (1-8322, default 1):
* N! A* H1 ]0 h. T    Using default value 1( ]; M% M' @& Y  }4 i# e
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G; [' O, M+ z' j
    Command (m for help): p
; \+ ~) y$ s! G    Disk /dev/hda: 4294 MB, 4294967296 bytes. J/ l, r$ v9 c3 }
    16 heads, 63 sectors/track, 8322 cylinders
( P' W5 n5 R  T2 T    Units = cylinders of 1008 * 512 = 516096 bytes
/ V) J+ m& ]: w  F+ L) W       Device Boot    Start       End    Blocks   Id  System
! m  C; B* g- o. {  V. |4 T    /dev/hda1             1      1000    503968+  83  Linux
; c6 G$ s: c+ E! n0 N# H# X    Command (m for help): w3 M/ W" c2 V# M2 }) r# W
    The partition table has been altered!8 }! G' Q. `: j' m
    Calling ioctl() to re-read partition table.
; e$ |6 A' _' Y5 U    Syncing disks.% D8 n9 g) v9 |# J
    //格式化新分区
8 i# W0 w/ u2 j
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
) C" T( ]/ w5 W5 S& v, H8 N    Filesystem label=
+ i+ K' O0 o3 m8 x- ]+ H% Q    OS type: Linux/ B, G, ~1 F3 d9 B$ O5 C8 O
    Block size=1024 (log=0)
- E2 A- i: o3 T% U& h6 G    Fragment size=1024 (log=0)& i$ L0 z' G2 i8 k& w
    126480 inodes, 503968 blocks) n6 t6 p" L( U" y
    25198 blocks (5.00%) reserved for the super user
( D8 v+ C. k8 D' m( o    First data block=1
( h7 N. n  ^* c) A8 O! _8 x    62 block groups' J; s2 D# I+ z' }
    8192 blocks per group, 8192 fragments per group5 M; J% v2 B9 ~2 I! [1 t# I
    2040 inodes per group
/ ^9 O0 j4 N: {4 J( P1 f( L    Superblock backups stored on blocks:
8 U. {! [3 ^0 J* i0 }9 j0 e( K            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409! N3 O- T9 a, N. c( s9 w3 d, }+ b
    Writing inode tables: done                              z8 Q2 i5 _7 g" U5 o  c  y
    Creating journal (8192 blocks): done
9 y6 M& Y7 V0 b! y& u- j8 [3 D    Writing superblocks and filesystem accounting information: done7 T- V  J" c7 ~" K4 h
    This filesystem will be automatically checked every 30 mounts or
% m% W1 ~2 _3 e% |$ J& u1 y. L- i    180 days, whichever comes first.  Use tune2fs -c or -i to override.
( O  |8 T- _2 a" S. y9 R* D3 k7 h' p
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点' e5 ^0 H5 A( ^, u7 T0 @
    /dev/sda3              3723848    705992   2828692  20% /
# K; i% _2 I/ S6 I# b: p/ e4 x    /dev/sda1               101089      9274     86596  10% /boot
7 I$ E& r% ?5 B$ p0 w0 ^( a    none                     14520         0     14520   0% /dev/shm, G7 o2 E+ i# u4 z- |
    //挂上新分区; o: o/ S: U# g  A% ^1 h9 _0 {- O
  1. mount /dev/hda1 /home# s$ r1 g" D8 X9 X6 T; U
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点1 a0 J  X7 I; o. _+ r) V
    /dev/sda3              3723848    705992   2828692  20% /$ x1 Y" S  o& X+ o8 \2 x$ v
    /dev/sda1               101089      9274     86596  10% /boot) l6 G7 w0 @! U+ B  Q9 l
    none                     14520         0     14520   0% /dev/shm
" Y9 R: H  s# z5 {, N    /dev/hda1               488006      8239    454569   2% /home) y2 r8 w/ a2 j% ^; u+ G

* I9 l% P1 L! E3 O8 g& |4 ?* c- h0 ]自动挂载:
7 F+ q* D" h' b6 p
  1.           vi /etc/fstab- S/ T& z0 u2 Z
  2. 0 e/ U# W( c  A& E
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    3 B7 p2 w3 i7 `" W
  4. ! k" b; C3 X; `! l. `; |4 I
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
) D, @- Y/ F1 T7 X6 S2 l4 R" C
  1.           mount /dev/sdb5 /mnt/ljp1; R/ `, B" N8 n2 ]4 Y, Q
  2. % I, i9 y9 S/ |% Z) s6 h' ~# t
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
7 G4 ]' |4 W8 g$ O5 r' q

  l' c5 j( x* o9 b' d8 x7 k' \" v' `" u2 ~) G% l7 C- I9 S' K
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-6-27 12:08 , Processed in 0.045323 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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