硬盘分区扩容

1.首先查看分区为40G,而现在只分了11G

[root@local200-70 ~]# fdisk  -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         127     1020096   83  Linux
/dev/sda2             128        1402    10241437+  82  Linux swap / Solaris
/dev/sda3            1403        2610     9703260   83  Linux
[root@local200-70 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             9.0G  3.3G  5.3G  39% /
/dev/sda1             965M   30M  886M   4% /boot
tmpfs                1006M  4.0K 1006M   1% /dev/shm


2.创建分区(以下红色为输入的命令)

[root@local200-70 ~]# fdisk  /dev/sda

The number of cylinders for this disk is set to 5221.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
  (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n #创建新分区
Command action
  e   extended
  p   primary partition (1-4)
p #创建主分区
Selected partition 4 #新建的主分区序号
First cylinder (2611-5221, default 2611):
Using default value 2611
Last cylinder or +size or +sizeM or +sizeK (2611-5221, default 5221):  #创建主分区大小,直接回车
Using default value 5221Command (m for help): w #保存创建的主分区

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

3.查看新的分区情况
[root@local200-70 ~]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         127     1020096   83  Linux
/dev/sda2             128        1402    10241437+  82  Linux swap / Solaris
/dev/sda3            1403        2610     9703260   83  Linux
/dev/sda4            2611        5221    20972857+  83  Linux

4.式化新创建的分区

如果创建完之后,/proc/partitions 查看不到对应的分区,使用parprobe 命令刷新一下就可以了: partprobe /dev/sda

[root@local200-70 ~]# mkfs -t ext3  /dev/sda4
mke2fs 1.39 (29-May-2006)
warning: 334 blocks unused.

Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2626560 inodes, 5242880 blocks
262160 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
16416 inodes per group
Superblock backups stored on blocks:
   32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
   4096000

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: 回车

5.挂载目录

mount /dev/sda4 /data

修改/etc/fstab ,添加

/dev/sda4              /data                   ext3    defaults        1 2

记住,不能这样写,否则服务器重起之后起不来

LABEL=/data             /data                   ext3    defaults        1 2


你可能感兴趣的:(硬盘,挂载)