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

 找回密码
 立即注册
查看: 2640|回复: 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)
0 S) c4 T' l7 `" e      or: fdisk /dev/sdc  (for the third SCSI disk)2 l, a( J! Y4 V0 e
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
7 @' B6 R1 N$ t      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)7 }' j& ~# P8 t6 n- P  B: G" F4 n
      ...! j" x" }+ w3 W* c6 e# ?
  1. df -k
    6 _' N6 j& k, @& [/ |5 f  ~! V
  2. df -lh! u* _7 u1 V! C' Z
  3. 查看有几块硬盘:fdisk -l
    6 `% \7 m( v; \. S( |( V
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点) d1 E2 `7 x) v
    /dev/sda3              3723848    705968   2828716  20% /
6 Z6 q  v/ r, I    /dev/sda1               101089      9274     86596  10% /boot
- \4 J4 R9 B3 i, E2 R' n    none                     14520         0     14520   0% /dev/shm
( Q9 z, B" s2 Z    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
* b- x1 N" o' `! E' e) X
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel* {* R( `" b5 b' O6 f1 S
    Building a new DOS disklabel. Changes will remain in memory only,
8 c; D* P, ^2 t5 y' x3 Y# T    until you decide to write them. After that, of course, the previous
9 S: i6 {$ y* D3 s    content won't be recoverable.6 e. G) Z+ q5 ~' O
    The number of cylinders for this disk is set to 8322.
% q) q& c, e7 }    There is nothing wrong with that, but this is larger than 1024,
* [& s5 y- j; L" W" G8 k* D5 c: C1 e    and could in certain setups cause problems with:
% ?: @9 V3 Y+ \1 M    1) software that runs at boot time (e.g., old versions of LILO)
# o4 U! k1 E; O    2) booting and partitioning software from other OSs4 D2 v' R: y$ j% Q
       (e.g., DOS FDISK, OS/2 FDISK)( U( d3 K% ]/ ?
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)6 j" N6 F8 c* w3 r% [0 ?: i( r
    Command (m for help): p+ S& V  F  v$ l0 V5 ]
    Disk /dev/hda: 4294 MB, 4294967296 bytes
: @  E0 W; i0 W    16 heads, 63 sectors/track, 8322 cylinders$ X9 ~6 O$ R6 A" k1 ~" j
    Units = cylinders of 1008 * 512 = 516096 bytes
" R* b5 y- ~8 I3 R2 V; F       Device Boot    Start       End    Blocks   Id  System/ {* i' q( [; c$ _3 w
    Command (m for help): m
7 ^, B! P) [* V, T! J9 R9 f    Command action
  `! [% [* T4 ^       a   toggle a bootable flag* q1 H9 G1 Y/ L( R3 Z! t8 b( o
       b   edit bsd disklabel
3 Q! i  ?8 b9 V, Y1 f  ^* }6 ^; x       c   toggle the dos compatibility flag
6 |+ j6 H" O' m# O; n       d   delete a partition7 S* h* [/ C/ P
       l   list known partition types
1 |5 Q; e' h; D' Z! V/ y* N+ x       m   print this menu
' ?* w% f: [: t" `/ ~9 X       n   add a new partition
! V3 q  k1 X6 q# R( b       o   create a new empty DOS partition table
/ t3 N8 }8 v% Y' O       p   print the partition table" M; W: L! _, X" W) w- S! `  k- x
       q   quit without saving changes
  W' j& z, R! H/ W/ ^" _       s   create a new empty Sun disklabel
  }, g8 H0 w( n" M0 H$ C       t   change a partition's system id
: y2 j/ ?+ W1 H! z4 O; X' a       u   change display/entry units
/ }# i2 `  O* l; Q. S7 \# {       v   verify the partition table
! F/ g- Y. ]1 P4 u( _0 y) D       w   write table to disk and exit& c4 O% H7 v1 P( ^
       x   extra functionality (experts only)
; w5 a: y+ Y8 m! r: g# h6 b    Command (m for help): n( o+ R3 v; u' k, f) U# p2 A
    Command action  H' V0 L( Q8 u1 u$ Z9 ]. l! k. i( b
       e   extended
: ^8 M% u- p) p5 h" ^       p   primary partition (1-4)5 q0 Q$ s( P/ }/ ]0 ]/ w
    p# Y6 X8 ?* Q7 |( r
    Partition number (1-4): 1) ]% J9 e# O0 z+ N2 R+ f2 y
    First cylinder (1-8322, default 1): ! b( \/ I+ T! \$ f1 J0 q' ^5 S& O
    Using default value 1
/ m! {5 ?' u+ {0 {5 I( N( t. _    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G2 d/ {, ?6 a; S7 g8 p
    Command (m for help): p" R" s- m/ I6 U- V2 v6 i2 Q
    Disk /dev/hda: 4294 MB, 4294967296 bytes: V  g9 ^* I* L$ E: h4 H
    16 heads, 63 sectors/track, 8322 cylinders
- r7 Y. \$ t3 s5 J: e    Units = cylinders of 1008 * 512 = 516096 bytes7 ~  Q- `- k3 k/ H) P; r4 @; z) v$ a
       Device Boot    Start       End    Blocks   Id  System% S. m. |2 S. \# z' o
    /dev/hda1             1      1000    503968+  83  Linux
; ?) R9 C3 L4 z6 m$ {9 S! H8 @    Command (m for help): w% h1 v# M' c+ @
    The partition table has been altered!
, P$ w! {9 r' Q; S% M! W) V) C    Calling ioctl() to re-read partition table.+ `6 j7 [) D3 I
    Syncing disks., q' C* [0 [  P4 S( g! B' Y
    //格式化新分区
. [) S/ X# V) w. Q. h  Y$ u2 Z7 A. y
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
* g4 Y+ Z: `+ _    Filesystem label=8 G* O6 A% M' E% s
    OS type: Linux. Y2 t" ?7 n* V0 d' q1 ^0 I
    Block size=1024 (log=0)
, r! V, P- G4 @" F- S, Y) {; h    Fragment size=1024 (log=0)6 h6 C$ h  g1 x3 {
    126480 inodes, 503968 blocks% o( ~/ d8 `# Q& o
    25198 blocks (5.00%) reserved for the super user+ T5 U; T: S! i3 h. k4 ~/ ]
    First data block=1
( Q/ t& M- X6 b) g6 x8 F* T    62 block groups+ O% I( [: Q: u- Y
    8192 blocks per group, 8192 fragments per group
1 i9 k" l8 m, ~" s- k2 z/ L    2040 inodes per group
) q8 C8 S- C9 |3 E3 ^* P    Superblock backups stored on blocks:
: Y8 j$ _; [( ?) ?0 G7 e5 C& X            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
" W# v9 D5 T+ ?+ y0 c    Writing inode tables: done                            , S9 I6 x9 }- @  b
    Creating journal (8192 blocks): done
5 n* z8 T. g* P7 u    Writing superblocks and filesystem accounting information: done, Z5 l3 C6 o7 ?. e3 X% E8 T3 V
    This filesystem will be automatically checked every 30 mounts or! ?7 N0 J4 R2 E# G$ |8 F
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
7 d1 q0 J3 n: ?5 G
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点1 Z7 }* L% b* \3 S$ G. g3 T- E
    /dev/sda3              3723848    705992   2828692  20% /6 E1 ]# {( n! e. v
    /dev/sda1               101089      9274     86596  10% /boot# U4 v* H0 o2 A. x, c
    none                     14520         0     14520   0% /dev/shm. s6 Y+ t! V: \# D: [% L
    //挂上新分区
: M4 Z' n6 o+ P8 v6 T
  1. mount /dev/hda1 /home8 q7 f6 X/ R% f4 {
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
+ ]& S# e. r: h: T    /dev/sda3              3723848    705992   2828692  20% /
' Q& V  i. n/ J5 \/ H    /dev/sda1               101089      9274     86596  10% /boot3 q# [  X" p! ]! v' _" n
    none                     14520         0     14520   0% /dev/shm, Q- S" k" {* F3 y  F
    /dev/hda1               488006      8239    454569   2% /home
& X: `' c# c4 r) o5 v7 |) H8 R
自动挂载:
( f0 ^! `: w% t; z- f
  1.           vi /etc/fstab9 T5 ^, v$ h% z  b' ]' g$ n( r

  2. $ M' A- s* @3 i1 f5 X0 d
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    9 F2 F: g* c, w% n0 P  S( ]
  4. 1 \' ?% E* w0 f) j! w' C. m
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
% [9 ]6 \9 k" x" P2 r* e
  1.           mount /dev/sdb5 /mnt/ljp1
    7 f- l4 a$ s7 h
  2. ' s( j# M! B% c$ \) E
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

. X' Z0 }) w' Q; G. J( B
; e; D7 t, u9 W: ^4 }9 C# K1 C  w; |, z8 y' R, ~1 s
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-5 13:58 , Processed in 0.030697 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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