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

 找回密码
 立即注册
查看: 2809|回复: 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)
9 c# B+ I/ {# {4 ~5 H      or: fdisk /dev/sdc  (for the third SCSI disk)% {5 n- L9 f3 H/ K2 P) }
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)% B3 E. P/ _. }- ^: ?
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)! b/ f5 I2 F( l4 P" ]' r
      ...1 L5 X' `7 S( Z  E* T
  1. df -k8 \9 q4 j8 N. S& d
  2. df -lh
    7 m. _( k' I' h7 }
  3. 查看有几块硬盘:fdisk -l
      T% g* P* ?7 B9 Q
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点1 G$ P' k! f. o/ M/ _6 C$ A
    /dev/sda3              3723848    705968   2828716  20% /
) y+ I8 x" H5 |% ]( D0 L    /dev/sda1               101089      9274     86596  10% /boot" R. ~" }* `9 {2 J5 W+ q
    none                     14520         0     14520   0% /dev/shm
8 [/ T3 J% p7 \9 U7 C1 J    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
' \; \0 t; E6 u
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel7 p0 Q: a8 z& H  U% }7 R7 l* ~
    Building a new DOS disklabel. Changes will remain in memory only,
' J* [. s# B+ Y    until you decide to write them. After that, of course, the previous* N, C9 b$ l& l4 n) Q) N
    content won't be recoverable.4 ~- A; _# p& V: x6 b( B
    The number of cylinders for this disk is set to 8322.
+ V3 z" a) S) ~$ [$ \    There is nothing wrong with that, but this is larger than 1024,8 M5 `6 A/ b; J  r# a) {
    and could in certain setups cause problems with:
+ g2 ?" R4 J* J    1) software that runs at boot time (e.g., old versions of LILO)
! U0 S" B& L/ C1 b    2) booting and partitioning software from other OSs; `, i3 c* o- J2 m% \" h
       (e.g., DOS FDISK, OS/2 FDISK)
, G4 K- ~# n- k+ f3 ^, G    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)5 Y9 K5 H* y) D$ X4 I9 W, V( J
    Command (m for help): p
9 k% Z( @6 L" j& U2 @# v  S7 {    Disk /dev/hda: 4294 MB, 4294967296 bytes
. n3 r: h4 V) v. H: c2 u5 H# D% {% f    16 heads, 63 sectors/track, 8322 cylinders
! b% A+ r# \% K2 D3 `9 a8 H    Units = cylinders of 1008 * 512 = 516096 bytes# T; Q6 D. B% K& E" y: }- X
       Device Boot    Start       End    Blocks   Id  System0 l! w8 d5 a3 ~* N) X
    Command (m for help): m
: ]: @( J8 J$ t. [% D: \    Command action# a; K" T. n# N' k
       a   toggle a bootable flag2 _( Y3 ]/ a) Y& ?% f6 i* [
       b   edit bsd disklabel6 G0 `' U/ W$ |7 R0 n
       c   toggle the dos compatibility flag: O) z0 t+ |/ m8 x& D3 m7 }! f
       d   delete a partition
. B; g) A, _: }6 a1 F9 Y: \       l   list known partition types& I" f3 q8 C% j& f4 d* N
       m   print this menu/ A+ q" k1 o; H( U, @/ V, F2 ?
       n   add a new partition
; [1 _9 x9 l! G& K       o   create a new empty DOS partition table
) v1 H# \3 p5 [1 U7 w% Y       p   print the partition table
: s& P: G8 r- @: G6 I7 r       q   quit without saving changes+ v' i2 Z) T0 `7 ?, a
       s   create a new empty Sun disklabel
. n4 O3 G1 G9 E) ]! D       t   change a partition's system id: f' d' u& ~" e& x
       u   change display/entry units
& C* `! I, t+ b, Q, r/ i& A; ^# i: T       v   verify the partition table
0 q9 h1 ]: h" D* K5 e- k) H       w   write table to disk and exit  z( a4 E+ s0 [' @5 _
       x   extra functionality (experts only)
8 j+ t- f( _6 t    Command (m for help): n
9 g" V+ D1 B( z! S1 k8 l, o2 U    Command action$ q1 @& t+ p9 N% V
       e   extended
0 j" C5 @" S# f$ W8 A       p   primary partition (1-4)/ L4 m+ h  Q6 b8 U+ t
    p0 ^) \5 b: F8 h
    Partition number (1-4): 1
& V! D" a7 \5 K  w5 h    First cylinder (1-8322, default 1):
" f/ s2 ]7 @: `$ U- z" e, }    Using default value 16 N2 H( Z$ Z" _' Y4 q: L& `& b
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
- e" l- w$ o5 N' B- h    Command (m for help): p# {( D  o- v8 j) i$ Z) ~
    Disk /dev/hda: 4294 MB, 4294967296 bytes
