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

 找回密码
 立即注册
查看: 2337|回复: 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 g  U& d5 x; A/ T      or: fdisk /dev/sdc  (for the third SCSI disk)/ r  n9 P" y1 c
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)1 U! ~0 x6 K% R- D  i" A- B4 J
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
6 L8 S% G6 Y* A# J% _- @3 j/ l- Z  q      ...
6 e1 g& x& B; t) @
  1. df -k& ^7 F" H4 z" W
  2. df -lh
    ( R& t3 e0 P. W, F$ {1 v' B
  3. 查看有几块硬盘:fdisk -l
    8 @) |' Z  B0 w
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点; K4 z6 Q9 h4 a2 f' g/ d
    /dev/sda3              3723848    705968   2828716  20% /- y, {* D( z5 n" w/ C! `; A) F% w
    /dev/sda1               101089      9274     86596  10% /boot
5 I1 C- B! t4 L9 H6 F2 z4 J/ d! G    none                     14520         0     14520   0% /dev/shm
; l: T1 _0 d- N# i9 \    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用, `+ Z( K3 J5 @/ l' b
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel" l+ b5 h8 q! t  o* k. N
    Building a new DOS disklabel. Changes will remain in memory only,
/ F( D( R+ R1 Y# [- r    until you decide to write them. After that, of course, the previous4 h9 ~2 u2 l: h6 U+ b! a- T, `
    content won't be recoverable.
' s2 k4 ~; B4 z1 I# G; @( e    The number of cylinders for this disk is set to 8322.
/ M2 d  x" h* c0 P* E, _5 H! _' s; _    There is nothing wrong with that, but this is larger than 1024,6 G2 H1 _' l2 |
    and could in certain setups cause problems with:9 j* P8 n, n$ m6 k6 r' U  v
    1) software that runs at boot time (e.g., old versions of LILO)) J. e  E' N  c/ V# r& A
    2) booting and partitioning software from other OSs5 L. I. N/ ~1 d$ G
       (e.g., DOS FDISK, OS/2 FDISK)* R% i- Y' ^& c1 Z, |
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
+ m1 T. Q" a5 u    Command (m for help): p) L- M( b2 w$ u- @8 @; K
    Disk /dev/hda: 4294 MB, 4294967296 bytes+ @3 r; J* X" e! U6 D) Q' G
    16 heads, 63 sectors/track, 8322 cylinders
1 i% P6 f# B2 M2 @0 |! h6 Z$ |    Units = cylinders of 1008 * 512 = 516096 bytes
) U8 P; X2 U9 W, k1 I- E       Device Boot    Start       End    Blocks   Id  System
2 K- y1 I  |- \; E: N$ ?    Command (m for help): m
; g$ s" n0 p; x2 u0 P! i    Command action, x- [! p* B5 f+ P
       a   toggle a bootable flag0 n. u% I1 h9 a1 N0 Q
       b   edit bsd disklabel3 G( p) f5 Q9 f, G* g2 v1 d! D
       c   toggle the dos compatibility flag
( _1 S% E" n( J3 l4 o       d   delete a partition% E# E# u8 b: \+ u% |
       l   list known partition types
6 V& A& P5 r& S9 g3 K) f  c       m   print this menu. ]6 n$ {  D4 J7 \" r# K
       n   add a new partition
$ X, R. }3 u" e3 l) ^3 W$ ^# {       o   create a new empty DOS partition table
6 k, E6 |) }  ^; E6 h       p   print the partition table
1 k0 o, Q. t4 w6 E" }- w& }3 t       q   quit without saving changes7 O$ ], {: P& d0 M. }: r1 W; W
       s   create a new empty Sun disklabel! e: w) j, }/ ], H- D# f
       t   change a partition's system id
: v! [# M3 l: r3 d       u   change display/entry units) v' h( ?: I7 e! f0 ~$ e8 W9 M
       v   verify the partition table* j2 |$ f2 O5 j% k. _2 a+ v
       w   write table to disk and exit
( Q, u2 ]! p9 E4 M" K       x   extra functionality (experts only)0 N3 D1 ^  c" Q3 D7 D$ d
    Command (m for help): n6 b8 r) p1 @- b0 v1 x/ ~% D
    Command action* V9 V9 S% D/ C! y/ K5 M
       e   extended
2 c. K9 \& U* H2 y$ @' X0 l4 v/ r% u       p   primary partition (1-4)7 F/ H9 k" T. Y& S6 ?5 d$ Z& q
    p
