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

 找回密码
 立即注册
查看: 2570|回复: 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)2 g( C7 e/ R2 Q
      or: fdisk /dev/sdc  (for the third SCSI disk)
# f6 l! f. u5 M7 E+ P! w      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
% o' u: m$ r; R! w- C      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)5 j6 H9 z* ?/ q" @6 o/ D
      ...4 B* @) t7 o. H. b
  1. df -k1 h$ H" D& r' S
  2. df -lh2 B' h$ ^) a# j8 I3 r6 W, X6 [
  3. 查看有几块硬盘:fdisk -l
    ! L4 p, b+ q  A
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
4 _3 K3 p( j; d0 T3 Z% i    /dev/sda3              3723848    705968   2828716  20% /
5 a5 ~  h% ?: {4 N    /dev/sda1               101089      9274     86596  10% /boot. ?* }8 Q. n! C2 {6 X
    none                     14520         0     14520   0% /dev/shm$ A7 j0 G( |6 K+ ^' Z. C% c
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
5 G7 i$ E& P- {
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel  o# t7 ^$ \0 U# j+ J' l& A
    Building a new DOS disklabel. Changes will remain in memory only,
# r) W$ V: U3 I" @! K    until you decide to write them. After that, of course, the previous
9 z, t5 b( Y( B3 a/ f- z    content won't be recoverable.
. _" w8 s8 ~. w& P1 A    The number of cylinders for this disk is set to 8322.7 z3 h. w" l) X$ _
    There is nothing wrong with that, but this is larger than 1024,
6 F0 @" \4 W# h$ o' S! ?3 k$ d    and could in certain setups cause problems with:* R# y/ K4 @/ \, Q) k/ c( ]% s
    1) software that runs at boot time (e.g., old versions of LILO)0 u- K  L; n5 n5 x6 f; _' o8 S
    2) booting and partitioning software from other OSs0 d' Q0 ~$ ]- \/ l/ R8 j
       (e.g., DOS FDISK, OS/2 FDISK)& ^1 l& A3 T0 ~, n) n2 C( l
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)/ N: H, [0 W( R& t
    Command (m for help): p: {: }$ ?- V# F+ I
    Disk /dev/hda: 4294 MB, 4294967296 bytes
9 \" L2 M1 k6 i; |5 w    16 heads, 63 sectors/track, 8322 cylinders
/ ^( R7 H: v# s; v    Units = cylinders of 1008 * 512 = 516096 bytes
, C6 ^2 P3 ]  [7 t- H/ h       Device Boot    Start       End    Blocks   Id  System
. g& j8 N+ Q/ D" D  t6 N5 ?9 b    Command (m for help): m+ R: W3 |1 n3 n# T
    Command action
& o% `( {1 {* p6 j  p( e4 O" J       a   toggle a bootable flag0 E# Y3 _& J: p0 _( H
       b   edit bsd disklabel+ E% w, G+ i5 c5 k/ u' e
       c   toggle the dos compatibility flag- P+ [% I& n* ]) n# V5 \. x" V5 m- L
       d   delete a partition/ P3 \% V; v! {
       l   list known partition types: _+ C$ i* N$ C+ i# B7 f! D6 E
       m   print this menu
( U$ s0 n* M$ j, V) {       n   add a new partition( n! B& b" S0 T/ l) Q& p
       o   create a new empty DOS partition table* J2 n# {0 ^6 v$ b& l
       p   print the partition table* {2 N( z8 Q6 Y$ v4 A
       q   quit without saving changes8 g& c2 e  ?# l. C  |
       s   create a new empty Sun disklabel- b; R) d/ b3 K0 ?9 x8 N5 o* W% T
       t   change a partition's system id
- O- y+ ~9 X9 y5 l5 M1 v0 Y       u   change display/entry units0 G: |1 n$ T6 d1 j& T
       v   verify the partition table
8 }5 P) n5 m# y& _, w& k       w   write table to disk and exit
* J* L  G$ m( p       x   extra functionality (experts only)
. }3 J0 g/ k' s1 ]) D) [) K0 c    Command (m for help): n
9 \$ A2 p& T+ e/ x% U    Command action
7 ~2 J5 [( @' H- D       e   extended5 n% V* {0 M0 \; \2 y! o
       p   primary partition (1-4)" {" n7 n4 o& w* A% [$ G
    p8 T" g- t- m7 r6 B: r
    Partition number (1-4): 17 v& f" H$ [; T& @
    First cylinder (1-8322, default 1): * ?) U  |, |; p# @$ X
    Using default value 1
+ o3 j5 y; I  ?* B$ e; g: G2 X    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G* |2 b8 O$ Z8 ?
    Command (m for help): p
% z  g: M6 W/ d5 X* M4 w' c    Disk /dev/hda: 4294 MB, 4294967296 bytes, \$ B) P: l1 _6 d0 N
    16 heads, 63 sectors/track, 8322 cylinders
  `2 y; j# ?: [* E- \& e( D    Units = cylinders of 1008 * 512 = 516096 bytes- a/ h- U7 g% {' n, v: k
       Device Boot    Start       End    Blocks   Id  System
% V# m5 m% B; L! A% i, S: ^    /dev/hda1             1      1000    503968+  83  Linux5 y" s9 G. I+ m' M
    Command (m for help): w/ \; ^# ^9 K) q! S! g# I
    The partition table has been altered!# L# y/ h! H9 t1 t; @0 r  o
    Calling ioctl() to re-read partition table.5 F& q% Z; ?3 I9 h& M
    Syncing disks.* g& x8 V& [8 f9 @) o
    //格式化新分区0 f5 ?2 v. T( U9 @+ l! m2 u
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
: B3 r; k5 @; I! @    Filesystem label=
* h# w3 E  j7 ]4 V: W    OS type: Linux
# a% k# ~7 q# X) B. Z    Block size=1024 (log=0)
2 N: y( f1 ^$ Y" f; I3 ]1 e" G    Fragment size=1024 (log=0)
; [+ @) n, C. g2 u2 l; \    126480 inodes, 503968 blocks" g4 {6 E8 b1 f5 t$ g! h) ~1 q( R# j
    25198 blocks (5.00%) reserved for the super user, s: e7 p  ^- E: J/ j1 S. ]: O+ V
    First data block=1
/ Q# p4 k1 z) ~) ^* ]    62 block groups
$ C+ G6 r( A% K. g    8192 blocks per group, 8192 fragments per group
( L4 x/ T, d9 ~/ N+ a7 [2 F    2040 inodes per group( o( a7 z; u: M, W7 y+ }
    Superblock backups stored on blocks:   h- R% a! A9 Q
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
) `/ \2 B& \$ W' H& z; Y/ t    Writing inode tables: done                           
" H" `8 h8 R- ~4 {' N$ j    Creating journal (8192 blocks): done) T0 j0 C; `+ j8 n
    Writing superblocks and filesystem accounting information: done& i1 {4 z+ G" O' R/ f9 W! X
    This filesystem will be automatically checked every 30 mounts or
% u9 O# }4 W/ r4 G    180 days, whichever comes first.  Use tune2fs -c or -i to override.* x3 u2 J$ B& b1 o; ^+ I
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点8 s4 _$ ~' Z. s& C4 ^9 I' ?3 M1 n, I! s" }
    /dev/sda3              3723848    705992   2828692  20% /
* b- B2 [0 r$ p, [' p$ v    /dev/sda1               101089      9274     86596  10% /boot
: A- @# k; ?) T    none                     14520         0     14520   0% /dev/shm2 N5 O$ e) m  T. Q: K
    //挂上新分区9 U- v8 g* L/ j0 i  W$ Y" {& s1 z* f/ N
  1. mount /dev/hda1 /home4 E' L/ d$ [, r6 |
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
, {  o" \# l& B+ h; q9 y9 b) n    /dev/sda3              3723848    705992   2828692  20% /
3 V) f: S. w. v6 ]# Z" e6 ~    /dev/sda1               101089      9274     86596  10% /boot
  P  `. n# K( l: r4 H7 H  n$ N- R    none                     14520         0     14520   0% /dev/shm, u+ v+ b2 n+ L; \! T) m# |5 w
    /dev/hda1               488006      8239    454569   2% /home
, V+ J8 r2 [& h- C# c- V
6 o8 o( A; b8 n: A自动挂载:; x6 W) M( N7 |% G5 a- h6 z
  1.           vi /etc/fstab+ d" J, w0 {) U, W

  2. + V/ s7 r/ p* _3 h
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 04 Y) P2 D2 H1 e

  4. ' A2 e' |5 z2 l. k% s
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
3 m! @) ~% s5 a! z; g* P
  1.           mount /dev/sdb5 /mnt/ljp1
    3 ?9 l* K& T0 v6 b
  2. , F" q" |* i' V7 n( w
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

/ ^. A* y2 _8 Q7 G) p( l
* o$ \$ Y# n' w7 t
: F, m+ N! M9 U+ o, l5 J
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-19 03:29 , Processed in 0.008017 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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