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

 找回密码
 立即注册
查看: 2607|回复: 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)
( L+ o: ~* k% l1 S      or: fdisk /dev/sdc  (for the third SCSI disk)
" H: F  J4 @- _2 U& [" F6 z" B/ r1 l      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)! M+ j2 x5 G: V$ V! N* T0 u0 f
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)1 k9 f2 T6 e  m5 G* H+ n
      ...$ X5 {- i. X4 l/ j
  1. df -k; M0 }5 v" }( o$ W! t4 s
  2. df -lh4 O2 l3 i; o+ S" W- z
  3. 查看有几块硬盘:fdisk -l
    # X! x1 m' ~1 y
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点# s3 t: n0 Z  }. p$ W0 q' w
    /dev/sda3              3723848    705968   2828716  20% /
! d- P$ E& g! D) ?    /dev/sda1               101089      9274     86596  10% /boot! w  K- `4 k, G5 [& I2 }* D- W
    none                     14520         0     14520   0% /dev/shm
' |# a& G% v: ?; S. C! R    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用0 P. x; ]! m6 L8 r% [9 Z, \
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel; B: @$ Y' {+ |- p5 U/ I$ \3 \# C
    Building a new DOS disklabel. Changes will remain in memory only,
( h/ i2 }2 z- j% [    until you decide to write them. After that, of course, the previous
8 }3 ?0 `: W# T% z    content won't be recoverable.3 m$ @) I. M9 e  u3 ~. ?
    The number of cylinders for this disk is set to 8322.. r% p! ~7 W, n( v( z1 N/ m8 ?
    There is nothing wrong with that, but this is larger than 1024,
' U2 X, T5 s8 d    and could in certain setups cause problems with:1 L2 U( R8 X; _) ^3 {& f  ]) ]
    1) software that runs at boot time (e.g., old versions of LILO)
" {8 ^/ i( G% N4 [$ S/ s    2) booting and partitioning software from other OSs" W2 `2 }7 h0 O( X1 s$ }+ {" k
       (e.g., DOS FDISK, OS/2 FDISK)# u9 f) B. U4 C# I$ |
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
! o1 R* @; [( o    Command (m for help): p
( q# Q/ m3 L& i/ z( ^# \/ n    Disk /dev/hda: 4294 MB, 4294967296 bytes
% Z% g3 I8 j3 Y; Q& W6 ^    16 heads, 63 sectors/track, 8322 cylinders
6 R# b3 U  E' m2 b# [+ k    Units = cylinders of 1008 * 512 = 516096 bytes
* u6 i6 [5 G, p; J, k& w+ X       Device Boot    Start       End    Blocks   Id  System! T4 i2 U& }  O3 K
    Command (m for help): m
8 P; n! {% c$ d& r1 O( a, f    Command action
. N# v. o  Z4 z0 ]       a   toggle a bootable flag
1 J! |5 j, U/ i3 ~7 ?2 P" ]( B6 o0 q       b   edit bsd disklabel: `( E) t0 n1 o: h# u6 ]
       c   toggle the dos compatibility flag9 j/ U9 h5 P1 l6 f
       d   delete a partition4 u! i& e* E) l0 h* }1 G
       l   list known partition types
/ m/ {" B; m. \) ]) V       m   print this menu" h: u4 [) a' b* ?6 _9 i
       n   add a new partition/ X' k) \8 |3 G' }. e
       o   create a new empty DOS partition table
% u9 [9 g. D6 j/ z$ b7 l* b0 h       p   print the partition table
3 I6 _( J/ L# d4 p       q   quit without saving changes8 w  ~4 y" i9 R+ G( D" {( F! B
       s   create a new empty Sun disklabel
, Q$ D: d$ ~4 }+ r! N       t   change a partition's system id/ r% n, a& f; _
       u   change display/entry units  r" P8 K$ ]" ~0 l. v: A
       v   verify the partition table
1 ~% Y6 V% x9 D& ], y& o: c# v       w   write table to disk and exit1 c# x9 `+ w- i, k( L# h  \
       x   extra functionality (experts only)
