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

 找回密码
 立即注册
查看: 2601|回复: 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)
% q5 T- C/ `. K/ V# h3 m      or: fdisk /dev/sdc  (for the third SCSI disk)
7 d- n/ E/ k$ K1 |$ q0 y; w      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
( H! ]* a% `, c8 @- r( D; n7 S      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
& a. k7 g; l% P) ^# S, Q      ...
- S: c: B9 R3 ]7 m/ B
  1. df -k
    % {# A, ^4 e; o2 r7 x
  2. df -lh" z9 V* U: L+ |
  3. 查看有几块硬盘:fdisk -l. ?8 t' \6 D- d+ k" ^2 x
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点- q* Y3 s# r) j3 c  N
    /dev/sda3              3723848    705968   2828716  20% /
' W1 d9 u; C+ G1 q    /dev/sda1               101089      9274     86596  10% /boot% r- w5 G& n2 u6 C2 x
    none                     14520         0     14520   0% /dev/shm
: J% ]5 z0 v5 B) n    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
/ D" ^+ D1 l+ E7 W% {0 O
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel% f0 k- R/ o# z4 @  W% N
    Building a new DOS disklabel. Changes will remain in memory only,; a) s: z, d- i# X* Q
    until you decide to write them. After that, of course, the previous& G( Y8 P5 l1 r( h5 N% B. I
    content won't be recoverable.
& i4 X0 E/ _+ o7 Y! [9 D" n    The number of cylinders for this disk is set to 8322.! |0 E3 u1 n! Q) v, |2 I' R
    There is nothing wrong with that, but this is larger than 1024,
0 [1 K, I, {0 `! L1 E$ b    and could in certain setups cause problems with:
, i; [! I- G$ h0 F1 I! {4 O2 `# J( c    1) software that runs at boot time (e.g., old versions of LILO)
) x/ f6 ]3 W% [0 ?" T: ]    2) booting and partitioning software from other OSs4 v: ]4 ?! ]2 y, B% I1 H" |
       (e.g., DOS FDISK, OS/2 FDISK)
  e8 g& G  l4 |3 x' ]& ?7 M8 u    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
% k  L6 W) _/ [+ x    Command (m for help): p0 r! A0 X% z* i7 h0 I' }# U- {3 R
    Disk /dev/hda: 4294 MB, 4294967296 bytes9 k, w$ Q* {* y# k3 l
    16 heads, 63 sectors/track, 8322 cylinders1 o+ t: F! K1 R
    Units = cylinders of 1008 * 512 = 516096 bytes
' |* a. Q8 ^( h  @       Device Boot    Start       End    Blocks   Id  System
2 m+ [+ s# ?! V3 c# ]# x. N    Command (m for help): m
/ L/ i) e( d; k6 z7 S% c    Command action
/ R. C% s: R. Q( u5 P4 D* {       a   toggle a bootable flag1 i- h4 u( B# e
       b   edit bsd disklabel5 B$ j% A$ [/ L1 @% G
       c   toggle the dos compatibility flag
2 z. Y" e9 J. W/ A3 m       d   delete a partition+ N1 f$ a; k+ t. u0 N5 [" S5 R- Z
       l   list known partition types7 _- m. h! h' R/ i+ N
       m   print this menu
6 ~. q4 a$ C( b" b" h  v4 }% D) V, O       n   add a new partition
  Q4 c3 [, n( O6 \6 k       o   create a new empty DOS partition table
. k$ |9 h  L# I  b" r; Q( ?  O  W       p   print the partition table
4 M/ F( Z% C, h( A# F       q   quit without saving changes
2 V4 D9 i, K2 Y) j       s   create a new empty Sun disklabel0 Y: Z0 ]5 Z$ M
       t   change a partition's system id
9 \# V3 n7 w! N, {) a3 z       u   change display/entry units2 Y4 ^6 k- b4 z4 Y% _
       v   verify the partition table5 B( H3 m# o/ c; D
       w   write table to disk and exit
7 g( C; a$ P+ n2 W- g! n9 k: u% _       x   extra functionality (experts only). R$ V# B" }% d  q
    Command (m for help): n; l9 N3 r) [' T$ J# J
    Command action
, Q8 r) g/ C, J( G7 x" j! u  q       e   extended
, t7 B3 U! g; M" z) _0 h       p   primary partition (1-4)
1 w6 z3 p& P/ |: b/ S" W7 {    p
& `" l, Z8 y5 n    Partition number (1-4): 1
5 G- x' D. O* C! ?    First cylinder (1-8322, default 1):
( W1 U7 j1 T( f. f    Using default value 1
# i# c# @3 U" P5 w( s    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
8 }8 @( W! ]# g; j2 }    Command (m for help): p- [! K  [3 c6 m. d
    Disk /dev/hda: 4294 MB, 4294967296 bytes6 N# i8 T1 T4 R! a
    16 heads, 63 sectors/track, 8322 cylinders
& `) \+ f+ U. D$ }: [1 z7 H$ m    Units = cylinders of 1008 * 512 = 516096 bytes
( C$ S! r5 G5 `9 W: k       Device Boot    Start       End    Blocks   Id  System
/ w/ X/ r2 S9 L) F9 I    /dev/hda1             1      1000    503968+  83  Linux
" V0 ]7 `% B0 C2 I  `6 c    Command (m for help): w
! h. J0 W+ S1 b1 G2 K( O% B    The partition table has been altered!# Q6 Q& W# a' C0 l" v
    Calling ioctl() to re-read partition table.
) h1 `. K- K( p: X+ e    Syncing disks.! z0 b2 ^0 z& m$ {* s+ P
    //格式化新分区
5 R6 X& G: U# H- f- b
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
9 t% p0 G9 ?+ C0 p- [1 R    Filesystem label=
5 D0 d3 U4 q4 ~+ g8 K" O    OS type: Linux9 ]  K. y" \0 A2 k- M. h" h9 Z, R9 |
    Block size=1024 (log=0)
- ?4 H+ `  a  O8 P    Fragment size=1024 (log=0)
4 I- Y* P8 W# C0 t# p    126480 inodes, 503968 blocks
' `# p5 g0 N5 c3 R: ^( v& f, d$ e    25198 blocks (5.00%) reserved for the super user
0 O+ M; V5 D+ I+ n% b    First data block=1
- D6 v8 g# @9 x: R  K    62 block groups
$ @( j7 z) o: ?$ {* D    8192 blocks per group, 8192 fragments per group
- H) Z4 [, L, I" q6 o2 n' i) q! H) X( S    2040 inodes per group
. P9 w$ m1 F% G: z3 h    Superblock backups stored on blocks:
) a+ w( v7 z' B( V6 P; b            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
) p2 r1 J- A* S& \5 _( v7 b    Writing inode tables: done                           
/ W7 J8 m/ l5 Q9 s' P    Creating journal (8192 blocks): done
; F  Y* a0 y  ?    Writing superblocks and filesystem accounting information: done0 Z8 Z1 u! Z) _8 z1 f* `' M& e
    This filesystem will be automatically checked every 30 mounts or; o: F  ~/ q/ _* Q3 l, `0 p7 b4 L
    180 days, whichever comes first.  Use tune2fs -c or -i to override.1 O2 Y- V' w( K; d2 C* U- o
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
& L9 M7 x6 w, S4 [1 h# p7 x2 n$ q    /dev/sda3              3723848    705992   2828692  20% /
- J7 s8 o1 G9 f8 d    /dev/sda1               101089      9274     86596  10% /boot; M  L- U7 h0 C7 g) K
    none                     14520         0     14520   0% /dev/shm
$ N4 L4 Y0 o5 C, V* h# ?% Q    //挂上新分区
( i% M) v. b' X; U: e
  1. mount /dev/hda1 /home. Z3 R8 J5 W! n) H  v
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
9 O1 v3 x# ~% A6 |) O. T    /dev/sda3              3723848    705992   2828692  20% /
1 _3 y! i) j1 v6 [    /dev/sda1               101089      9274     86596  10% /boot
7 e4 w1 J3 z9 B- q    none                     14520         0     14520   0% /dev/shm
$ y: q- M8 R+ M$ i( \6 M    /dev/hda1               488006      8239    454569   2% /home
+ O, j* `( i* u" G9 W! |) {& ^. P1 i3 u
自动挂载:7 O. ~- T- z" s) b
  1.           vi /etc/fstab
    5 N! O% F  b6 l/ t2 o: u

  2. " t. t, \. [/ W) G9 f& Q- \9 X5 e
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    : e' x) v8 w1 ^; p
  4. 0 C6 G) U5 S3 q  U. v/ }$ ?
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:" ~$ K* K* q  m5 X7 a
  1.           mount /dev/sdb5 /mnt/ljp1" s4 L$ m" v1 T: s' b  r

  2. 8 d4 Y5 y% Z/ I6 A
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
! U6 n# z( X: s' c4 Y

0 J" l& e# ?  g1 H2 q; Z. R6 [4 d5 K/ A, |! X4 a) I
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-27 04:33 , Processed in 0.016334 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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