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

 找回密码
 立即注册
查看: 2694|回复: 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)' J8 p! G( u; |) O9 X1 x
      or: fdisk /dev/sdc  (for the third SCSI disk)
" L8 X$ S4 ~2 J0 t# C      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)2 |; C1 S$ o4 w5 ^$ H8 S
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
* e$ X2 X3 E3 q9 C9 Y& \      ...( f1 N$ f; d+ t
  1. df -k* I9 ]" _: @1 w5 V! h% m9 O; F
  2. df -lh
    6 j" Y: V2 }6 s% E& f7 T
  3. 查看有几块硬盘:fdisk -l% n0 N0 K/ b# v& ~# |. }5 t
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点; `$ N% [1 C/ C" }- k
    /dev/sda3              3723848    705968   2828716  20% /' x, E- f2 }& f) q6 d! A# g
    /dev/sda1               101089      9274     86596  10% /boot& h* D6 U+ I# r: I8 d9 p5 ~
    none                     14520         0     14520   0% /dev/shm
5 h3 |. l8 S$ q    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用6 H% u$ B9 o1 V6 l; v; h
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
1 P4 a' d7 |2 V7 Y' Z    Building a new DOS disklabel. Changes will remain in memory only,+ j4 B' C9 {+ V; q
    until you decide to write them. After that, of course, the previous
7 W2 Z* f3 t: H) y5 l/ F% h    content won't be recoverable.2 u* v+ l1 q9 |
    The number of cylinders for this disk is set to 8322.
0 F$ T, }+ I9 C5 H' J1 i9 G2 P6 X    There is nothing wrong with that, but this is larger than 1024,
& D! d: ?0 \3 C/ E* H3 T    and could in certain setups cause problems with:
" p! h" p& }7 }' f; B: d8 ?9 S    1) software that runs at boot time (e.g., old versions of LILO)
7 v& p. e5 f6 ]    2) booting and partitioning software from other OSs
! A. \/ V8 m9 b* ^) l: G       (e.g., DOS FDISK, OS/2 FDISK)  o- X" L1 I  b5 M5 `* h
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)$ N. L% F' T1 o0 Z! I! N! @6 s
    Command (m for help): p
) S8 ^( ~2 O8 n; v5 z/ @& T% E    Disk /dev/hda: 4294 MB, 4294967296 bytes
+ s6 D8 Z- H! }2 k8 M. T2 e/ ?    16 heads, 63 sectors/track, 8322 cylinders& ^, l  w2 s2 [
    Units = cylinders of 1008 * 512 = 516096 bytes) U( ?/ S( y( D, `9 P0 M8 r9 M
       Device Boot    Start       End    Blocks   Id  System
5 D, w4 ?8 j: T+ t    Command (m for help): m9 A% T2 P  q' V$ R# O: X+ ~
    Command action
2 D; M/ N& ?8 }. m1 ^* w# V3 g       a   toggle a bootable flag- y$ o) P# l' \! k5 c6 I: M2 d' k
       b   edit bsd disklabel
* U6 n. J! m% j8 M- d       c   toggle the dos compatibility flag
5 P6 H' J  W1 w9 v$ L. C       d   delete a partition6 @/ x7 F* P' n) l
       l   list known partition types
) [, n' l2 `, E5 e       m   print this menu
( ]5 ]  n3 g& U5 I) o3 |       n   add a new partition; y3 K# [: ~( k! N- v3 i/ L/ w
       o   create a new empty DOS partition table
: E# r2 e+ y5 l' E$ c( P       p   print the partition table, h8 B) y4 v! A, N) O$ J
       q   quit without saving changes
& E/ u0 I; b, ?: |: e' F5 I& _       s   create a new empty Sun disklabel+ o3 Y6 y, Y$ F& a, `0 _# N+ c
       t   change a partition's system id9 d4 m: T% q7 }9 P. K6 s) h
       u   change display/entry units
  u( _" B  _2 S1 G6 k7 Z       v   verify the partition table: V5 U7 O+ i) @
       w   write table to disk and exit' |  p0 u3 s7 c
       x   extra functionality (experts only)
1 d+ g" }: R2 D! R0 F! j    Command (m for help): n
4 M  Z3 K/ c9 y% X6 q# p& ]5 {! \    Command action
( z  i1 W3 S; x1 `* a6 z       e   extended" I( J- g) W9 {& W  a
       p   primary partition (1-4): U6 w' |0 n8 q
    p
2 {% O$ M" H" S1 P7 j5 ~    Partition number (1-4): 19 P' j4 N& i9 S1 }2 w
    First cylinder (1-8322, default 1):
  W& u  R0 k5 @8 ^- A0 c: a    Using default value 1: D6 M5 W8 w! }
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
/ h& I. m6 P) N6 d2 ]    Command (m for help): p
" N& _5 J5 k6 x- E$ w# n    Disk /dev/hda: 4294 MB, 4294967296 bytes9 c* n& T) e; O2 M- L
    16 heads, 63 sectors/track, 8322 cylinders
0 ^4 E& a1 r; F; c: n) i% E' k3 C    Units = cylinders of 1008 * 512 = 516096 bytes
. i6 C+ ]  {' g% q! e! X6 g$ u       Device Boot    Start       End    Blocks   Id  System5 M# L$ B5 p- E
    /dev/hda1             1      1000    503968+  83  Linux2 M7 `2 ^7 b+ |; m$ ?5 X2 {
    Command (m for help): w* i! Z4 ?  N; r8 S
    The partition table has been altered!
" G1 F- |+ Z  r/ w5 `    Calling ioctl() to re-read partition table.6 c$ Q. I2 y, s: o, J
    Syncing disks.
7 x$ {1 x8 f% S. s- t% P1 j    //格式化新分区4 n; ]% G: V7 S8 l
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
; r' _* X- ?+ q- J* a8 [    Filesystem label=
- j6 G0 y1 i8 g( O3 N) ~3 A    OS type: Linux$ S$ ]$ ~3 q) e+ U: Z. h& g- N
    Block size=1024 (log=0)3 W' e( S9 E4 z; N) {8 X& {5 k- b
    Fragment size=1024 (log=0)
$ I6 V. k& Z  o5 {    126480 inodes, 503968 blocks% F8 W" S3 Z. ~/ h! U; Y
    25198 blocks (5.00%) reserved for the super user
. H0 W2 P$ {* k8 L5 J) i9 l    First data block=1
. j0 n+ ~1 m$ z! |    62 block groups" |9 m- Y$ D' S* f& X
    8192 blocks per group, 8192 fragments per group5 m* X+ R0 A0 ^& ^' O8 Z
    2040 inodes per group
7 i" b1 K: {5 D1 Z3 M    Superblock backups stored on blocks: # i7 g; |) h# x& D% `& C
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
8 E3 ]- E. f' b) X' K$ \    Writing inode tables: done                            7 `  A1 [. [1 a+ r( D, F& y( W
    Creating journal (8192 blocks): done
! G+ c; N: A- b* d! ^; p9 f8 N5 K    Writing superblocks and filesystem accounting information: done
. R" K5 `* M) a' o' ], }/ w8 C    This filesystem will be automatically checked every 30 mounts or
, W% }0 \0 \# T3 p4 Q" E* z    180 days, whichever comes first.  Use tune2fs -c or -i to override.9 G* ^  E: I; B7 L5 D. l
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点$ Z# t2 `8 l& o: q5 f. h# U
    /dev/sda3              3723848    705992   2828692  20% /6 o& N8 b8 B) d6 u8 I# X* m
    /dev/sda1               101089      9274     86596  10% /boot0 ?7 p- Z& a$ d1 {, p) C& o
    none                     14520         0     14520   0% /dev/shm
) ]5 O& S: q3 l4 g4 k6 E* m    //挂上新分区
9 {4 N+ J/ b/ K
  1. mount /dev/hda1 /home3 }, w$ X0 f/ d$ d: q& H6 g" D! J" T
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
8 s: z; [) _8 R    /dev/sda3              3723848    705992   2828692  20% /
4 S$ b3 ?9 @+ }; a. {    /dev/sda1               101089      9274     86596  10% /boot! T2 q# J' ~5 u) |9 m7 ^. k
    none                     14520         0     14520   0% /dev/shm
1 j- D/ ?% z. L/ W    /dev/hda1               488006      8239    454569   2% /home
8 x( _, t8 f; V) y8 i/ E! I: C3 E1 |. h# [/ U/ g% T* r: J/ `
自动挂载:
$ K8 A9 d. b  v' W0 [; }' B) w. a; a* \
  1.           vi /etc/fstab4 i- \8 j1 e! W) {" |

  2. 2 Q7 p3 @1 [9 c) F3 J+ Z' O
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    1 ]: S8 \) d7 z' S! v; v
  4. . \1 ?9 ?7 Q- W5 E9 [0 Y
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:$ M1 @' h, v; ^  X
  1.           mount /dev/sdb5 /mnt/ljp1
    " S( p7 ]( E8 B1 B; ~
  2. ' j3 p+ f+ T  J. s! \. a
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

+ X. Z5 m+ I+ t4 D7 f: Y
/ O: V. G5 J; L1 i/ c
4 I% o% B: C7 ^: c6 r+ h
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-17 06:10 , Processed in 0.016888 second(s), 10 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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