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

 找回密码
 立即注册
查看: 2103|回复: 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)7 E9 u: y' E: f2 V+ n% e( U
      or: fdisk /dev/sdc  (for the third SCSI disk)
; W0 T( K9 K- }# i      or: fdisk /dev/eda  (for the first PS/2 ESDI drive), g! ]. v5 I2 m: ^; ^
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
( F7 z$ ]& z" X% {  L      ...
  l6 s* W# o; y3 I( G6 Z
  1. df -k
    , t1 `* k3 ^% i! F6 A' ~/ s7 K
  2. df -lh
    6 v$ ^0 h, \7 Z8 R! s  Z$ R7 W
  3. 查看有几块硬盘:fdisk -l
    1 ?4 w1 w1 G/ y& n/ f
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
& `! W1 N% F. K, n/ D% V    /dev/sda3              3723848    705968   2828716  20% /
! o% M9 C: ^2 B6 f* x    /dev/sda1               101089      9274     86596  10% /boot$ S* w+ b0 K6 ?% P6 |# h( H* B
    none                     14520         0     14520   0% /dev/shm
  S4 u* B, C4 B; v4 e% Z/ h    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用) V+ J8 |2 Y' J/ s# ]% c
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
7 r" f) c' p9 ~3 {    Building a new DOS disklabel. Changes will remain in memory only,
$ O+ E1 K/ V" g- r9 c    until you decide to write them. After that, of course, the previous
, S- |( L4 v( |/ s! _7 t    content won't be recoverable.
2 h4 Q1 o0 n+ p3 v    The number of cylinders for this disk is set to 8322.
7 d) T) J& }$ O) e* V+ V    There is nothing wrong with that, but this is larger than 1024,% q8 l! \/ k1 B8 @. d
    and could in certain setups cause problems with:
0 }- p8 M6 g- a8 C' G: V    1) software that runs at boot time (e.g., old versions of LILO)
0 r7 h* l1 {& _- W0 O    2) booting and partitioning software from other OSs
, G/ f& Z1 S: Z- e" I       (e.g., DOS FDISK, OS/2 FDISK)% p6 m7 d( }* {/ j
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite). a' l) Q4 ?6 n( p
    Command (m for help): p
