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

 找回密码
 立即注册
查看: 2746|回复: 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)" l  j) H& [5 t4 {
      or: fdisk /dev/sdc  (for the third SCSI disk)
/ }4 |! j2 ~5 K      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
7 T7 y9 E" B; Z0 h2 e: y      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
- Y3 ^9 B) i7 G4 \      ...  c0 R) E7 A/ `9 Y
  1. df -k
    ! [" n) W8 q' X" @
  2. df -lh
    8 |% w7 v/ Y9 _6 I2 P3 U+ {7 p
  3. 查看有几块硬盘:fdisk -l( l8 |+ v4 g1 g+ ^
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点7 k8 j# G/ I/ A2 f
    /dev/sda3              3723848    705968   2828716  20% /$ }9 x$ j) g' @$ y3 o# _7 Q
    /dev/sda1               101089      9274     86596  10% /boot. I. m! A6 `7 K- x5 ]) i
    none                     14520         0     14520   0% /dev/shm; P# M- f  ]: o3 @6 `6 G
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用5 U7 G8 q3 Z3 ^
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
; z# Y. q# o1 v. e  Z' @    Building a new DOS disklabel. Changes will remain in memory only,5 W' Q- W3 @. q
    until you decide to write them. After that, of course, the previous8 ?7 T" [, A5 q+ o7 U& o
    content won't be recoverable.
: n0 q+ t( A! @- e' q    The number of cylinders for this disk is set to 8322.
* ^+ \: ?' _) n3 w* d4 F    There is nothing wrong with that, but this is larger than 1024,
3 i. V) J9 x) P) `    and could in certain setups cause problems with:8 o6 b# y: l) y. Y5 {  f( }
    1) software that runs at boot time (e.g., old versions of LILO)
1 E; P9 w& Y) ^4 E- G; H, C    2) booting and partitioning software from other OSs
7 K7 A7 @; x8 ?2 m       (e.g., DOS FDISK, OS/2 FDISK)8 G1 C7 m: d$ N" t
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
' o( H0 h/ ^& A0 i, K0 j4 {    Command (m for help): p7 |/ N* ~1 a/ c6 e( {* A0 P
    Disk /dev/hda: 4294 MB, 4294967296 bytes
9 X* P* M( ^0 W: T- ~% t    16 heads, 63 sectors/track, 8322 cylinders  o3 n3 b( k$ `8 @
    Units = cylinders of 1008 * 512 = 516096 bytes
- z: r: Q1 {, Y4 v1 }       Device Boot    Start       End    Blocks   Id  System
/ W) N5 M9 w/ c8 k    Command (m for help): m  V2 N, b. [4 S
    Command action0 r9 H+ U5 G: h
       a   toggle a bootable flag" n8 u6 }$ s9 E4 \
       b   edit bsd disklabel
- s7 A! q0 p8 o( l! C       c   toggle the dos compatibility flag
9 c0 I  r9 ]6 p) E) Q       d   delete a partition
7 z# E/ r) s# B6 n" L       l   list known partition types
/ a$ N7 a0 I' G0 ~       m   print this menu
, Q# R: `4 x8 m' Q+ q9 h       n   add a new partition
7 R5 |6 z7 }" N! D8 g8 i       o   create a new empty DOS partition table* ~; E0 M: V% g! f) @
       p   print the partition table2 ]+ M8 I2 S$ Q6 t. A2 u0 W& ?
       q   quit without saving changes
' I+ x% E  k; R0 _0 w       s   create a new empty Sun disklabel& r, F" K, R4 V# z6 b  X
       t   change a partition's system id
