日前把一台有800G HD的linux server 在不停機的狀態下p2v轉到proxmox
記錄一下流程
linux server雖然不停機但是在轉換過程中資料不能有異動
1. 在原server上使用sshfs把proxmox的目錄mount進來
modprobe fuse
sshfs root@10.0.0.1:/mnt/data /mnt/10
2. 使用dd把原server的HD完整複制成一個raw檔
dd if=/dev/cciss/c0d0 of=/mnt/10/www.raw bs=1M
^^^^^^^
這個參數一定要加 加快速度
3. 在proxmox上新開的vm hd要指定為ide 格式為raw
否則開机時會出現kernel panic 無法開機
再來把www.raw更名為已開vm的檔名
4. guest os 要修正 /etc/udev/rules.d/70-persistent-net.rules 網卡編號
視需要修正crontab
在/etc/rc.local加上開机對時
修正後reboot
注意備份路徑
加上proxmox備分
5. 舊机器shutdown
2012/03/01
今天一台vm出現disk空間不夠的問題
參考以下的資料
搞定
改完後記得再用gparted 調整分割大小
修改虛擬機鏡像大小(qcow2/raw resize)
不多說,直接看
創建一個鏡像文件,大小1G,格式是qcow2
muxueqz@muxueqz /tmp $ qemu-img create -f qcow2 t.qcow2 1G
Formatting 't.qcow2', fmt=qcow2 size=1073741824 encryption=off cluster_size=0
查看鏡像文件實際佔用空間
muxueqz@muxueqz /tmp $ ls -alh t.qcow2
-rw-r--r-- 1 muxueqz muxueqz 193K 8月31 13:18 t.qcow2
查看qcow2信息
muxueqz@muxueqz /tmp $ qemu-img info t.qcow2
image: t.qcow2
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: 136K
cluster_size: 65536
加1G(resize +)
muxueqz@muxueqz /tmp $ qemu-img resize t.qcow2 +1G
Image resized.
再查看qcow2信息
muxueqz@muxueqz /tmp $ qemu-img info t.qcow2
image: t.qcow2
file format: qcow2
virtual size: 2.0G (2147483648 bytes)
disk size: 140K
cluster_size: 65536
減1G(resize -)
muxueqz@muxueqz /tmp $ qemu-img resize t.qcow2 -- 2G
qemu-img: This image format does not support resize
!!!qcow2只能加不能減!
再查看qcow2信息
muxueqz@muxueqz /tmp $ qemu-img info t.qcow2
image: t.qcow2
file format: qcow2
virtual size: 2.0G (2147483648 bytes)
disk size: 140K
cluster_size: 65536
果然沒變
再試試改變raw格式的大小(resize raw)
同樣先創建1G大小的raw
muxueqz@muxueqz /tmp $ qemu-img create -f raw t.raw 1G
Formatting 't.raw', fmt=raw size=1073741824
muxueqz@muxueqz /tmp $ qemu-img info t.raw
image: t.raw
file format : raw
virtual size: 1.0G (1073741824 bytes)
disk size: 1.0M
可以看出raw要比qcow2多佔一些空間。
加1G
muxueqz@muxueqz /tmp $ qemu-img resize t.raw -- +1G
Image resized.
muxueqz@muxueqz /tmp $ qemu-img info t.raw
image: t.raw
file format: raw
virtual size: 2.0G (2147483648 bytes )
disk size: 2.0M
減1G(resize -)
muxueqz@muxueqz /tmp $ qemu-img resize t.raw -- -1G
Image resized.
muxueqz@muxueqz /tmp $ qemu-img info t.raw
image: t.raw
file format: raw
virtual size: 1.0G (1073741824 bytes )
disk size: 1.0M
http://www.linuxzh.org/Linux/qemu_resize.html
參考以下的資料
搞定
改完後記得再用gparted 調整分割大小
修改虛擬機鏡像大小(qcow2/raw resize)
不多說,直接看
創建一個鏡像文件,大小1G,格式是qcow2
muxueqz@muxueqz /tmp $ qemu-img create -f qcow2 t.qcow2 1G
Formatting 't.qcow2', fmt=qcow2 size=1073741824 encryption=off cluster_size=0
查看鏡像文件實際佔用空間
muxueqz@muxueqz /tmp $ ls -alh t.qcow2
-rw-r--r-- 1 muxueqz muxueqz 193K 8月31 13:18 t.qcow2
查看qcow2信息
muxueqz@muxueqz /tmp $ qemu-img info t.qcow2
image: t.qcow2
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: 136K
cluster_size: 65536
加1G(resize +)
muxueqz@muxueqz /tmp $ qemu-img resize t.qcow2 +1G
Image resized.
再查看qcow2信息
muxueqz@muxueqz /tmp $ qemu-img info t.qcow2
image: t.qcow2
file format: qcow2
virtual size: 2.0G (2147483648 bytes)
disk size: 140K
cluster_size: 65536
減1G(resize -)
muxueqz@muxueqz /tmp $ qemu-img resize t.qcow2 -- 2G
qemu-img: This image format does not support resize
!!!qcow2只能加不能減!
再查看qcow2信息
muxueqz@muxueqz /tmp $ qemu-img info t.qcow2
image: t.qcow2
file format: qcow2
virtual size: 2.0G (2147483648 bytes)
disk size: 140K
cluster_size: 65536
果然沒變
再試試改變raw格式的大小(resize raw)
同樣先創建1G大小的raw
muxueqz@muxueqz /tmp $ qemu-img create -f raw t.raw 1G
Formatting 't.raw', fmt=raw size=1073741824
muxueqz@muxueqz /tmp $ qemu-img info t.raw
image: t.raw
file format : raw
virtual size: 1.0G (1073741824 bytes)
disk size: 1.0M
可以看出raw要比qcow2多佔一些空間。
加1G
muxueqz@muxueqz /tmp $ qemu-img resize t.raw -- +1G
Image resized.
muxueqz@muxueqz /tmp $ qemu-img info t.raw
image: t.raw
file format: raw
virtual size: 2.0G (2147483648 bytes )
disk size: 2.0M
減1G(resize -)
muxueqz@muxueqz /tmp $ qemu-img resize t.raw -- -1G
Image resized.
muxueqz@muxueqz /tmp $ qemu-img info t.raw
image: t.raw
file format: raw
virtual size: 1.0G (1073741824 bytes )
disk size: 1.0M
http://www.linuxzh.org/Linux/qemu_resize.html
訂閱:
文章 (Atom)