如果你磁盘分区是用LVM的话可以实现动态分配,直接用lvextend;
如果用传统分区的话,可以在分区上面再fdisk出需要的容量,然后挂载mount到主磁盘就行了。
此处讲的是lvm的lvextend
一、创建逻辑卷
[linux@localhost Desktop]$ su //切换root
Password:
[root@localhost Desktop]# fdisk -l //显示详解
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00053377
Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 2358 18631680 83 Linux
/dev/sda3 2358 2611 2031616 82 Linux swap / Solaris
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
#创建分区
[root@localhost Desktop]# fdisk /dev/sdb //对sdb磁盘进行操作
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): m //m查看文档
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n //n新建
Command action
e extended //扩展区
p primary partition (1-4) //主分区
p
Partition number (1-4): 1 //编号1
First cylinder (1-2610, default 1): //直接回车 什么都不甜 避免空间浪费
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +3G //多大容量
Command (m for help): p //查看情况
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x609a0236
Device Boot Start End Blocks Id System
/dev/sdb1 1 393 3156741 83 Linux
Command (m for help): w //保存 否则以上操作不管用
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#查看
[root@localhost Desktop]# df -h //磁盘空间占用情况
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 4.0G 13G 24% /
tmpfs 491M 372K 491M 1% /dev/shm
/dev/sda1 291M 34M 242M 13% /boot
[root@localhost Desktop]# fdisk -l //显示详解
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00053377
Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 2358 18631680 83 Linux
/dev/sda3 2358 2611 2031616 82 Linux swap / Solaris
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5b4abd65<