Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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... ?

like image 332
w2lame Avatar asked Jan 20 '23 12:01

w2lame


1 Answers

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 the nbd kernel module was already loaded (with a different max_part parameter) when you ran modprobe.

You can fix that by unloading the module and modprobing it again.

like image 136
Vegard Avatar answered Jan 23 '23 01:01

Vegard