日期:2014-05-16  浏览次数:20689 次

linux增加根目录的磁盘空间(LVM)

第一步:添加磁盘

第二步:使用Linux下的fdisk工具进行分区

?

?

用root用户登录:

打印当前的磁盘分区表,这时我们可以看到磁盘的总量的确增加到30GB 了,但是分区只有以前的那几个原有的分区
[root@localhost ~]# fdisk -l

?

键入命令: fdisk /dev/sda?? “sda 就是经过扩容的硬盘,为 SCSI 硬盘, IDE 类型硬盘对应为 hda ,是对该硬盘进行操作 ”?

选择主分区吧,则键入 p

此时, fdisk 会让你选择主分区的编号,如果已经有了主分区 sda1 , sda2 ,那么编号就选3 ,即要创建的该分区为 sda3.?
键入:???? 3?

?

此时, fdisk 又会让你选择该分区的开始值这个就是分区的 Start 值( start cylinder );这里最好直接按回车, 如果您输入了一个非默认的数字,可能会造成空间浪费;

对于分区的 End 值(end cylinder),同样直接按回车。这时候会显示出你新建分区的柱面范围和空间大小。

此时键入: w??? 表示" 保存所有并退出,分区划分完毕 "

[root@localhost ~]# fdisk /dev/sda


The number of cylinders for this disk is set to 3916.
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
Partition number (1-4): 3
First cylinder (1045-3916, default 1045):?
Using default value 1045
Last cylinder or +size or +sizeM or +sizeK (1045-3916, default 3916):?
Using default value 3916


Command (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 16: 设备或资源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

?

我们的新建分区/dev/sda3,却不是LVM的。所以,接下来使用fdisk将其改成LVM的。

[root@CNGI-SIP6-BUPT ~]# fdisk /dev/sda
Command (m for help): m?
Command (m for help): t //改变分区系统id??????
Partition number (1-4): 3 //指定分区号
Hex code (type L to list codes): 8e //指定要改成的id号,8e代表LVM。

Command (m for help): w

[root@localhost ~]# fdisk /dev/sda


The number of cylinders for this disk is set to 3916.
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 softwa