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

 找回密码
 立即注册
查看: 2269|回复: 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)
4 h! m7 [* V+ k/ [5 ]) N1 G) H      or: fdisk /dev/sdc  (for the third SCSI disk)5 f! G) u: i& s
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
. ]/ X' C) G: F& @      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)" D' S( B; ]/ E4 I* ~6 ^
      ...
/ M/ [4 K% d" T5 v" {3 j
  1. df -k  o2 i- d4 f4 Q+ d, p
  2. df -lh" L- m1 G# _3 J: \$ @# t
  3. 查看有几块硬盘:fdisk -l' ^& ^# n0 g# x( P, d
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
) m+ q8 h4 D3 @4 V# t" Y* H    /dev/sda3              3723848    705968   2828716  20% /& p+ Y" C1 X/ V/ H
    /dev/sda1               101089      9274     86596  10% /boot- N  y0 B+ Q3 J& R4 J3 }8 s
    none                     14520         0     14520   0% /dev/shm
3 k  o0 T2 b+ d    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用2 L0 d" P* I& I) R
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel1 s0 O% N- d1 r, @
    Building a new DOS disklabel. Changes will remain in memory only,
5 @7 X; o& s; `8 N( I( P    until you decide to write them. After that, of course, the previous2 ]& a% r' t. H* o
    content won't be recoverable.7 z% q8 o1 \3 I8 L) n' |) r& D
    The number of cylinders for this disk is set to 8322.8 q' y! C: e/ q$ {: g
    There is nothing wrong with that, but this is larger than 1024,
% D8 T# g$ |$ U    and could in certain setups cause problems with:
& _' C) l5 X+ e5 `    1) software that runs at boot time (e.g., old versions of LILO)% L; \) n1 \& N2 T( L* p8 @( ]
    2) booting and partitioning software from other OSs
4 e9 I3 F7 V# A4 h; X       (e.g., DOS FDISK, OS/2 FDISK)0 F+ w3 p, e7 {
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)9 g/ M1 s) h8 t, E
    Command (m for help): p* M4 D2 Q2 d6 b9 \" V  h0 ]
    Disk /dev/hda: 4294 MB, 4294967296 bytes
/ H$ Z  N( w( R3 @& E    16 heads, 63 sectors/track, 8322 cylinders4 B1 p  Y& y) r
    Units = cylinders of 1008 * 512 = 516096 bytes7 i% \1 o' x7 ~" U9 i2 g/ o
       Device Boot    Start       End    Blocks   Id  System9 ]. i, j; m+ |$ {
    Command (m for help): m6 S" @$ ~& U% p( P- S2 e* P
    Command action, P$ b3 {$ ~9 y! U
       a   toggle a bootable flag2 @( j' F4 l! u. c6 q, ~! {: l
       b   edit bsd disklabel
; G+ _- t& R& |       c   toggle the dos compatibility flag
# Q0 s! i* S' o       d   delete a partition
9 K7 X. z- ^% t% u       l   list known partition types
) a5 \, U! u$ F2 ^, d1 L       m   print this menu
. i9 B/ L& G) v7 O; ^       n   add a new partition: z) U7 P% N; F1 I! j' [( E
       o   create a new empty DOS partition table( @5 \) Q, T" \+ v! c5 t
       p   print the partition table
) o, O* x$ R* B- v% E7 P       q   quit without saving changes  C1 P. y8 I( ]+ a& F$ k3 f
       s   create a new empty Sun disklabel
