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

 找回密码
 立即注册
查看: 2751|回复: 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)- g& e9 j2 H: |* ^2 S$ O
      or: fdisk /dev/sdc  (for the third SCSI disk)
2 {5 d7 H6 X, n0 B% t+ S      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)7 z+ y5 P$ U5 S8 z
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
4 A$ B6 V4 c. h( B      ...
8 l7 ]* @  B+ F& Y0 N
  1. df -k5 {9 z% s" ~3 Z% I4 ^7 M
  2. df -lh
    0 b4 `' N/ m, ]$ k( o
  3. 查看有几块硬盘:fdisk -l+ y; H) R# G  r) o
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点, H; ]8 o( w( a% W% {+ j
    /dev/sda3              3723848    705968   2828716  20% /
% B4 \' u8 J# ~" m) F    /dev/sda1               101089      9274     86596  10% /boot
8 \  c+ W5 v- O, [. R    none                     14520         0     14520   0% /dev/shm
0 r; Q# S" k- }) b  i    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用% O- p& I# t, K7 @+ S
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel- @* m/ D  |% m# I+ t+ A4 o! t& S
    Building a new DOS disklabel. Changes will remain in memory only,
0 E. e2 R* E0 X# d2 q3 n9 N    until you decide to write them. After that, of course, the previous
, Y( i- U; A$ [7 }1 F    content won't be recoverable.- x" C. {4 _+ P  Q) D8 S
    The number of cylinders for this disk is set to 8322.
4 k3 G2 R+ E! `6 r6 `9 a    There is nothing wrong with that, but this is larger than 1024,
7 P/ l* x5 J) K0 m+ l/ i+ F- L; k    and could in certain setups cause problems with:
( u1 n; p! ]* n! V    1) software that runs at boot time (e.g., old versions of LILO)
8 P6 G/ i( z  U+ G6 q    2) booting and partitioning software from other OSs, F$ _- \, N9 n0 z6 W
       (e.g., DOS FDISK, OS/2 FDISK)  q& o8 ^/ V9 X$ b
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
! V+ X" U# _; x    Command (m for help): p
# `* Z" ~; @1 @    Disk /dev/hda: 4294 MB, 4294967296 bytes
1 R# S' Q, }9 z' s4 q    16 heads, 63 sectors/track, 8322 cylinders3 ?: H* q. n/ C# }! c3 ~
    Units = cylinders of 1008 * 512 = 516096 bytes
2 `9 n! P# k9 ~4 u0 A6 p& }       Device Boot    Start       End    Blocks   Id  System. X! a* k0 S7 N" h+ U
    Command (m for help): m
7 Z! Y/ Z$ y6 a# O9 }    Command action
- J& h. m8 |: V, G+ Y( {2 T. E       a   toggle a bootable flag! E: M5 a5 }8 I% \0 L4 p2 O
       b   edit bsd disklabel
% A6 _/ Q( b- A8 b  X       c   toggle the dos compatibility flag
" C8 J6 _5 A/ _5 X: G; q6 U       d   delete a partition
; V6 e; n) d7 B( D" c- _" C7 j       l   list known partition types
' i" M5 w. K/ o' Z9 ^% Z       m   print this menu
8 B3 V; H5 T8 |, N       n   add a new partition
6 ^+ @( a* I7 A, L& S/ Z3 u1 K& Y6 B       o   create a new empty DOS partition table! S8 R. U! v- a$ U+ p7 e
       p   print the partition table
4 [, v) Q- _# M4 v+ R       q   quit without saving changes
# Q, n* F& |2 w( ^       s   create a new empty Sun disklabel
! Y. g4 v. ]& X/ U! u       t   change a partition's system id
5 S: s' a2 K# r, g( ^2 C       u   change display/entry units
: ~. q! b/ I* \" s       v   verify the partition table) o9 {, Y0 z6 H$ [
       w   write table to disk and exit9 i8 n1 U- c, a* c3 F+ w) a
       x   extra functionality (experts only)8 Q* G& F5 P% r# h* N& }4 ]
    Command (m for help): n; u+ e( v( [& ^7 B6 \) d( k
    Command action! ?$ f/ [2 ~! k6 X' y
       e   extended8 \; T* |4 f4 d% H8 ]
       p   primary partition (1-4)
% G& N7 u+ K1 R1 M    p
5 _1 h$ x4 C" N' }    Partition number (1-4): 1( ^) d% p6 p  I9 U
    First cylinder (1-8322, default 1):
4 a& @. h' x( l" ]% z, B    Using default value 1. C7 e- [0 B- ?$ k8 j4 l) f; y& q! O
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
0 x& B+ u7 e: s0 H    Command (m for help): p% _7 F/ K) R2 [' e! ^
    Disk /dev/hda: 4294 MB, 4294967296 bytes
% y. p  Y$ I& A  d# G    16 heads, 63 sectors/track, 8322 cylinders& Q1 S9 P  n8 ?
    Units = cylinders of 1008 * 512 = 516096 bytes- d  j9 t. O  R& Y  j9 y
       Device Boot    Start       End    Blocks   Id  System8 h0 I0 s1 \( M) k2 N2 e6 P
    /dev/hda1             1      1000    503968+  83  Linux  O  v9 a/ l& o1 L; M
    Command (m for help): w
! Y" N' ]. y0 L' ~+ x* O5 v8 U' i    The partition table has been altered!
1 s6 Z- o' @  s- q3 J, O    Calling ioctl() to re-read partition table., y, L( v  T# x. c6 a; t
    Syncing disks.
, @: b( v) x% e, z/ o$ Z# @8 Q8 u8 g  f    //格式化新分区
  p1 y, q" @7 V! w, O# _  K
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
+ I0 w) n; S9 \1 t    Filesystem label=
& C! k3 L8 v0 F, z' [6 e9 o    OS type: Linux
* u- }8 x, ?, ~- R6 M$ j; J, u  S3 w+ Z    Block size=1024 (log=0)
8 Y' A# G# u( B: V1 z' x5 A% p! {    Fragment size=1024 (log=0)+ p1 R" Z- q0 d' [/ j* z
    126480 inodes, 503968 blocks1 C: S" q2 E, U% ?" H
    25198 blocks (5.00%) reserved for the super user
8 \& q" h* A: H# G    First data block=1
' X& W8 o, d2 F- c3 T# E    62 block groups
' r& H1 t2 n5 u7 b+ L* \  u    8192 blocks per group, 8192 fragments per group# R/ A* Z/ V* X& ?
    2040 inodes per group
4 _; G. x" H$ o    Superblock backups stored on blocks: 6 w+ }/ m  c7 z
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409! Q) B. C- J0 b
    Writing inode tables: done                            , a( W# M7 _% n' l
    Creating journal (8192 blocks): done
; e  n! C  j! i6 q, X/ x! l    Writing superblocks and filesystem accounting information: done( T: V4 O" p4 K. \. H! ?1 g8 Q5 V
    This filesystem will be automatically checked every 30 mounts or
# S: N5 b" Q8 \# v/ q, K& ~    180 days, whichever comes first.  Use tune2fs -c or -i to override.+ @* ~0 h0 W+ U' V
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点! Q. o: B5 h! R7 Q# p8 @
    /dev/sda3              3723848    705992   2828692  20% /2 V* R( R( \1 P" j) M' {' z; Y
    /dev/sda1               101089      9274     86596  10% /boot. o/ t( j* e( u% ]; C5 u& F) K) s
    none                     14520         0     14520   0% /dev/shm
7 o! F  O' W+ e: o/ ]6 ~! [    //挂上新分区
: D7 ^- p. j. T# e! w& K
  1. mount /dev/hda1 /home
    / K' Q& X+ Q# ~3 d  ~
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点4 ]% ^" H5 w* p( s; ]
    /dev/sda3              3723848    705992   2828692  20% /
6 p( R% K) E3 x+ V9 B/ Q: ]2 ^' v    /dev/sda1               101089      9274     86596  10% /boot! e5 `$ O2 j& ]' X+ ]) Q5 c
    none                     14520         0     14520   0% /dev/shm' z/ z: y8 O# P" }  i
    /dev/hda1               488006      8239    454569   2% /home
. |  x. H; @$ s) [) K* H; e: Y
) B! \$ u$ F3 w( G! u  B自动挂载:5 v  c  N/ i0 o$ j5 W$ _1 f
  1.           vi /etc/fstab* |* i. B4 H2 S) V% H+ [
  2. - f& W2 `7 r$ ~% J8 V; d! F
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 08 r1 M! ?! d& t' W6 |8 a6 g8 J4 Q9 A

  4. : E7 Q: A7 Y' k
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:1 |+ k. E1 W* ~8 T) r" }
  1.           mount /dev/sdb5 /mnt/ljp1
    7 s5 E7 Q1 X8 w- V: u
  2. . {, Q4 C2 [$ A4 k" G
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

. ]4 @3 L5 t8 [3 S- Q! Z8 l5 e6 y) [. d1 Y! I9 }+ f

0 O- {: T! g3 L0 n
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-9 01:07 , Processed in 0.025401 second(s), 6 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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