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

 找回密码
 立即注册
查看: 2572|回复: 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)$ u7 c- w/ _3 D
      or: fdisk /dev/sdc  (for the third SCSI disk)4 {, v; v6 {% Q/ z9 S5 O7 \
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
+ y) M. n+ y0 v3 I- g  y      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)( \' r/ D% r0 c8 @2 \* P* Z/ K( R
      ...' ?- e- Y2 {% e8 u' w  n
  1. df -k
    6 L  ~& p9 p, ]9 z+ d
  2. df -lh9 R6 s: m, W$ ]: y# Q1 i+ a
  3. 查看有几块硬盘:fdisk -l
    7 u, _6 z0 I/ x1 m
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
+ X, W- l- m/ a$ g- R' ?    /dev/sda3              3723848    705968   2828716  20% /( `8 q# W! T; n  T  F& D
    /dev/sda1               101089      9274     86596  10% /boot# P# M1 ?! D8 @0 I/ T
    none                     14520         0     14520   0% /dev/shm8 P" ~( A% I% U6 d* F/ }$ U. w
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用( M% Y, v5 x4 G' R0 j
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel7 H* o  d& ]2 h* n( Z2 p6 j
    Building a new DOS disklabel. Changes will remain in memory only," {- R5 H+ u) q6 ~/ _
    until you decide to write them. After that, of course, the previous, @1 m7 D+ w7 P
    content won't be recoverable.
' g6 H9 c8 `1 r' F8 y$ }    The number of cylinders for this disk is set to 8322.
" O! ^2 a! t2 v* S    There is nothing wrong with that, but this is larger than 1024,
9 u$ d7 k6 R. }. n    and could in certain setups cause problems with:
3 {  t  S8 V$ G3 {* W7 k# W, T    1) software that runs at boot time (e.g., old versions of LILO)
8 B/ a, h6 o% f! b& M    2) booting and partitioning software from other OSs
: P: u9 V$ J* r       (e.g., DOS FDISK, OS/2 FDISK)
  D# B9 x, |$ s5 A    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
3 T7 u2 M5 {5 v( A5 W    Command (m for help): p7 Z! Z1 l/ f, T( F. s5 ^
    Disk /dev/hda: 4294 MB, 4294967296 bytes1 f3 \6 A4 J1 C& f& J7 r
    16 heads, 63 sectors/track, 8322 cylinders
4 g8 m, P3 @( C( M    Units = cylinders of 1008 * 512 = 516096 bytes3 a; |0 o; o4 x! }+ h8 m9 V5 N
       Device Boot    Start       End    Blocks   Id  System
- \$ T% r; n" l( Q1 S6 `% [, c    Command (m for help): m8 G& a) v5 ?( ~3 u2 C, k
    Command action
+ Q. k/ V! |/ G7 `6 m5 {+ e# s" d       a   toggle a bootable flag* m% ~  w! X- b+ j
       b   edit bsd disklabel
' `! G0 t% ?- n6 ?6 n: A! e8 L; X2 E       c   toggle the dos compatibility flag
3 g# D( k& N  K4 n       d   delete a partition5 q# R: k% o2 Y- `3 d' \
       l   list known partition types/ I5 }: s$ |4 M3 c
       m   print this menu
! v% S! k- a& T$ Y  J' G; ^- k       n   add a new partition0 i9 x: |5 I  B+ `. T  E, S/ G
       o   create a new empty DOS partition table% Z9 @6 F6 v8 T  j# l
       p   print the partition table
, Q( H; |4 L) E$ _       q   quit without saving changes
1 i* t# V9 q5 U2 Q       s   create a new empty Sun disklabel8 v+ V2 V9 @- P% y1 L5 L
       t   change a partition's system id6 B  t+ j3 b; r; Z
       u   change display/entry units" F7 y# Z+ S; n
       v   verify the partition table8 x. e- t3 W8 }9 b' w6 X
       w   write table to disk and exit
; V4 B; h1 r( _% S  Q       x   extra functionality (experts only)
5 Y$ X, P: t3 B" H) s3 m    Command (m for help): n
. `! B/ l+ x$ R, l# Y2 r    Command action
4 i' u' l+ |1 G! U. m6 Q       e   extended8 W) w6 V6 q  A* D6 P' x
       p   primary partition (1-4): V! X6 i* n$ M4 S" H
    p
6 t+ ]6 h% G: ^" y! L    Partition number (1-4): 1
# q: c0 I5 m% v) P    First cylinder (1-8322, default 1): . L& Y5 z6 }$ D1 }* Q
    Using default value 11 H4 V' V  o1 g& t1 y
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
. {% O: G7 F! S! G( C    Command (m for help): p- K* y2 x0 J; c" f; b& I
    Disk /dev/hda: 4294 MB, 4294967296 bytes
3 k$ {/ }6 [- C. j5 |  _    16 heads, 63 sectors/track, 8322 cylinders8 V6 ]; ?4 X, U+ F$ v1 \
    Units = cylinders of 1008 * 512 = 516096 bytes6 A# m) N6 E- h
       Device Boot    Start       End    Blocks   Id  System
. ]  V! i/ t+ |    /dev/hda1             1      1000    503968+  83  Linux
2 L. F  y( _9 [9 |    Command (m for help): w
2 N" \2 o2 c3 x: b/ `    The partition table has been altered!
* T6 E6 N) Y' ^- |" p" w# Y) T    Calling ioctl() to re-read partition table.7 H) }) J7 ^$ M
    Syncing disks.! ^3 M! \- L" D' v6 T( A: z
    //格式化新分区
7 {4 _. W) R+ M
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
7 _4 o7 ^+ g  b    Filesystem label=
  z" m* H" V1 o0 P    OS type: Linux" B2 V2 r3 M+ _/ C2 u7 I$ O  K
    Block size=1024 (log=0)
- I9 q6 V- D1 a7 D5 R    Fragment size=1024 (log=0)8 M( V1 A$ F) A  @4 i& q
    126480 inodes, 503968 blocks, [+ v3 W- H- w9 W+ ?3 t
    25198 blocks (5.00%) reserved for the super user
: X0 g8 I: T. }: y! c    First data block=1
8 p' m- d# c& |! R7 k    62 block groups, o/ F1 c7 W3 U. q6 `4 x4 f
    8192 blocks per group, 8192 fragments per group
0 L3 |. d1 f- [0 x    2040 inodes per group. G; j0 d% `1 I8 _
    Superblock backups stored on blocks:
! j% V9 i1 C+ n$ l' }            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
/ r9 {8 @6 }7 e! |; {2 q5 H    Writing inode tables: done                           
) v4 t' p( P8 U+ I/ x    Creating journal (8192 blocks): done
) o: @; s; M1 `8 T    Writing superblocks and filesystem accounting information: done2 E, h6 G2 Q4 S& C! M8 \7 a
    This filesystem will be automatically checked every 30 mounts or
4 ]! F! }# U0 S4 N$ T    180 days, whichever comes first.  Use tune2fs -c or -i to override.* w/ s8 v, u5 B) i4 ~
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点/ Q1 b* K2 F& R( f
    /dev/sda3              3723848    705992   2828692  20% /
' P4 ?, B7 z. _$ u5 B3 f    /dev/sda1               101089      9274     86596  10% /boot
7 q  V5 v) R' [: }" I    none                     14520         0     14520   0% /dev/shm
1 p  Z! ~& t1 J; e2 W    //挂上新分区
- x* V1 E* E* v* S, d1 m+ [" P  s
  1. mount /dev/hda1 /home
    ! a/ p* z1 }' I1 D5 {1 [2 F4 U; K
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点! k8 P( y! _& f* ?( H# ~
    /dev/sda3              3723848    705992   2828692  20% /
. d/ f( L) S/ `2 q/ ^    /dev/sda1               101089      9274     86596  10% /boot# }- Z7 K+ m. }7 b: ~8 `1 F
    none                     14520         0     14520   0% /dev/shm
2 n6 e6 Z# G/ z$ g: ]1 P; t8 B    /dev/hda1               488006      8239    454569   2% /home
1 E$ @5 r# i* T! @
; J$ T3 l! ^4 n; M自动挂载:% f* ]) W9 P# `+ s9 w1 j
  1.           vi /etc/fstab. d# x; u! f' G2 p2 M
  2. ( m7 X" o9 y8 p% P
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 04 H5 _& ?4 c2 q4 m" W! z4 S

  4. ( a6 v0 d4 K8 m- J+ c
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:& d) O! n& }8 D' [+ U' R3 y) ^, ?# V
  1.           mount /dev/sdb5 /mnt/ljp1% I- Y& i" ~+ C8 O9 G
  2. # J) S. B* @& H0 G* w
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
; E- K, w# C3 T  z$ f
- h4 g6 ~2 W. p# ~8 [+ [+ |  N# Q

4 R& u9 K. b" @
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-19 20:24 , Processed in 0.045335 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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