& N6 |& M' s0 ?# \2 f5 V+ R  g       t   change a partition's system id; ^+ `/ o7 v& n$ X- \1 N
       u   change display/entry units
0 A9 Y- X5 [. n* l  e$ i" C       v   verify the partition table
6 a3 ]2 L8 C5 E% i       w   write table to disk and exit4 T' A" d; {/ ?7 U5 f
       x   extra functionality (experts only)* E$ ?# j8 r, D0 {
    Command (m for help): n
, m7 {* R% w8 M' V: i7 Z7 N    Command action! |2 E! x$ X) ~: ?5 Z) \+ S
       e   extended7 _4 j" I5 q+ b* a) @8 X6 t. i$ |4 q
       p   primary partition (1-4)/ o5 f. }2 ]+ L' m% m" n2 m' {
    p
% f* M/ w3 n+ {    Partition number (1-4): 1
" F5 k, o# {4 ]. M    First cylinder (1-8322, default 1): 8 x% n) v5 C# U3 \: c; r! u3 Y* ]8 ?
    Using default value 1
8 l# J) _6 Z/ u6 v    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
- K8 i: r) [! a5 S4 x7 A0 y$ l    Command (m for help): p; a3 S% T) Q/ c* D6 y$ Z
    Disk /dev/hda: 4294 MB, 4294967296 bytes+ Y5 {: _5 Y& g, X" X- t( R0 m
    16 heads, 63 sectors/track, 8322 cylinders
0 I' G5 x, C- @5 f    Units = cylinders of 1008 * 512 = 516096 bytes; W, e. Q2 E4 y7 K5 O) ~# t2 s
       Device Boot    Start       End    Blocks   Id  System
/ Y1 P9 {* x" A% {    /dev/hda1             1      1000    503968+  83  Linux
+ ], F6 o0 \( }( Q5 [  K    Command (m for help): w
. v+ m7 v5 F6 v    The partition table has been altered!+ J* R- Q9 E4 ^3 ^! j
    Calling ioctl() to re-read partition table.1 s/ F' Y2 x) l4 T. c
    Syncing disks./ B, _5 ?3 y3 k' l
    //格式化新分区& K7 D2 r( _; }  e5 o+ [: L
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)* A0 {' ]/ G2 M/ P% m
    Filesystem label=
, R) Y: E4 v8 T  ]    OS type: Linux
+ v8 {  C8 z7 L1 ~    Block size=1024 (log=0)& A. r. N$ j. F# v" {: u9 A
    Fragment size=1024 (log=0)% q6 Y7 E5 s( |! B+ t: b
    126480 inodes, 503968 blocks/ s: L5 d" D) {4 o
    25198 blocks (5.00%) reserved for the super user
2 R3 U, R& P2 U9 {( J6 B8 J! {    First data block=17 R- c% W* S2 L
    62 block groups
% o( V/ \& W$ [2 o" g    8192 blocks per group, 8192 fragments per group
* F) s  `& d8 b+ ~; G! v! g9 ^. v    2040 inodes per group6 E: G0 D: H& H- y
    Superblock backups stored on blocks:
' M; x, W* t5 }4 J8 j$ _            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
2 X% w+ p% \) c+ @5 g& u    Writing inode tables: done                           
# J! x- r; Y/ Y' C' Q/ I    Creating journal (8192 blocks): done, j! f/ f; S, k- A1 U& [
    Writing superblocks and filesystem accounting information: done
+ d1 N" f; ^8 E1 q    This filesystem will be automatically checked every 30 mounts or5 F( e, \( }8 A, |1 Z
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
! ?) _, M3 q* _+ ?
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
; t" a6 m' M1 N! u) `; n+ E    /dev/sda3              3723848    705992   2828692  20% /
+ }5 G) h) }! u  O) P6 c* R; A    /dev/sda1               101089      9274     86596  10% /boot
- _0 ^# O8 C- g. ^! n5 Z    none                     14520         0     14520   0% /dev/shm8 J' z- _! j1 j7 h
    //挂上新分区
8 f! L$ E) a6 |8 Y: H
  1. mount /dev/hda1 /home2 L9 q# X; [2 ~+ e9 x5 k4 M
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
9 A& E: s1 g6 ^$ a, m    /dev/sda3              3723848    705992   2828692  20% /% s. l+ W/ y9 C6 o% Q* z$ [& n
    /dev/sda1               101089      9274     86596  10% /boot
9 R& f4 W& b+ n* g! P    none                     14520         0     14520   0% /dev/shm
4 p6 J% p5 o+ q4 a  I; k' n, e    /dev/hda1               488006      8239    454569   2% /home2 X. D2 ^0 k: f3 x) F* U

+ R! A2 p- B# _0 w% g9 z自动挂载:" H; p( F# K' s
  1.           vi /etc/fstab% W9 x7 H% d2 I9 i: T& @
  2. 5 `& S# i: j: |+ n$ }6 k- E, k
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0  v% v: l  B/ O7 C* m8 I' F" E
  4. # p/ s) v3 ~  P4 G) L2 s6 n' d* a4 G
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
) b" H4 d7 \1 |6 T
  1.           mount /dev/sdb5 /mnt/ljp1
    1 z- K) I7 K5 R

  2. 6 `; [) [% b& M% W  G2 K6 k
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

9 w4 D6 }( r- k5 Z3 [. k1 b& u& h. ?# C+ }
7 x/ f. r# q  q7 V# ?) V7 M
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-7-31 09:36 , Processed in 0.033482 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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