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

 找回密码
 立即注册
查看: 2663|回复: 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)% q( x' ~4 f( ?7 g0 |0 L% x  G3 I9 Z
      or: fdisk /dev/sdc  (for the third SCSI disk)
! a! `' R$ m6 P" L& H( {      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)8 ?, b0 k7 C9 L# S7 a- v
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
$ _" f1 ?" a, n& e9 B/ C& A      ...
' @6 A: e4 J- C( I# C
  1. df -k
    : k8 H; t5 W7 Z  y6 p
  2. df -lh
    ; X; Q8 f; R4 a
  3. 查看有几块硬盘:fdisk -l
    7 V6 i- y6 ~; K. j$ E: h  d6 e1 Y( E
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点; w! z' Y6 {: W7 i
    /dev/sda3              3723848    705968   2828716  20% /3 E* p- A, ~- z* R5 l, Y
    /dev/sda1               101089      9274     86596  10% /boot% N3 [, a3 W) b
    none                     14520         0     14520   0% /dev/shm
0 U$ L6 d2 p+ h; L/ }% U    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
& \0 e  b* e& R/ x- U
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
3 Y5 J5 Z, u+ _  w( S: E$ k6 x    Building a new DOS disklabel. Changes will remain in memory only,* L. W3 p! j0 |
    until you decide to write them. After that, of course, the previous0 `) C4 ?/ E/ X/ \- _) _
    content won't be recoverable.# O5 C# ~* A& V$ ^" h
    The number of cylinders for this disk is set to 8322.
# H2 h4 n: \# j" N  K9 E: M% M    There is nothing wrong with that, but this is larger than 1024,
' S' e* T1 x/ f    and could in certain setups cause problems with:$ ^8 d7 F  h6 c9 N2 m
    1) software that runs at boot time (e.g., old versions of LILO)
, Q7 D4 ?/ F7 K" ], M    2) booting and partitioning software from other OSs
/ ^# _+ s# B; N* m! n, a       (e.g., DOS FDISK, OS/2 FDISK)+ I, Z+ t+ c6 W- h& C! |5 V7 n9 l
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)$ q3 U7 B' ?" E' d  g6 W
    Command (m for help): p
0 W) q" ?3 j/ J/ Q& u7 ~2 Y    Disk /dev/hda: 4294 MB, 4294967296 bytes
- C/ M# Z) y4 x- k$ F$ A8 p$ Q; p; Y( n    16 heads, 63 sectors/track, 8322 cylinders! _$ `$ j2 U- P3 N
    Units = cylinders of 1008 * 512 = 516096 bytes