3 I6 [% d( o* V, V% R7 x1 u' i    Disk /dev/hda: 4294 MB, 4294967296 bytes1 w: a9 a: a: W' N! w& Q% q9 M
    16 heads, 63 sectors/track, 8322 cylinders8 c. d( {! ]7 R, h; P, m$ h
    Units = cylinders of 1008 * 512 = 516096 bytes
; ~9 _1 J% [& U/ {4 B       Device Boot    Start       End    Blocks   Id  System
, z' s( ^# t' I    Command (m for help): m
5 Z/ y+ V& ^: [6 \: e# e9 @    Command action% q! R; P& E. Z2 ?
       a   toggle a bootable flag
% [* M" }0 u% s0 i) t" l       b   edit bsd disklabel
9 ^! J2 z4 t! c  ~! D: P% I       c   toggle the dos compatibility flag
$ @. B* P( p! q/ |7 z2 D/ F8 X+ k       d   delete a partition4 }6 p) r! x- V- V
       l   list known partition types( j: l$ a6 x  ]4 @% {: L0 Z3 j, i
       m   print this menu
9 t' a, |: R2 E( D       n   add a new partition5 A, E. }# |$ j3 ?+ s2 T  H* B, T
       o   create a new empty DOS partition table
( E5 M6 X! u9 \* W  Z3 Y       p   print the partition table
9 R$ r( D* b% L5 A/ ~/ A& f       q   quit without saving changes
7 e" j, j) y/ i3 ~& `       s   create a new empty Sun disklabel: c- w, `% c5 e' G0 @& |8 T# `
       t   change a partition's system id) Y/ l- M6 i- }7 N2 P) f% r
       u   change display/entry units
! ~" \+ ]1 j/ D8 n: I4 @3 N- W       v   verify the partition table8 g# r( m+ z" Z
       w   write table to disk and exit
% p3 C: L  b) U7 d: F' J       x   extra functionality (experts only)* t+ Z# O( O5 W* u* L
    Command (m for help): n7 l# c2 e5 L9 I
    Command action
- R: z0 M: ^" [5 d       e   extended$ @+ D5 f0 p) H' x
       p   primary partition (1-4)
: P0 O( _8 M/ ^& B: Y- G2 u: ~    p
0 r1 G; v4 A9 l' ]! H/ K- v    Partition number (1-4): 1$ n# N4 z$ a. e
    First cylinder (1-8322, default 1):
( B. k8 E8 X- a: [    Using default value 1
9 f$ `) A8 D* D1 c5 W' J; I    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
+ Q* \) s0 z( P' A7 v, k- v' o    Command (m for help): p
0 U) e0 |# C& r+ m    Disk /dev/hda: 4294 MB, 4294967296 bytes
" G+ f* ^; y' I! R7 K    16 heads, 63 sectors/track, 8322 cylinders
1 `' }4 U& i5 j" f* t    Units = cylinders of 1008 * 512 = 516096 bytes; _, [0 V! K: R7 W
       Device Boot    Start       End    Blocks   Id  System3 f1 U8 L! W& G, S
    /dev/hda1             1      1000    503968+  83  Linux' O5 y; g  K9 K9 l4 }5 A
    Command (m for help): w# U* d* d/ _; \4 v6 ?
    The partition table has been altered!
+ H' i# P3 ]' L; y    Calling ioctl() to re-read partition table.( b# h2 s7 Y4 T7 x; i* {9 n& M7 T7 p
    Syncing disks.
- J- ]4 `! P* {9 s" |4 I/ C    //格式化新分区
4 P6 u6 o' g) _, K& D& J
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)& H$ i- _: m! |: g
    Filesystem label=
8 I' j0 }6 q1 c. e    OS type: Linux4 h" p$ M6 }8 q
    Block size=1024 (log=0)9 d6 {8 \$ c; r
    Fragment size=1024 (log=0)
2 b# j* R" K- g" e    126480 inodes, 503968 blocks% |0 h5 L" j* p8 w) N
    25198 blocks (5.00%) reserved for the super user
$ ^( r7 v  F2 L  Y    First data block=1
: o4 v( ~( C+ w( t& c; A$ o' A    62 block groups
/ e- y: W) N4 E0 R    8192 blocks per group, 8192 fragments per group. I0 m3 @% l3 Q. `. F1 \
    2040 inodes per group! B) ^" Q# k& h& O7 r9 ~
    Superblock backups stored on blocks:
8 G# F" U/ L7 c' g* a            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
- X, X3 k6 _! z    Writing inode tables: done                            / L% z1 h; m6 `# H1 p8 W
    Creating journal (8192 blocks): done1 w) O4 }5 ?/ O' s; q
    Writing superblocks and filesystem accounting information: done
! ?% L8 H2 Q7 m9 V  I    This filesystem will be automatically checked every 30 mounts or
3 [/ \8 i7 x& |    180 days, whichever comes first.  Use tune2fs -c or -i to override.
6 c- v& w5 o  B( W: r
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点1 ^( E5 j3 y+ \& `* k+ ]
    /dev/sda3              3723848    705992   2828692  20% /
, U9 ?( o' x+ E  K  b) P4 P7 h    /dev/sda1               101089      9274     86596  10% /boot  i7 M& a! {- l
    none                     14520         0     14520   0% /dev/shm
- `+ P' h4 s- {% b3 d0 Y9 \, v& T! b- q    //挂上新分区
0 e  k0 K1 z5 U  e  t# Z1 a  {/ u3 }
  1. mount /dev/hda1 /home
    4 F3 N' c  s& _* t
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点4 W$ K" s; r4 i  K2 J
    /dev/sda3              3723848    705992   2828692  20% /8 _: n8 r% @6 {: w- x4 V
    /dev/sda1               101089      9274     86596  10% /boot2 S' U% P0 b7 j3 F% x
    none                     14520         0     14520   0% /dev/shm! k4 \" i8 w3 x9 _! S4 h8 P% t
    /dev/hda1               488006      8239    454569   2% /home; }1 I: t2 l$ _

: y: v0 q. ^+ n% l自动挂载:
' V& j5 a# j5 r, H. q2 o
  1.           vi /etc/fstab
    ' h! s6 Y* r( ^2 ^+ C) T  h1 w
  2. % x$ a0 V& V7 n# x" d7 d
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 01 r1 D# v' d' j/ C* r

  4. 0 J! ~+ r" v4 W2 I( ^1 B
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:8 s: _8 r2 A( y) w0 S- ?' w/ g
  1.           mount /dev/sdb5 /mnt/ljp18 q% x7 ^# Q5 ~& Q8 r

  2. + ]3 U$ ~' I$ F8 K' D; [0 [' q3 M+ y
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

8 g, O2 P0 P  R* P: Z4 L. j* I9 q+ L/ K9 v, e" R+ }5 V

6 d8 }: ^- y0 V. U4 B3 A
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-2-23 04:43 , Processed in 0.012847 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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