/ Q/ D- {8 y6 D' k       u   change display/entry units
: S+ y% h* L7 a; v       v   verify the partition table- n' ], z% S8 E' c
       w   write table to disk and exit$ A0 c1 I: V$ v  R
       x   extra functionality (experts only)
8 W- p" `  r8 p7 k1 e    Command (m for help): n* h( M5 G  [( X* |. r
    Command action
6 r' V* w- r7 n7 s8 w       e   extended  j4 W1 A& p3 s# y/ L
       p   primary partition (1-4). Y7 I8 V6 t8 v' S( }6 S$ _
    p% G9 }, O2 f9 E6 R  E# a9 j
    Partition number (1-4): 1/ _  k2 i) `+ C# d( h' D* m2 K$ n  I/ r
    First cylinder (1-8322, default 1): & N% z2 }  i0 x3 @4 Y/ r
    Using default value 1+ X3 d1 D* @$ e! g$ t& y
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
8 i( x" {2 g1 V& |    Command (m for help): p
& M1 G) @! M- E4 l- q6 e% @    Disk /dev/hda: 4294 MB, 4294967296 bytes
1 W/ l" Y; Z1 F. X' h" X    16 heads, 63 sectors/track, 8322 cylinders& m8 w) x. l6 }6 |# h
    Units = cylinders of 1008 * 512 = 516096 bytes- V/ U( v9 p- N! t
       Device Boot    Start       End    Blocks   Id  System
( X6 I& `7 [& U: \% Z9 Y" m7 P2 f0 M    /dev/hda1             1      1000    503968+  83  Linux* k8 ^  p) O9 Z( t
    Command (m for help): w# J' U+ n; p5 [, j- F+ N. g+ u* l7 k' J
    The partition table has been altered!; D9 ]# _$ ]# w: Y* \( S& N
    Calling ioctl() to re-read partition table.; `  m* u1 H7 I6 p" _# Y% U% n
    Syncing disks.
) J( Y7 j4 U! d' M7 X1 l4 P( _    //格式化新分区+ l) s1 Q  j5 u( n
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
& A2 U# i# ?" k( ^% [$ g! C    Filesystem label=3 D1 J0 [4 H  ~: N8 z
    OS type: Linux
1 r8 E) ?* \& K  l6 W; e9 c( v    Block size=1024 (log=0)
  C; g" _" _8 S0 i4 |! E    Fragment size=1024 (log=0)0 @8 A6 b: a4 ?" h5 R" S
    126480 inodes, 503968 blocks
, a0 Q6 L3 k$ Z- |7 f    25198 blocks (5.00%) reserved for the super user& A5 V0 J% v% w6 v' k
    First data block=1
% {9 O" g+ b' E( D; s4 @# c0 D3 ]    62 block groups( d+ ^& N# x' o7 k! _: g
    8192 blocks per group, 8192 fragments per group
$ F$ U& `9 d, x    2040 inodes per group
! v" t: S8 ?2 y1 S    Superblock backups stored on blocks:
) J5 r# v. F; `6 ^0 j            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014090 O3 l; u: W) b3 I" c0 b  s8 r
    Writing inode tables: done                           
% _( {8 \0 w( \3 j    Creating journal (8192 blocks): done
# j: ~9 u$ t5 I0 p  b7 E) B/ h3 y! K! P    Writing superblocks and filesystem accounting information: done
* m* Q3 s. h2 F8 G5 e- ]    This filesystem will be automatically checked every 30 mounts or
- u$ Z! l- R) w9 p! s& S1 f; A    180 days, whichever comes first.  Use tune2fs -c or -i to override.
5 B5 b3 ?" B/ ]4 N& u( A. x
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
( Y9 P* }, M) @+ U2 f3 ^, a5 V    /dev/sda3              3723848    705992   2828692  20% /5 p" l! p/ Y7 [7 x% o2 |
    /dev/sda1               101089      9274     86596  10% /boot
& Y* t& `  D% x) }9 u3 @( k    none                     14520         0     14520   0% /dev/shm
8 F- n3 H( P/ |    //挂上新分区
$ K1 o! V  a- s) U6 |' b
  1. mount /dev/hda1 /home
    9 L2 j' b- ?9 ?7 G; z! R) W
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点, y8 I4 m" f4 M" J$ ~* k3 w0 F
    /dev/sda3              3723848    705992   2828692  20% /9 _) p/ F3 M' r# v- I
    /dev/sda1               101089      9274     86596  10% /boot
. I/ S/ H+ m: `    none                     14520         0     14520   0% /dev/shm5 w7 L5 I/ M) `' `& T- v5 }7 s
    /dev/hda1               488006      8239    454569   2% /home) h& B& N  Q& t# p- H2 @
, @6 R: P; }0 q' U/ N
自动挂载:6 V; |; T3 K: y, Z  p# R$ C- E, L
  1.           vi /etc/fstab. a- F, h+ ]! B5 Z4 m" U# J

  2. / T  B; B! _$ C' Y1 R% ?& n
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0  s$ l' m5 ~+ s" I

  4. 2 H) z( w- m1 `# u8 N- K' X1 f
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:% t$ U- h5 f9 l. N/ q9 T' [% V
  1.           mount /dev/sdb5 /mnt/ljp1; B& h$ n) h* o+ y- Z! o( s

  2. ) u/ l2 z' e8 A1 x5 K
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

/ t0 N' D6 G& F3 E7 k: T! Z/ R* X* u5 K* N6 P2 t& c* L
( J- d* F5 P/ X9 }) Z* s& b
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-7 12:43 , Processed in 0.036264 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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