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

 找回密码
 立即注册
查看: 2790|回复: 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)
5 b6 V- N; L' e' m9 v  m4 Y      or: fdisk /dev/sdc  (for the third SCSI disk)
4 B0 {2 c) Z* N8 N; |! J, g: V      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
- h) ~" N2 L3 b( I" E/ ]- Q# ]      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
6 D& `# B2 U6 J3 h      ...
, `1 d9 y1 Q' {+ S: s# y# K
  1. df -k0 v- W/ H7 p. |" q- ?4 A
  2. df -lh
    5 o* M( w0 |4 P/ t
  3. 查看有几块硬盘:fdisk -l
    6 O. J: X$ j; {; N1 v" ?# Z
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
+ [# A4 ~5 Y( q7 _    /dev/sda3              3723848    705968   2828716  20% /' u! G, n( o2 F- D
    /dev/sda1               101089      9274     86596  10% /boot
) G0 b4 ~( Q3 F2 }; {' ~2 D+ G    none                     14520         0     14520   0% /dev/shm% w! A% q) f2 v2 }" o
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
* C) V3 m1 V( H1 z  W
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel. I- ]( t9 w- m6 `  E
    Building a new DOS disklabel. Changes will remain in memory only,
( S& J, I/ O7 E$ j; J    until you decide to write them. After that, of course, the previous" p+ t0 @. m: `- X
    content won't be recoverable.
. j1 [( N6 k; R' O* |$ D% a8 m    The number of cylinders for this disk is set to 8322.& b4 J  i% t* C9 |
    There is nothing wrong with that, but this is larger than 1024,
! x, S7 F3 s2 m    and could in certain setups cause problems with:
9 p4 \1 D" s1 ?; b    1) software that runs at boot time (e.g., old versions of LILO)
4 g" [$ _4 k- Z/ z9 N    2) booting and partitioning software from other OSs: w/ w; B% C, u( I* p. H
       (e.g., DOS FDISK, OS/2 FDISK)  v5 Y: m& P7 W  b1 j& W8 V
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)( Y( s0 P4 z9 K0 _6 |
    Command (m for help): p
7 f* x. c2 w0 S, Q& U; g  P    Disk /dev/hda: 4294 MB, 4294967296 bytes
1 k, l' h) \* T    16 heads, 63 sectors/track, 8322 cylinders7 I* a) J" S1 \% `0 A& s! i
    Units = cylinders of 1008 * 512 = 516096 bytes# m! I/ g' j3 n
       Device Boot    Start       End    Blocks   Id  System* w- p7 B+ {+ W" f1 q" U! E
    Command (m for help): m
7 O6 L5 k; x4 H    Command action
) m) t* V2 G# `! e/ l       a   toggle a bootable flag
. }# t0 X2 |" J" Q6 }% j       b   edit bsd disklabel
" q, O5 C% }% J3 i       c   toggle the dos compatibility flag2 A4 ~8 y8 c( _" p: D8 n, e2 Y
       d   delete a partition, ?! O$ R0 U2 S: c5 l5 \
       l   list known partition types* ~/ g9 u3 H6 `" E8 |( n0 O' L
       m   print this menu9 i. u' U8 N/ s/ F+ m! c: D
       n   add a new partition
! ~6 ]$ H, u! f       o   create a new empty DOS partition table
6 p3 N3 C+ J/ l% Z: K, c) `7 ~       p   print the partition table- n3 a7 f( P7 [) n0 z& |
       q   quit without saving changes- V! Q. y3 R6 j
       s   create a new empty Sun disklabel$ O6 o% a. J6 S+ P8 T
       t   change a partition's system id
8 u9 [1 G4 F* a% d       u   change display/entry units. T! Y! a7 z( ~; O% F8 ]% J" U
       v   verify the partition table* |: x7 j6 o$ W" d
       w   write table to disk and exit
$ p  J, K: d1 x5 w1 a5 q( [/ n       x   extra functionality (experts only)
' I3 {& ?' U2 K: m: e2 L    Command (m for help): n
/ _# M. r5 @+ ~2 c0 h    Command action
1 a# b+ h& V3 h9 w       e   extended
% J; S, d5 w0 Z: |& k* w7 }       p   primary partition (1-4)
/ d5 Y% Q* e: z$ W. D: F3 h9 J8 ^0 v    p$ U. Y& b0 W4 y( b7 U; b* \
    Partition number (1-4): 1
% u1 E1 ^5 u8 d0 C    First cylinder (1-8322, default 1): ) z* m5 {* g6 d. v- a
    Using default value 1- [1 x2 c+ v9 h9 L* ~5 K. e3 \  S( G
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G- J. I" O  _3 C5 j. U' k+ g
    Command (m for help): p/ x5 U5 d- [& a, u/ t' ?5 w& h, ?  e1 R
    Disk /dev/hda: 4294 MB, 4294967296 bytes
5 A/ k+ m4 q: h! R( _  E    16 heads, 63 sectors/track, 8322 cylinders
. M  U% m& T! G: I    Units = cylinders of 1008 * 512 = 516096 bytes& g9 t2 {- }% b( H6 ?' x/ h+ Q! p
       Device Boot    Start       End    Blocks   Id  System' q/ g. S3 t+ t1 f5 D8 e
    /dev/hda1             1      1000    503968+  83  Linux
  m1 Q: z) q# I! O9 e; F, W    Command (m for help): w1 X1 B! W+ B& Q- g( q
    The partition table has been altered!
3 Q% {; _+ |- q" L' s' x    Calling ioctl() to re-read partition table.2 B; X4 Y7 I2 v5 M5 Z
    Syncing disks.! [+ s( w6 E: E. N& ]
    //格式化新分区
# g( g( R. d1 V2 ^
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)% ?9 z5 @7 K7 p' s3 D! |
    Filesystem label=% R- M; u5 m6 o5 w1 `% H# l
    OS type: Linux5 Z: R2 m; {( z+ b
    Block size=1024 (log=0)
& @' S- t3 O0 v: ^    Fragment size=1024 (log=0)
+ n# }; d& Z$ E- E9 V$ J    126480 inodes, 503968 blocks
% @$ h: E/ z- V' i/ Q    25198 blocks (5.00%) reserved for the super user+ A0 k$ }2 T4 r3 o6 o( n5 a+ m
    First data block=1% V# X0 v' c* l' D1 w7 I- e
    62 block groups3 P6 g  W6 j0 V5 }: Y" J( S# T( a
    8192 blocks per group, 8192 fragments per group; p7 T3 D) J& c7 w, T) j
    2040 inodes per group
# z1 Y4 Q) |( K8 c    Superblock backups stored on blocks:
2 Y- [9 a; v+ P# K            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409. w, _8 x) v6 l" [8 t
    Writing inode tables: done                            / {- h' k. L$ @$ T
    Creating journal (8192 blocks): done) C- W4 q* g0 w; ^8 }5 x) n4 C
    Writing superblocks and filesystem accounting information: done
* ~9 U( g; ~5 c* Y; r    This filesystem will be automatically checked every 30 mounts or
; A( N# a  O0 ?/ p    180 days, whichever comes first.  Use tune2fs -c or -i to override.
) L0 m+ S; y, k, m# s6 @/ N0 w: a
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点0 C5 o8 J* r! n- [
    /dev/sda3              3723848    705992   2828692  20% /
; _# n# {7 R% B" ^    /dev/sda1               101089      9274     86596  10% /boot+ s, j* I5 D$ H* \+ t- E5 m
    none                     14520         0     14520   0% /dev/shm4 r' A; V* r  X4 U- f% b! @
    //挂上新分区' A& j3 B1 P& d! D0 K  }
  1. mount /dev/hda1 /home  |- G9 ?$ i& T( ^  v3 p) D
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
2 T8 x" n& |; Y. |    /dev/sda3              3723848    705992   2828692  20% /% T4 k1 ?% y3 d# _
    /dev/sda1               101089      9274     86596  10% /boot
, p1 ?: @7 e& z. r    none                     14520         0     14520   0% /dev/shm
! t' \0 _& Z$ S  _" Q    /dev/hda1               488006      8239    454569   2% /home: k: S( N( L+ q0 B4 w2 X. s
+ U- i# B" f# S7 E7 r  o2 ]
自动挂载:
; m4 X& d) E6 ^
  1.           vi /etc/fstab1 b: f7 R1 g8 k! C6 c+ Y

  2. # a  H# a$ n, @8 @- t! b% U
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0- D5 y1 n) G( L8 b9 H: _; I& J
  4. ! H+ m" P9 w1 {" v9 B
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
! W; |( P9 _0 L* g) K! Z5 V
  1.           mount /dev/sdb5 /mnt/ljp1/ l( r% \- X6 B2 C
  2. 8 h9 P; a3 T  t
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

/ I0 E' {; |+ K+ {) ~% p$ Y
' S8 u* B( k' H, t: ~* \) e( t: z+ F% m! B
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-15 14:10 , Processed in 0.029317 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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