直接掛載虛擬機器內為LVM分割槽的映象

2021-06-22 10:14:17 字數 1785 閱讀 7177

如果虛擬機器內部做了lvm,則直接掛載lvm分割槽有點麻煩

詳細命令如下

[root@centos images]# fdisk -lu lvm-ubuntu.img 

you must set cylinders.

you can do this from the extra functions menu.

disk lvm-ubuntu.img: 0 mb, 0 bytes

255 heads, 63 sectors/track, 0 cylinders, total 0 sectors

units = sectors of 1 * 512 = 512 bytes

sector size (logical/physical): 512 bytes / 512 bytes

i/o size (minimum/optimal): 512 bytes / 512 bytes

disk identifier: 0x000c848f

device boot start end blocks id system

lvm-ubuntu.img1 * 2048 499711 248832 83 linux

partition 1 does not end on cylinder boundary.

lvm-ubuntu.img2 501758 20969471 10233857 5 extended

partition 2 has different physical/logical endings:

phys=(1023, 254, 63) logical=(1305, 73, 48)

lvm-ubuntu.img5 501760 20969471 10233856 8e linux lvm

通過上面的命令可以看到這個虛擬機器映象內做了lvm

通過下面命令可以掛載lvm分割槽

[root@centos images]# echo $((501760*512))

256901120

[root@centos images]# losetup -f

/dev/loop0

[root@centos images]# losetup /dev/loop0 lvm-ubuntu.img -o 256901120

[root@centos images]# pvscan

pv /dev/loop0 vg ubuntu-vg lvm2 [9.76 gib / 0 free]

total: 1 [9.76 gib] / in use: 1 [9.76 gib] / in no vg: 0 [0 ]

[root@centos images]# vgchange -ay

2 logical volume(s) in volume group "ubuntu-vg" now active

解除安裝分割槽的命令如下:

[root@centos images]# umount /image/

[root@centos images]# vgchange -an ubuntu-vg

0 logical volume(s) in volume group "ubuntu-vg" now active

[root@centos images]# losetup -d /dev/loop0

掛載虛擬機器映象檔案裡的 LVM 邏輯分割槽

如果按照 在 centos 上安裝和配置 kvm 這篇文章介紹的方法安裝 guest 作業系統到乙個 raw 檔案裡 virt install disk path home vpsee centos.img 那麼在以後的維護過程中就可能會遇到麻煩。比如,前段時間 vpsee 碰到一位使用者忘了 ro...

虛擬機器中archlinux嘗試LVM分割槽

archlinux created 星期六 26 一月 2013 本來是打算玩一下 lfs 的,總是用發行版 還幾年 ubuntu 入門版 linux 搞得自己太業餘了點 不過,lfs也沒多專業,好吧 但是呢官網 lfs 的 live cd 是比較老的,而且不更新了。於是乎,看來使用虛擬機器更好玩一...

為Linux虛擬機器掛載SD卡!

把讀卡器sd卡插上電腦,在vmware的選單欄上依次點vm removable devices usb devices 你的sd卡 如圖 此時,可以看到windows系統右下角彈出安全退出usb裝置的訊息提示,說明u盤已被虛擬系統識別,在vmware的右下角會看到乙個usb的圖示 通過 fdisk ...