標籤:
方式:LVM方式
第一步 增加分區:
1、VM—>編輯設定—>硬碟 下擴大磁碟(菜單操作不再贅複)。
2、使用fdisk 命令
fdisk /dev/sda
#用n命令建個P類型的磁碟,然後用t命令更改ID為8e(LVM類別)。
# p查看一下:
Disk /dev/sda: 17.1 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1044 8281507+ 8e Linux LVM
/dev/sda3 1045 1545 4024282+ 8e Linux LVM
最後w儲存
3、重啟一下伺服器,不然掛載不上建立的sda3、sda4,
第二步 加入VLM:
root#mkfs.ext3 /dev/sda3 ##格式化新增的分區)
root#lvm
lvm>pvcreate /dev/sda3 ##建立LVM硬分區
Physical volume "/dev/sda3" successfully created
lvm> vgextend VolGroup00 /dev/sda3 ##加入與/目錄同一個LVM組
Volume group "VolGroup00" successfully extended
查看一下:
lvm>pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 7.90 GB / not usable 23.41 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 252
Free PE 0
Allocated PE 252
PV UUID ua5FJN-jSLL-bGkp-w0XO-N8JG-MBR0-1yDzGW
--- Physical volume ---
PV Name /dev/sda3
VG Name VolGroup00
PV Size 3.84 GB / not usable 25.96 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 122
Free PE 122
Allocated PE 0
PV UUID mHKWzk-mQ1o-jkQB-0DZC-PVqW-w2R9-14y19G
把sda3變為LVM的虛擬磁碟(增加容量的關鍵)
lvm>vgextend /dev/VolGroup00/LogVol102 /dev/sda3
第三步 增加 /目錄容量
lvm> lvextend -L +3.8G /dev/VolGroup00/LogVol00
Rounding up size to full physical extent 3.81 GB
Extending logical volume LogVol00 to 9.69 GB
Logical volume LogVol00 successfully resized
# resize2fs /dev/VolGroup00/LogVol00 ##還要重新一下識別磁碟容量
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 2539520 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 2539520 blocks long.
最終確認結果:
lvm> lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID r9eG4x-njBD-z2HT-lmL2-2l81-P3XV-KVd0e4
LV Write Access read/write
LV Status available
# open 1
LV Size 9.69 GB
Current LE 310
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
增加一塊新硬碟
1。增加前先關閉VM,然後編輯VM屬性,增加一個vritual disk(scsi),其實是增加一個虛擬磁碟檔案。
hard disk2就是我新增加的
2。查看目前的磁碟結構
[[email protected] ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 905 7164990 83 Linux
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn‘t contain a valid partition table
//說明磁碟/dev/sdb還沒有被系統識別
3。分區
[[email protected] ~]# fdisk /dev/sbd
Command (m for help): n //輸入m獲得協助資訊,n建立分區
Command action
e extended
p primary partition (1-4)
p //建立主要磁碟分割
Partition number (1-4): 1 //指定分區的起始柱面
First cylinder (1-130, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130): //設定分區容量,直接斷行符號表示全部
Using default value 130
Command (m for help): t //改變一個分區的系統ID
Selected partition 1
Hex code (type L to list codes): L //查看檔案類型對應的Hex
85 Linux extended //linux ext3的hex是85
Hex code (type L to list codes): 85
You cannot change a partition into an extended one or vice versa
Delete it first.
Command (m for help): p //列出當前硬碟的分區
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 130 1044193+ 83 Linux
Command (m for help): w //儲存
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
4。查看現在的分區
[[email protected] ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 905 7164990 83 Linux
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 130 1044193+ 83 Linux
5。格式化分區
[[email protected] ~]# mkfs.ext3 /dev/sdb1 //格式化成ext3格式
6。掛載分區
[[email protected] ~]# mount /dev/sdb1 /tmp
[[email protected] ~]# df -h /tmp
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 1004M 1.3M 952M 1% /tmp
7。自動掛載
修改/etc/fstab
增加一行
/dev/sdb1 /sdb1 ext3 defaults 0 0
重起
本文出自 “技術成就夢想” 部落格,請務必保留此出處http://pizibaidu.blog.51cto.com/1361909/1641695
不損壞資料的情況下 linux磁碟如何擴充 LVM格式