0 ^# @; e. n& h- Z. Z5 e) v       Device Boot    Start       End    Blocks   Id  System
/ T4 M  G- _/ l+ A: O3 _    Command (m for help): m
* @* t) z: u5 y( x! Z2 A    Command action
$ O* c! _, ?0 l! F; c4 y       a   toggle a bootable flag
) K, W0 l& w! @* [- V! s0 x       b   edit bsd disklabel1 I! S/ }; A$ J( ?% U
       c   toggle the dos compatibility flag
* K3 b! G. n. e* T       d   delete a partition& u" p% p, I, n- ^* N
       l   list known partition types
0 z' ~* Y$ ^+ |: Z) D       m   print this menu
% J6 q8 p( r5 F' H- M  p       n   add a new partition
4 ?: d; l# o4 _8 B       o   create a new empty DOS partition table
- t0 V: P) o$ i       p   print the partition table: ~: {  `* o3 j9 |( x8 e, C% w
       q   quit without saving changes1 n. J0 M9 J. f* U# q6 k3 x
       s   create a new empty Sun disklabel
' N) ~5 {; P+ }0 ]9 b1 J7 [3 }/ Y       t   change a partition's system id$ E+ b2 E  k; X8 A$ L4 `4 d" b
       u   change display/entry units2 {  P) k3 Q: [! f3 y
       v   verify the partition table3 p& b+ A. W: D8 A  f
       w   write table to disk and exit
4 ^1 h- L, w; m+ O7 ~' s0 q2 \7 u       x   extra functionality (experts only)! T& @2 q- Z2 ?
    Command (m for help): n. l8 x+ X3 {& {$ z
    Command action
# ~# d, g, ^2 {" }) o7 f       e   extended& r- j) @7 j: B7 E$ K# R
       p   primary partition (1-4)
) M. {; n; z! N/ _/ D    p
: @0 _; W5 C& {- F4 h# Y    Partition number (1-4): 1
4 t8 f% L& q2 Q    First cylinder (1-8322, default 1):
! p. h4 R. i9 m/ c; ~& u, I4 G8 ]8 ]- V    Using default value 15 R- M2 a* L, e* ^9 A
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
# p; ^4 l* X6 D3 g4 Y1 F    Command (m for help): p1 N4 A& Y# s! Y: D) I, f
    Disk /dev/hda: 4294 MB, 4294967296 bytes) g. u" y  e8 M, a& Z
    16 heads, 63 sectors/track, 8322 cylinders. Z2 ?9 l( n6 H! U- R
    Units = cylinders of 1008 * 512 = 516096 bytes3 \, ~( |4 z5 c) s
       Device Boot    Start       End    Blocks   Id  System
- B; [; [9 @  X9 N- {9 g* ?    /dev/hda1             1      1000    503968+  83  Linux/ e+ B  u- ^0 x. y- G1 e! L6 ^
    Command (m for help): w
! T! ]$ Y+ `$ k- f* J* x    The partition table has been altered!
5 J+ A4 d3 ^; D6 f0 P) L    Calling ioctl() to re-read partition table.
0 `9 ^% ~' ?* V( v8 x    Syncing disks.
3 m( H( Z0 n/ y1 ?    //格式化新分区
6 H: [5 G; Z& z' x; e. R) K. |# A
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
8 ^/ Z9 Y; Y# N& h    Filesystem label=
7 ]& Y& g' r# z" v! R  p! `    OS type: Linux
2 z! E! T6 b9 \. A9 i8 z    Block size=1024 (log=0)
4 @& N* l+ ^* w' }) I. \    Fragment size=1024 (log=0)1 H7 v% [0 J, {- b7 g
    126480 inodes, 503968 blocks
* T1 |+ D, [5 T7 D0 Y  Z$ d    25198 blocks (5.00%) reserved for the super user
; I* t) c6 {. l9 f/ t$ d- G: w    First data block=10 d$ U. y) y" X4 Q" z# Y& M6 |
    62 block groups
& \- M) z  e  c; T: v1 Q    8192 blocks per group, 8192 fragments per group' k! q- ~# M. J' C3 I* V
    2040 inodes per group( Y$ [: K" Q+ n# H* D! h
    Superblock backups stored on blocks: : x3 u# `. ~2 S9 n: I
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409" F; N. A3 _5 }; b
    Writing inode tables: done                           
3 ]/ ^# `# B5 h+ |( Y; U( U    Creating journal (8192 blocks): done
6 n( M6 w# f3 E' U6 X) W3 m    Writing superblocks and filesystem accounting information: done; u# u* B) g) Y  H
    This filesystem will be automatically checked every 30 mounts or4 U" K! {; P" s8 X: k' B
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
2 w: g1 t: N  d5 m* V
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
6 Y) n+ [2 k+ |0 p, {    /dev/sda3              3723848    705992   2828692  20% /) _* i& x; y7 F& Z
    /dev/sda1               101089      9274     86596  10% /boot5 F% B4 j  I( v9 \: Q- }
    none                     14520         0     14520   0% /dev/shm5 f; P* a  [1 c
    //挂上新分区
- v, R" \3 f0 r$ b' n
  1. mount /dev/hda1 /home: D7 H3 F! F1 ]* Z0 p. @7 N
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
/ g5 A- d: Y) h( S5 u9 [' p    /dev/sda3              3723848    705992   2828692  20% /! i  t, _' o% D, g6 J1 g
    /dev/sda1               101089      9274     86596  10% /boot
4 C2 m9 Z1 i. p& a    none                     14520         0     14520   0% /dev/shm
" m9 Y( t% Y  w$ H    /dev/hda1               488006      8239    454569   2% /home' A; D6 N% D7 V9 ]3 m. i, o
9 H' l$ |4 Q6 r* r2 S) n: b, l" k
自动挂载:
& U( `7 W; {/ r
  1.           vi /etc/fstab$ `4 V& N6 |( a0 V) ~. M( @) |# \

  2. 3 T: A& r6 s. y4 o
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    4 {5 H2 i$ i. z1 I
  4.   M( V. @! |4 z* R5 o% c
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:9 s. r) n  g- V/ ~( q
  1.           mount /dev/sdb5 /mnt/ljp13 ~6 H4 g1 P: m5 c; S3 D
  2. 2 y+ V7 e0 u0 s) A5 Z, R
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

" }$ }; ?/ m2 D& l( ?# m7 `7 z2 C2 G7 }$ g/ b' l$ z
; R! x9 p+ L) j% O3 \
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-10 11:46 , Processed in 0.040362 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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