% w9 q3 c& H& \& |    Command (m for help): n
: C2 S, D3 ]* Q    Command action: g5 R0 P( J( Z# G5 }8 A1 ?
       e   extended' q9 v% T. q  ?' v
       p   primary partition (1-4). L  i# ?/ Z7 u2 I* b4 O% `. \
    p
2 \) r- r2 n& A4 w    Partition number (1-4): 1
4 p9 k' b( T5 \- @0 u8 i    First cylinder (1-8322, default 1): 6 A# b3 w7 t1 R+ M* ?) q
    Using default value 18 c3 m2 t- j4 u% w# g4 }! R  r% y
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G: B% Y7 B# u: v: P
    Command (m for help): p
; {: N7 @& M6 T* V$ G. @    Disk /dev/hda: 4294 MB, 4294967296 bytes3 c" ?8 y, A) Q7 c
    16 heads, 63 sectors/track, 8322 cylinders
; K( U6 W+ n% F- m) k$ ~3 X    Units = cylinders of 1008 * 512 = 516096 bytes
* s. W( ^) h  D* f. W- [; U       Device Boot    Start       End    Blocks   Id  System* R1 [. y; H- h- Q( B- B
    /dev/hda1             1      1000    503968+  83  Linux
- b6 D6 k' B5 B2 i0 A2 P    Command (m for help): w( r! z$ j2 z6 e" s3 C/ q4 ]
    The partition table has been altered!
! L3 q% J$ Z7 _$ p; w    Calling ioctl() to re-read partition table.
3 O2 `2 n$ z; H# G5 m' \    Syncing disks.7 A% n2 n& y' b- l
    //格式化新分区
. n) C# c& k8 I- g5 J* @
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
/ S& W# X9 y2 k3 Y+ I' f) ~- r    Filesystem label=/ d/ p, R3 J# n4 @/ g( W
    OS type: Linux; i+ x- i3 O8 s- x, ?& V% x/ O
    Block size=1024 (log=0)& O( a& f9 I" I4 @  J* b
    Fragment size=1024 (log=0). C( n3 m; i; y2 u: Y( z7 {
    126480 inodes, 503968 blocks
0 n  \1 m& |& j6 e5 p6 _1 ^    25198 blocks (5.00%) reserved for the super user
5 j6 O0 s# R* G3 U9 U    First data block=1
$ a  S/ w6 b" e2 a    62 block groups
3 R, u6 n6 Q5 c. {( q    8192 blocks per group, 8192 fragments per group
& M0 i+ ~) f1 G: L+ R, p    2040 inodes per group% _# ^7 R* B+ s5 p
    Superblock backups stored on blocks:
& j& H; e' J( Y6 z; E. W/ r            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014093 o5 |9 }# ]" d
    Writing inode tables: done                            7 \# d- M8 c8 G4 S7 o
    Creating journal (8192 blocks): done
$ @1 N+ H! h. K. Z    Writing superblocks and filesystem accounting information: done
, s6 E- x8 a! [    This filesystem will be automatically checked every 30 mounts or
# E. T! d. R% b) O    180 days, whichever comes first.  Use tune2fs -c or -i to override.; V6 w9 f$ N0 {" |6 e/ A
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
; X4 O! \5 u+ z' x% I    /dev/sda3              3723848    705992   2828692  20% /
$ C0 C4 q# V, p; \+ r    /dev/sda1               101089      9274     86596  10% /boot
7 G$ d9 f& t: `5 d! m6 f+ }& x    none                     14520         0     14520   0% /dev/shm
4 {! ~# \# Y7 K    //挂上新分区
3 G1 r- v+ c2 [, f' ?/ P7 D
  1. mount /dev/hda1 /home# p# B( C$ E/ d9 _0 [/ g
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点* b! Q' e0 J. i* f0 E1 ~
    /dev/sda3              3723848    705992   2828692  20% /
* a* B. W6 {! S. Z) C1 E    /dev/sda1               101089      9274     86596  10% /boot
0 }3 V% _4 b/ Y2 p+ @    none                     14520         0     14520   0% /dev/shm
0 }: H& ^9 c* X9 h    /dev/hda1               488006      8239    454569   2% /home3 v' p- k- w8 w/ `. o, D! A7 c  ~

9 I% A- J6 g8 e6 P# f: E8 Y自动挂载:
0 }" ^1 p7 l0 V  N9 L* F
  1.           vi /etc/fstab  n4 l) ^7 b! Q* u1 C! \8 f7 f
  2. 3 @5 j$ S8 k- l* K, t+ l7 e- o
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    # l* i0 ^4 O6 n! A- y; K

  4. . ^! o: G% L) X+ Y0 P+ [
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
1 b$ ]- e/ Y( p$ `' i
  1.           mount /dev/sdb5 /mnt/ljp1- ~, ^# b, I' `2 b
  2. 5 t5 l2 K4 h& Z) _7 B
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
4 b, I, X& Z. S/ ?
, k0 A  z! Q  Q5 f. E  e! A; J

' G$ d3 h  J0 T8 U( I/ ~* t! G; L
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-28 13:34 , Processed in 0.006570 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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