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

 找回密码
 立即注册
查看: 2012|回复: 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)
/ w+ P, y7 b' C      or: fdisk /dev/sdc  (for the third SCSI disk)! c# y0 \, ^' ~
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
. ^3 V. O3 x* j& @/ t! |/ u      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
& e, G0 k3 j  I      ...) P" u9 w# F) l
  1. df -k- W# H' |( j0 X6 B
  2. df -lh
    1 x* k, N" l% K
  3. 查看有几块硬盘:fdisk -l
    % U, V7 P# F# g8 e8 w& v- p5 \
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
4 M. O" [* r: W4 p& U2 \, a    /dev/sda3              3723848    705968   2828716  20% /5 B7 j' x, J9 H( R, s7 x5 s& ]+ j
    /dev/sda1               101089      9274     86596  10% /boot
/ N. n' b! |, X- i; v: [    none                     14520         0     14520   0% /dev/shm
1 t# n5 g# f' q    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
) N) s2 L8 f* f4 h7 x" m/ I
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
# t2 D6 A' W, \    Building a new DOS disklabel. Changes will remain in memory only,
& w- A" i( ^9 n' E' |    until you decide to write them. After that, of course, the previous* X: q3 l. S; x: [8 _& j$ N( _
    content won't be recoverable.5 N: v& S" @5 a# J" {+ o* S) @$ S
    The number of cylinders for this disk is set to 8322.% Q6 H7 o& k9 T( C( ]! @- M
    There is nothing wrong with that, but this is larger than 1024,4 O6 S" k! b( [- y
    and could in certain setups cause problems with:
8 l% \+ X, g; |2 M    1) software that runs at boot time (e.g., old versions of LILO)
4 ^1 H& L# W& w7 f, g    2) booting and partitioning software from other OSs
! c% M. g0 x( h& L3 a       (e.g., DOS FDISK, OS/2 FDISK)! |! q4 y. l: o; H* L
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)0 J9 b) [0 }% x6 f# r
    Command (m for help): p" |' |) x2 ^9 h
    Disk /dev/hda: 4294 MB, 4294967296 bytes) m: g; S" z& k* e8 M6 h
    16 heads, 63 sectors/track, 8322 cylinders
- ?9 O/ b' v& r: O$ I4 R: a    Units = cylinders of 1008 * 512 = 516096 bytes
2 _' u. |& l* p       Device Boot    Start       End    Blocks   Id  System. I# L4 E  Y+ f
    Command (m for help): m
% H+ s+ U2 ^# g+ h* D    Command action) v; {8 N. S; U5 }2 I% W/ E' h
       a   toggle a bootable flag
* d- y* A' y; W! G3 x       b   edit bsd disklabel- v1 J( n# N: I2 W+ w
       c   toggle the dos compatibility flag
" B0 v8 c/ Y* d, d- a       d   delete a partition
3 u* p+ u/ a5 ]/ e) O       l   list known partition types
* g* n& O1 q+ N3 D* Y       m   print this menu
' S. k! R/ D: V; D8 M4 w       n   add a new partition  L+ w8 L- F2 p. s% F
       o   create a new empty DOS partition table
- W3 U; W# F3 B' Q% u3 q       p   print the partition table
: `$ d- A: c) c9 K* @       q   quit without saving changes
0 w/ g3 e; C5 w       s   create a new empty Sun disklabel
0 K# s. j# t+ [7 S/ n4 ]8 r5 V       t   change a partition's system id+ {5 W) V  |7 l  ]$ P. {+ w0 M
       u   change display/entry units  F: P! `: O! b1 Z0 T0 J& U
       v   verify the partition table! m9 Q0 {3 \1 S) {& [1 X# Z
       w   write table to disk and exit5 F& j% y; j4 K& N5 H- g
       x   extra functionality (experts only)1 Z- v( }) Y2 t7 d8 F) w3 _) P
    Command (m for help): n
