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

 找回密码
 立即注册
查看: 2778|回复: 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)" {$ t1 J. N: `  Q
      or: fdisk /dev/sdc  (for the third SCSI disk)
6 [  q( v+ Z' r$ v( E: X8 q& G! M      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
$ w5 @$ G9 }, {3 }  r7 y* E4 N      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)) Z2 i- p+ D; v8 ~# g1 i, i
      ...% }5 h# j  ]: Q+ t3 w: H- E  ^' M4 r* Z
  1. df -k
    0 A% _% m, p, k( F% B0 b
  2. df -lh
    ) `& |5 |, |# r, \+ t5 @
  3. 查看有几块硬盘:fdisk -l
    , \) S2 j& G$ g
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点$ G) a" \" h) Y) f8 Q
    /dev/sda3              3723848    705968   2828716  20% /
" T3 U, O) z; t( M. C' {    /dev/sda1               101089      9274     86596  10% /boot  }! }( T4 q  T/ z4 h) O
    none                     14520         0     14520   0% /dev/shm0 S' E: @" n# d9 Z. h% \# J
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
( B+ X9 m5 q2 K" k6 i3 o4 M
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
: c; A, M5 `2 W3 h# k* ?    Building a new DOS disklabel. Changes will remain in memory only,
. V( Z  o8 V, y: H  J8 l. V  ?7 R    until you decide to write them. After that, of course, the previous
! ]! O' L6 r& q1 M    content won't be recoverable.9 G! D3 I% B7 U2 W9 {, v
    The number of cylinders for this disk is set to 8322.% A: M# t- a' X- I& ^. K% b+ D9 H- b
    There is nothing wrong with that, but this is larger than 1024,
! v. j+ T  m! ]- H  W; O    and could in certain setups cause problems with:( V9 C% K+ K% N" u
    1) software that runs at boot time (e.g., old versions of LILO)