, w) h" ]( w; K7 U7 n$ }    Partition number (1-4): 1
7 Q" ~  D% ?( L* d6 C    First cylinder (1-8322, default 1):
' V3 ]  ~% q$ K2 z7 K- D    Using default value 1
5 l. t1 x0 i1 t; A' _6 k7 w' X    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
! r1 Y: g' A6 R4 w: h. a" `# M( y    Command (m for help): p7 P0 y8 i& i1 m& u+ _# C" S
    Disk /dev/hda: 4294 MB, 4294967296 bytes% |5 O% w% W' [8 z" J5 R) {5 Y3 t
    16 heads, 63 sectors/track, 8322 cylinders
7 G! C+ S& J- n: E3 m2 {    Units = cylinders of 1008 * 512 = 516096 bytes3 `+ D) e  J' a2 ^% L1 C- @
       Device Boot    Start       End    Blocks   Id  System1 s! @/ ?$ V) U7 d, v
    /dev/hda1             1      1000    503968+  83  Linux! ^  L4 j! @: q7 M0 D- f
    Command (m for help): w
& R5 ^3 X9 A& w, p    The partition table has been altered!+ W! y3 T3 b# T" y" D9 `
    Calling ioctl() to re-read partition table.) ^" x& X, t! t8 o3 W8 S
    Syncing disks.7 n: g0 \2 F5 C; f# O
    //格式化新分区
% T* s. d3 r0 A7 d" N+ |( h6 [
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)" W7 H1 M- x& `+ d4 Y
    Filesystem label=: e) e( x8 O! k9 Q" e  c4 i& T* L
    OS type: Linux* U0 Z2 ]' V) Z. o$ l
    Block size=1024 (log=0)
+ T+ ~) x+ Z! R, L  l    Fragment size=1024 (log=0)$ j( M. `8 G" `* q
    126480 inodes, 503968 blocks' M2 h4 P& B6 L" V" C6 e
    25198 blocks (5.00%) reserved for the super user
: t# g9 y) v+ j  v    First data block=1
4 N2 W# g$ u* h/ S9 p2 }    62 block groups* \/ [4 ~  l% s/ n
    8192 blocks per group, 8192 fragments per group* z7 v  q2 E0 H% a
    2040 inodes per group
" {/ F6 L. k4 Q3 Q/ p# r: F    Superblock backups stored on blocks:
! Y0 m& m% \: n            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
; `. Q) ~+ k4 ^    Writing inode tables: done                           
2 {$ F5 h) Y9 p. i    Creating journal (8192 blocks): done
1 p3 u" j/ e. G1 t8 }) L) w4 a! ?    Writing superblocks and filesystem accounting information: done
  o1 I0 p9 r8 q$ o    This filesystem will be automatically checked every 30 mounts or
5 b: k: R% W" L% }9 U    180 days, whichever comes first.  Use tune2fs -c or -i to override.8 L8 `% e* K+ J  ?/ o( I. Q
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
2 M5 _1 W1 m1 V, ^$ T    /dev/sda3              3723848    705992   2828692  20% // g2 W5 r( R& d& \% m
    /dev/sda1               101089      9274     86596  10% /boot
7 r; T3 s4 ]% C; T: x    none                     14520         0     14520   0% /dev/shm5 j: X- O' h* T% V% K3 s# J
    //挂上新分区( H* ]; ^" i5 b# R. y$ p* \* x* X
  1. mount /dev/hda1 /home
    ( I" X, `" h* Z" T& n$ v
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
0 L0 n/ R  ]# Y: B/ N3 O' M    /dev/sda3              3723848    705992   2828692  20% /
; }" G# \  S8 e" U( T* q# S4 {/ A    /dev/sda1               101089      9274     86596  10% /boot
) S0 \# ]' ]. f9 `% o& g* T    none                     14520         0     14520   0% /dev/shm8 a7 z, i" |  f/ U3 i
    /dev/hda1               488006      8239    454569   2% /home
5 e) ~4 c3 [" K! |) _: R' V6 _: [8 U) O3 o' V! k" g& L& s; l, _/ b
自动挂载:6 j3 Q) w; M/ l9 b2 E
  1.           vi /etc/fstab* A, ~! M/ u( I; a3 h. h3 |0 v
  2. - C# S4 m# D2 i3 D/ s# R- r
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    2 a8 t' C( t/ n! n) w$ Z0 n3 U2 I& Q

  4. " s! }, a# M! n0 t9 J. c/ _( G
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
# E) a' P8 u& u' G
  1.           mount /dev/sdb5 /mnt/ljp1  d6 p% s- s* [

  2. + w6 a& F* b' V+ E6 m
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

, g. d, m0 l1 z' K
7 s, C9 G& F" Z% X; b3 `( g, @& \- {5 g' Y" d3 P" K0 q
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-9-10 04:42 , Processed in 0.006073 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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