Changing password of a Virtual Machine
I have some virtual machines with me. I want to write a script which automates the following process...
- It mounts the virtual machine (with linux as the os) to a location say /mnt/image
- It modifies the /etc/passwd (or the equivalent file) to change the password of the user
- Unmount the virtual machine
Since, I am using libvirt I am having some qcow2 images of the virtual machine. to mount the image on my ubuntu, I am using nbd module. Here are the commands that I am trying :
modprobe nbd max_part=63
qemu-nbd -c /dev/nbd0 image.qcow2
mount /dev/nbd0p1 /mnt/image
It gives me the error:
mount: special device /dev/nbd0p1 does not exist
When I replace nbd0p1 with nbdo I am getting the following error (though I am not sure what I am trying to do by this)
mount: you must specify the filesystem type
Any suggestions so as what could be the problem... ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Check that
/sys/modules/nbd/parameters/max_part
has the expected value. If it's 0 or too low, the partitions/dev/nbd0p1
, etc. will not be made available by the kernel. This can happen if thenbd
kernel module was already loaded (with a differentmax_part
parameter) when you ranmodprobe
.You can fix that by unloading the module and modprobing it again.
[Not a direct answer to the question, but an alternate]
You can try to convert qcow2 image to raw and then, mount the raw image.
convert:
mount:
Could it be that the partition isn't in the first slot in the MBR, or an extended partition is in use? Check to see if any other
nbdXpY
device nodes are being created, or runfdisk
on it andp
rint the partition table.I stumbled on the same issue and same error but on a vdi
for me the solution was simple I just changed
nbd0
tonbd1
and then:
worked.
Please leave a comment if this worked for you also and on what type of image.