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

 找回密码
 立即注册
查看: 2575|回复: 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 g; k  x( g7 x  k  t      or: fdisk /dev/sdc  (for the third SCSI disk)& O9 R; G; o& h0 |
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
3 `7 r, t  ]) X$ S- }- n- ^      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
; a# Z1 {4 V& j+ c+ x: `- a      ...
# s* p2 @4 a5 [9 A: h* e
  1. df -k7 M- l$ [% L$ K/ d  b+ z* ?$ Y
  2. df -lh% y2 B& `. d' U0 h3 m. a+ h# A
  3. 查看有几块硬盘:fdisk -l9 G/ O( t+ Y9 B2 l' E6 y
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
9 V" r7 C' d6 c. [0 C: v5 r( p8 y    /dev/sda3              3723848    705968   2828716  20% /- v" C) g0 X2 x; a8 `- o% b# w
    /dev/sda1               101089      9274     86596  10% /boot
: H* ~. _" H1 I/ Q    none                     14520         0     14520   0% /dev/shm
4 F- _' x: A- M  i: D    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用; \* T* i8 p' J8 `% `
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
2 l8 D) f5 N4 |* A    Building a new DOS disklabel. Changes will remain in memory only,
7 e) ^: Y: D4 C1 T7 d0 R    until you decide to write them. After that, of course, the previous4 O7 z2 s% g( p, \3 A2 _1 m
    content won't be recoverable.5 @3 p" W: r9 s1 ?* k6 V
    The number of cylinders for this disk is set to 8322.
: _2 `* O' r! q2 b" v    There is nothing wrong with that, but this is larger than 1024,' d: g. {; }0 G8 ~3 b
    and could in certain setups cause problems with:
: x4 V# a& c( H# I* J; l- V9 h    1) software that runs at boot time (e.g., old versions of LILO)
1 ?6 O" z6 E/ q9 j5 ~" z    2) booting and partitioning software from other OSs
* N9 |4 s  z' g( o5 v! J* v       (e.g., DOS FDISK, OS/2 FDISK)
/ T, n; a7 i, u  p. ?    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)& ~' }+ e) M6 W
    Command (m for help): p
+ Z) U0 Z4 d5 h+ @    Disk /dev/hda: 4294 MB, 4294967296 bytes% s1 t) Y3 R6 e* J
    16 heads, 63 sectors/track, 8322 cylinders
! Z9 q+ Y4 d. n& c( C    Units = cylinders of 1008 * 512 = 516096 bytes/ r+ X/ h& F' i2 i, t
       Device Boot    Start       End    Blocks   Id  System% v4 b1 }# s9 m  b' M
    Command (m for help): m
% e' {- P' @5 q0 O# ~6 P    Command action! V6 K2 a( i) V( h  l( l
       a   toggle a bootable flag
" R' |. o0 Q) L       b   edit bsd disklabel  t6 n. ~8 a( w3 N, }
       c   toggle the dos compatibility flag8 v  B4 ~; Q1 n
       d   delete a partition
- {  G' H8 Z" p1 `& @/ k       l   list known partition types% P# S8 {8 A/ y2 V; Z
       m   print this menu
# h. x: t6 S9 \2 M; n$ J       n   add a new partition' @& r5 @7 ^- _/ I4 g
       o   create a new empty DOS partition table
0 s9 g( O+ f1 f       p   print the partition table
& a* U5 |1 T6 g8 P& P6 W, c       q   quit without saving changes
. c6 p) l0 |; {. B       s   create a new empty Sun disklabel
( h; n6 P! [+ }, p- L       t   change a partition's system id
$ b: a% f8 y3 ]       u   change display/entry units
4 g, f( r% f) G+ V' i. \1 n       v   verify the partition table
5 {+ v6 t. ?9 k       w   write table to disk and exit
9 k/ v3 X. U( d/ l/ q       x   extra functionality (experts only)
! ~+ H  L$ ?3 d0 W& U( z    Command (m for help): n
! ~/ s; J" ?/ |3 ~    Command action
) [1 @# V- s5 e. |& k# y' F" T       e   extended
: H+ g. z; Q. q0 f       p   primary partition (1-4)
) P' `/ D* v/ m) x! `% J. y! n& D    p! L4 K( N$ E+ K# \6 N
    Partition number (1-4): 16 o% J! ?0 s9 \
    First cylinder (1-8322, default 1): ( ]0 U; ^- X" A+ `% h. K
    Using default value 1
# c5 n5 Z* E1 Z* c. j# S$ R$ N    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
3 x/ x8 `4 H1 P3 E2 z6 ]    Command (m for help): p/ U" q$ m. {/ ]. |6 K. D2 e
    Disk /dev/hda: 4294 MB, 4294967296 bytes  C: Q0 ^0 U, ?& b5 [4 E4 m
    16 heads, 63 sectors/track, 8322 cylinders
# D. J( Z1 j. e    Units = cylinders of 1008 * 512 = 516096 bytes# B2 V' i! _% u% b7 n
       Device Boot    Start       End    Blocks   Id  System: r$ U4 J. y% M" z1 ~
    /dev/hda1             1      1000    503968+  83  Linux
& P# V3 K* w) e& ]+ R( N  j+ Z# I& ~    Command (m for help): w, w- |' `  r7 W( u
    The partition table has been altered!
. R6 @! [7 o: P% \+ S3 h9 t    Calling ioctl() to re-read partition table.
3 j  P  M3 c/ z, c+ w    Syncing disks.
8 R( V2 u# }- E    //格式化新分区. {' Y  v5 Q3 a4 i! \- t: a
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002); d1 p' \2 S; e. H3 A, B
    Filesystem label=3 e# \. t9 c- y$ y8 e$ E
    OS type: Linux7 }; z, b  k: f. F% W, b# f
    Block size=1024 (log=0)
4 V: Q/ @# N: @    Fragment size=1024 (log=0)
  t* w, ]# Z! C% f    126480 inodes, 503968 blocks
) R+ |1 D  j  T9 r: F% N    25198 blocks (5.00%) reserved for the super user8 s, G) D; ~# o' w
    First data block=1- \7 L5 ]  \: C
    62 block groups
. F) q2 ]9 Y0 U+ E5 v    8192 blocks per group, 8192 fragments per group; N# }& D5 l0 e( r" V$ ]4 _2 U& m
    2040 inodes per group  i% z* O# r3 c3 }- @1 y8 p
    Superblock backups stored on blocks:
+ a0 E3 x9 y% |. R3 ^, N            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409* p1 J' d- y( f( v1 B# d. \7 y
    Writing inode tables: done                           
- [: l7 s# m% x5 y) e5 o    Creating journal (8192 blocks): done% p6 H( P0 J% }8 S5 P( i
    Writing superblocks and filesystem accounting information: done. b5 m) ~( F1 e3 z. O3 {
    This filesystem will be automatically checked every 30 mounts or% e  _6 K/ k( O/ I2 }
    180 days, whichever comes first.  Use tune2fs -c or -i to override.* g6 Q5 F6 n! ~# k8 N5 }/ o
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点, D# q2 o0 B0 k  K
    /dev/sda3              3723848    705992   2828692  20% /  ?) Y5 c2 M# \+ m# |& }
    /dev/sda1               101089      9274     86596  10% /boot- B7 r( ?) s* z0 @! V
    none                     14520         0     14520   0% /dev/shm; p2 C* i% l' t4 S( S( d1 ]
    //挂上新分区
# O" K- j1 a) d2 s; B, E
  1. mount /dev/hda1 /home
    0 ?  K+ E/ g0 U0 [4 J
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
9 P, o) L% u$ ~7 s$ p    /dev/sda3              3723848    705992   2828692  20% /  ?7 e, `4 s* @# @$ l% j1 H- |
    /dev/sda1               101089      9274     86596  10% /boot
3 e" Q3 X/ }* m( z! t$ b  X9 F. C    none                     14520         0     14520   0% /dev/shm
8 S0 O. @+ F* ^+ G( \& h    /dev/hda1               488006      8239    454569   2% /home4 A! u( W/ R% A
+ ~, g! q- G! _4 a5 u6 B
自动挂载:
& l2 ^) r( {" h( O! w
  1.           vi /etc/fstab
    7 w6 l" h0 j3 @9 n- a9 p: G0 q
  2. $ j/ P2 G' d3 y+ X
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0  `& l% ~  f$ B/ z" e

  4. . C% [  q% ?1 y' f. @+ V
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
' t$ G8 N+ P3 x: H
  1.           mount /dev/sdb5 /mnt/ljp1
    5 a# s5 Z9 F4 a
  2. * T8 x9 ?" L& q( J
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
* m1 o$ V$ J$ V+ a6 K5 Q6 Z
. p  v1 V; E; K: F
% `6 L" R# Z# I; k" v, J
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-20 14:48 , Processed in 0.016115 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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