% F# [4 p6 S% ~, _3 T" C* U* d4 R    16 heads, 63 sectors/track, 8322 cylinders2 n9 ~7 K) M6 J& ^
    Units = cylinders of 1008 * 512 = 516096 bytes
) _" ^+ h, b& m; H+ I       Device Boot    Start       End    Blocks   Id  System# N8 {% v7 M9 X# v9 a8 o/ ^# G$ \
    /dev/hda1             1      1000    503968+  83  Linux
/ J1 q8 K' w; T1 ?    Command (m for help): w' \! k; u( j# K+ K, V! p2 d! J& w
    The partition table has been altered!
* i" G; A% |% f& j2 `; n7 R    Calling ioctl() to re-read partition table.
( s- v" \: {* C! W" n    Syncing disks.
: M0 T3 D, S% v. a. t4 E    //格式化新分区
9 G$ b) V" k% s! L5 B
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)+ b  S  \7 W, Z* e' G0 J& q8 h" O) R
    Filesystem label=7 Z# S/ E" B) u
    OS type: Linux
: I; e$ \/ _6 E. u0 h7 j2 M; W4 `% E    Block size=1024 (log=0)
# _6 ~% H* m* d7 z1 U* ~( y    Fragment size=1024 (log=0)$ r7 F6 n: W( k6 L9 Z  h
    126480 inodes, 503968 blocks1 K8 M4 K% b4 u% N/ |
    25198 blocks (5.00%) reserved for the super user9 _9 Q+ n' p4 w+ @3 U
    First data block=1
7 |! W2 H+ _- M9 J. K! c! l    62 block groups2 x7 ^: k" u/ x7 X* t
    8192 blocks per group, 8192 fragments per group2 O  _# \, R0 p' i' ]  L6 R; q
    2040 inodes per group
3 c" v2 n. x/ s% v    Superblock backups stored on blocks: % \4 m' f" Y' d) `( @  [
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014099 k1 x6 N1 W# H3 Y$ X% p
    Writing inode tables: done                           
1 S, e' E& X; c. h9 @! z* B8 c# I    Creating journal (8192 blocks): done
8 o, N, O5 {7 z    Writing superblocks and filesystem accounting information: done
4 ?8 O0 S# V; z2 \. E" ?    This filesystem will be automatically checked every 30 mounts or6 H$ D7 Y/ I6 ^! _( c2 T
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
2 x3 `! d/ t2 k0 R/ d# }
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
1 r$ \7 p" K: H3 q0 f- X& ^1 [    /dev/sda3              3723848    705992   2828692  20% /. R$ Y5 E; ?/ Z
    /dev/sda1               101089      9274     86596  10% /boot
0 w5 Z* q/ }( V) @; V" m    none                     14520         0     14520   0% /dev/shm( a1 ]$ U. S' v2 [& a; b
    //挂上新分区
1 m! G7 r( [0 F, g9 w
  1. mount /dev/hda1 /home
    7 a0 z' T2 |6 M5 t
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
) }5 T! \" b7 i( {. F5 \    /dev/sda3              3723848    705992   2828692  20% /
! C" ]! l' E2 M$ I5 ~    /dev/sda1               101089      9274     86596  10% /boot  z# O2 i7 N7 d
    none                     14520         0     14520   0% /dev/shm
& `& _! P& q! c$ P    /dev/hda1               488006      8239    454569   2% /home$ u6 L- h9 n+ l: r8 q

; Y7 J% B+ Z4 @  a$ w自动挂载:( I6 ]. [: B$ t& F
  1.           vi /etc/fstab) j0 T, g* ]1 s$ \5 u/ h! T% I' d

  2. 5 `$ x+ F8 D) H; V# p& {. b% Y
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0  W- j* u9 |' H' e6 w& k

  4. . a' O6 O4 A' _' H* v
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
) V( _! {  P) T9 K2 ^- c( d
  1.           mount /dev/sdb5 /mnt/ljp1
    / r' T) `! h8 C+ Y. K" P% F
  2. $ K- Z- U9 \+ R: F* y2 t
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

# e3 h4 K  d. Y2 i+ L: ?3 S! n6 Q3 J4 m6 Y
8 x7 n/ _$ s7 l( L! ]- V
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-19 09:43 , Processed in 0.027071 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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