- N, f7 @& D1 M( u    Command action2 u, `" H: @3 U
       e   extended
$ V8 r: i9 Z' B; S       p   primary partition (1-4)3 \- \. R" f( W7 j% v& q
    p
2 {3 _1 }: u8 E" H    Partition number (1-4): 1+ D0 |8 B( S! ?1 U$ }
    First cylinder (1-8322, default 1): + O2 ?& n* s: J6 M& [' E2 ]. V
    Using default value 1
" |( m2 c: p" Z# ^$ h' K    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
, t) [: P" {. U. C% h' p5 r    Command (m for help): p
9 ^8 D. b5 ^' I3 [9 C5 ]    Disk /dev/hda: 4294 MB, 4294967296 bytes: c& a6 K. W2 R% |- e6 u
    16 heads, 63 sectors/track, 8322 cylinders6 W& R, i+ N/ s& x- A( ?  y
    Units = cylinders of 1008 * 512 = 516096 bytes" D4 t; _8 ~  W, A" s6 h5 \
       Device Boot    Start       End    Blocks   Id  System! R5 I8 ~* O# U  g0 r% M0 R) w7 ]
    /dev/hda1             1      1000    503968+  83  Linux
, ^7 P- s* W- X$ h* R, h1 w* t    Command (m for help): w
2 c: ^6 w5 J( |* `$ {    The partition table has been altered!
1 s& q: E0 g- t# O8 k    Calling ioctl() to re-read partition table.
- ^  d7 ?" _# v, r, ]# d    Syncing disks.
! s- I! Z* _4 e& B) N4 c    //格式化新分区2 e! w6 R; U: G- a+ M
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)- |, g4 K4 _6 c$ J
    Filesystem label=
( w2 Q6 H$ o1 Y! E6 a7 t    OS type: Linux3 H! A4 ^( H/ L7 A
    Block size=1024 (log=0)
, \$ F' G# m1 D, I5 ^2 Y    Fragment size=1024 (log=0)
; J" W2 a/ s  U- V    126480 inodes, 503968 blocks
/ A* {0 W" k2 Z* `% B( L    25198 blocks (5.00%) reserved for the super user
$ L" b  h9 V# [* ]4 U. V    First data block=1* |9 F4 t4 U" l
    62 block groups
8 R& }. L6 F) L% @    8192 blocks per group, 8192 fragments per group7 p+ C  J! H2 n9 K
    2040 inodes per group
8 @2 |+ a8 u0 y* Y- F9 M$ H0 c" Y* H    Superblock backups stored on blocks:
( y: k4 K# @% C, E4 ?; E            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409' n' d2 `6 Q7 m  ?9 F/ u6 M
    Writing inode tables: done                           
% O8 V9 y/ R1 l+ U    Creating journal (8192 blocks): done3 @7 [3 C5 s7 l; H  j: o9 k
    Writing superblocks and filesystem accounting information: done5 q+ {& M& m' x) Y3 K; W
    This filesystem will be automatically checked every 30 mounts or% X! r% J, [* T( p9 ?' _" D
    180 days, whichever comes first.  Use tune2fs -c or -i to override.! E! A6 l# H, y( n' U3 L4 Y: {8 a
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
) G4 W  ]+ P+ j  D- t" A. R" N. k    /dev/sda3              3723848    705992   2828692  20% /
6 {; K2 ?5 X8 z$ a    /dev/sda1               101089      9274     86596  10% /boot' z9 Y# Y4 B) o, U
    none                     14520         0     14520   0% /dev/shm. ?( }6 O! J. R$ @
    //挂上新分区
9 H1 h# H2 ^7 O" \) a9 X
  1. mount /dev/hda1 /home
    : S. O' {* {$ R& G) l
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
4 W. K5 h* L" F; x! B& \- @/ o( e3 Q    /dev/sda3              3723848    705992   2828692  20% /
6 C2 C0 z) }6 V5 x: m( B+ Y    /dev/sda1               101089      9274     86596  10% /boot5 i# H. K+ w0 @1 ^5 ^$ ]
    none                     14520         0     14520   0% /dev/shm2 v9 r8 }9 j( A% h
    /dev/hda1               488006      8239    454569   2% /home) Y! a7 w& U) T$ s! h& Q
, u$ L- T+ B: {/ S0 p) x' r- g( n, I! ~
自动挂载:
1 h" ?8 u) @- N4 c3 A4 r. K
  1.           vi /etc/fstab( i1 _0 Q- ]7 W

  2. / N% ]0 m; D) O- i% S+ v
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 01 G$ C# {* t/ h; g5 f$ m

  4. % d2 m5 D7 U0 z
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:% c' @1 y/ B4 q# O
  1.           mount /dev/sdb5 /mnt/ljp1+ E) Y. n2 m- V$ Z- e+ Z( l6 u

  2. ! ^2 V  V% w  r9 a# g
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

/ a0 V; d, B7 f; e' X  g
: p( i' M0 |' t* ~& G9 E* `$ E
$ f& H7 N/ K$ w0 b$ M4 ~' g
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-10-18 14:35 , Processed in 0.012014 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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