3 H. {1 ~: {- [7 l  V6 `3 R# [9 j    2) booting and partitioning software from other OSs
' z- ?2 [1 X8 |" g; y       (e.g., DOS FDISK, OS/2 FDISK)3 s1 |3 s' F: [; Q
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite); k( K8 k/ L; t! t) z* w6 x4 U
    Command (m for help): p' d. o0 \6 _5 V8 D! F3 {
    Disk /dev/hda: 4294 MB, 4294967296 bytes. o- j8 t6 K/ F3 s1 n, u# Y
    16 heads, 63 sectors/track, 8322 cylinders
. ]5 T- a1 H. B! @) j+ f    Units = cylinders of 1008 * 512 = 516096 bytes
' ^  |5 O% h8 V: ~. Z0 b! H$ d4 u5 M       Device Boot    Start       End    Blocks   Id  System) \, ?, c6 t1 v! R. Z! P
    Command (m for help): m
  c: _6 D, N& K1 \7 S    Command action
. b; ?2 }+ m* p% p' ]       a   toggle a bootable flag. z2 c) u( K$ y) l3 j0 ]
       b   edit bsd disklabel
  X/ U% A3 }2 S       c   toggle the dos compatibility flag/ V4 R7 h/ E3 o. {
       d   delete a partition
* B/ ~1 Q1 ~1 h4 r       l   list known partition types- M/ j+ H0 D  i2 x. G4 P
       m   print this menu
7 c7 p: V/ a3 b2 a  u       n   add a new partition; b/ z6 j* E; @0 X' l
       o   create a new empty DOS partition table
# z: l1 L$ U& T9 Y& D; p" c* J       p   print the partition table' o- k3 Y# Z/ d; K
       q   quit without saving changes/ x3 a' p' ?4 y- \$ {3 K
       s   create a new empty Sun disklabel4 R: W8 W) j( q7 Q2 Q
       t   change a partition's system id3 q2 d; [0 e. V- x7 v
       u   change display/entry units
% ~/ o5 M" T( O4 R/ f- Y/ o       v   verify the partition table0 ^" ?: s; k7 \
       w   write table to disk and exit
+ a+ n& h5 q9 L( @0 i) C1 l       x   extra functionality (experts only)! ?* _* S" j% l4 l5 H
    Command (m for help): n" k' J, n9 C! f% S6 k  j" u
    Command action
0 w3 C* z2 X) F) H! g3 y4 Q/ a: g       e   extended# t9 A' f3 U- p
       p   primary partition (1-4)) I$ u- M8 z0 _7 _9 Q  I
    p
4 i5 |* k' _$ Z6 Q% R4 E$ m6 e    Partition number (1-4): 1
" [& A3 M8 g& c4 L+ {: n+ Z    First cylinder (1-8322, default 1): ' u. U: I+ J' k1 K: j
    Using default value 1
; Y" o: _. w! J- i+ N( x+ t    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
! A, N2 U0 d' p; J    Command (m for help): p% z0 I# B6 }$ T7 P8 B0 n4 b2 o
    Disk /dev/hda: 4294 MB, 4294967296 bytes4 E$ s+ L  ~3 g8 v* O
    16 heads, 63 sectors/track, 8322 cylinders
% S4 O& s0 G" f3 L) t: ?$ D    Units = cylinders of 1008 * 512 = 516096 bytes
2 ?7 u" @3 [' ?( }# V: o       Device Boot    Start       End    Blocks   Id  System
% ^, v2 s; p1 y4 a# D0 Z    /dev/hda1             1      1000    503968+  83  Linux3 A1 b, ], R- A3 u4 A
    Command (m for help): w
4 d; B" N1 M- P1 y; {    The partition table has been altered!
4 P- V4 B* c* T2 C    Calling ioctl() to re-read partition table.( l, ^$ W, A- m8 I3 O5 _2 G
    Syncing disks.
; P+ d; V1 X/ X; H& K    //格式化新分区
5 L& F8 z3 ~5 Q1 s' t+ r
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
! x* ?% y. r- d8 U' Z0 _' q    Filesystem label=9 a( G4 _# q) X/ _7 \
    OS type: Linux
, I. a' x5 X) n8 X- E    Block size=1024 (log=0). N. k+ P) Z( s7 ~: p4 {) r8 G8 d
    Fragment size=1024 (log=0)! E: ?6 Y- z+ J/ y2 _
    126480 inodes, 503968 blocks1 E3 J7 W6 f8 b) S' z2 H
    25198 blocks (5.00%) reserved for the super user: U) |! m% p$ e! `; |6 Z
    First data block=1* }( M6 G! J/ H! X+ i
    62 block groups. @+ B2 V/ S+ h* [; C
    8192 blocks per group, 8192 fragments per group
* E' r1 V1 `) ^' S3 V1 M    2040 inodes per group
! A; |! A" I1 j* ~7 W' a: P    Superblock backups stored on blocks: + r6 i3 p0 Y; u6 {% k2 o9 S
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
2 ?* b# Y8 ?6 \0 c: J9 ]8 O    Writing inode tables: done                           
2 O5 R" e( K- E, r: m3 o) T4 w9 m    Creating journal (8192 blocks): done
7 @- Q) s1 ?) K8 T2 R1 F0 z    Writing superblocks and filesystem accounting information: done
7 ]: @4 c2 c2 U) C7 d' P: |: z    This filesystem will be automatically checked every 30 mounts or
* H% ]1 L5 }- R  o) @' I    180 days, whichever comes first.  Use tune2fs -c or -i to override.: I$ N( w  [% v: R2 S* {; y
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点7 T2 R- y9 O2 i8 @% a, }4 `
    /dev/sda3              3723848    705992   2828692  20% /
: G5 v/ }6 y' `/ K, A& v, i3 ?) _    /dev/sda1               101089      9274     86596  10% /boot$ e6 s' ?+ u8 m4 _& Q, E. Q6 S
    none                     14520         0     14520   0% /dev/shm9 m- c5 L. D! `+ M2 J
    //挂上新分区% A9 {; M) Z, ?* v$ g
  1. mount /dev/hda1 /home
      Z# f$ ~+ u! F) R
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
* m3 d# N1 b9 ^3 z. A+ ?    /dev/sda3              3723848    705992   2828692  20% /- x7 _4 H% k5 {/ B
    /dev/sda1               101089      9274     86596  10% /boot8 s8 W; e: t) S+ D/ R0 J
    none                     14520         0     14520   0% /dev/shm/ s" Y, I4 [! [2 ~
    /dev/hda1               488006      8239    454569   2% /home
* }+ {) F; ~! j% d: P6 R; o* C/ G
自动挂载:: b5 H, b4 H$ d( S* B9 x& u5 E
  1.           vi /etc/fstab  d: j) k5 H* W; {$ Q+ O

  2.   J1 ~2 I  T/ q
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0% J* Z$ `5 G; r. ~2 w; S

  4. 1 ]- U6 h5 X, e
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:1 F& S( x$ B. O
  1.           mount /dev/sdb5 /mnt/ljp1) h, N# ~. D5 k; K, e
  2. 9 @% A/ w% c( P" }
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

# O" U; C3 m) t$ m/ L7 S* f# A: d! i$ d; ]

+ L* m( ]" C5 n, r# ^  I3 x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

Powered by Discuz!

© 2010-2023.

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