由於在裝軟件,原來的20G空間不夠使用,需要擴容操作。
1.關閉虛擬機
2.點擊編輯虛擬機設置
選中硬盤,添加,硬盤,推薦,確定大小,完成。
2.啟動虛擬機
查看磁盤使用情況:
[root@master ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 18G 3.0G 14G 18% / tmpfs 931M 80K 931M 1% /dev/shm /dev/sda1 291M 39M 238M 14% /boot /dev/sr0 3.6G 3.6G 0 100% /media/RHEL_6.5 x86_64 Disc 1
查看我們新的磁盤
對新加的硬盤進行分區,格式化,因為我的磁盤名稱是/dev/sdb,所以輸入 fdisk /dev/sdb命令:
[root@master ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xc2e1095b.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
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
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
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-652, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652):
Using default value 652
Command (m for help): p
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 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: 0xc2e1095b
Device Boot Start End Blocks Id System
/dev/sdb1 1 652 5237158+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
下一步,查看
格式化:
另一種格式化:mkfs -t ext3 /dev/sdb1
[root@master ~]# cd / [root@master /]# ls bin dev home lib64 media opt root selinux sys usr boot etc lib lost+found mnt proc sbin srv tmp var [root@master /]# mkdir exapp [root@master /]# mount /dev/sdb1 /exapp/ [root@master /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 18G 3.0G 14G 18% / tmpfs 931M 72K 931M 1% /dev/shm /dev/sda1 291M 39M 238M 14% /boot /dev/sdb1 5.0G 139M 4.6G 3% /exapp
這個是掛載上了
開機自動掛載,則修改 /etc/fstab 文件,在這個文件里面添加一行:
/dev/sdb1 /exapp ext3 defaults 0 0
然而:我想擴大 / 下的空間 ,關閉虛擬機,重新給虛擬機分配2G的空間,啟動
對磁盤進行分區
[root@master master]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x1b0e6bd8.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
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
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
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 4
First cylinder (1-261, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261):
Using default value 261
Command (m for help): p
Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 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: 0x1b0e6bd8
Device Boot Start End Blocks Id System
/dev/sdc4 1 261 2096451 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@master dev]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 3.0G 14G 18% /
tmpfs 931M 72K 931M 1% /dev/shm
/dev/sda1 291M 39M 238M 14% /boot
/dev/sdb1 5.0G 139M 4.6G 3% /exapp
[root@master master]# pvcreate /dev/sdc4 -- //創建物理卷
dev_is_mpath: failed to get device for 8:36
Physical volume "/dev/sdc4" successfully created
查看新建的物理卷和大小,使用pvdisplay命令。
為啥我的根目錄下沒有卷組?
根目錄下有卷組的話,vgextend ubuntu14-vg /dev/sdc4
vgdisplay 會顯示一個卷組信息
lvresize -L +120G /dev/mapper/ubuntu14--vg-root
resize2fs /dev/mapper/ubuntu14--vg-root
df -h
應該會添加成功。