Qiu Yu
2013-May-30 14:21 UTC
[Libguestfs] How to use libguestfs access LVM as non-root user?
Hi, Following code snippet, running as non-root user, will throw up a 'Permission denied' RuntimeError. Could someone kindly guide me the correct way to handle LVM disk as non-root user? Cause as http://libguestfs.org homepage claims, "libguestfs doesn't need root permissions." A little confused somehow. import guestfs g = guestfs.GuestFS() g.add_drive_opts("/dev/vg0/disk1", format="raw") Thanks! -- Qiu Yu
Richard W.M. Jones
2013-May-30 16:48 UTC
Re: [Libguestfs] How to use libguestfs access LVM as non-root user?
On Thu, May 30, 2013 at 10:21:42PM +0800, Qiu Yu wrote:> Hi, > > Following code snippet, running as non-root user, will throw up a > 'Permission denied' RuntimeError. > > Could someone kindly guide me the correct way to handle LVM disk as > non-root user? > > import guestfs > g = guestfs.GuestFS() > g.add_drive_opts("/dev/vg0/disk1", format="raw")Libguestfs doesn't do anything different from any other program. I'm assuming that /dev/vg0/disk1 isn't accessible by non-root (by anyone) on your host. On most Linux distros you can add yourself to the 'disk' group in order to get access to disk devices: # usermod -G disk -a yourusername You may need to log out and log in again after doing that.> Cause as http://libguestfs.org homepage claims, "libguestfs > doesn't need root permissions."Right. This doesn't mean that libguestfs bypasses OS permissions. It just means that root isn't required unnecessarily. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Qiu Yu
2013-May-31 02:58 UTC
Re: [Libguestfs] How to use libguestfs access LVM as non-root user?
On Fri, May 31, 2013 at 12:48 AM, Richard W.M. Jones <rjones@redhat.com>wrote:> On Thu, May 30, 2013 at 10:21:42PM +0800, Qiu Yu wrote: > > Hi, > > > > Following code snippet, running as non-root user, will throw up a > > 'Permission denied' RuntimeError. > > > > Could someone kindly guide me the correct way to handle LVM disk as > > non-root user? > > > > import guestfs > > g = guestfs.GuestFS() > > g.add_drive_opts("/dev/vg0/disk1", format="raw") > > Libguestfs doesn't do anything different from any other program. I'm > assuming that /dev/vg0/disk1 isn't accessible by non-root (by anyone) > on your host. > > On most Linux distros you can add yourself to the 'disk' group > in order to get access to disk devices: > > # usermod -G disk -a yourusername > > You may need to log out and log in again after doing that. >Unfortunately, the standard 'disk' group permission only applies to /dev/sdX device nodes, not to device mapper nodes created by LVM commands. Thank you for the clarification on libguestfs. I'll try to find out other way to handle LVM device nodes as non-root user. -- Qiu Yu
Maybe Matching Threads
- Re: How to use libguestfs access LVM as non-root user?
- Re: How to use libguestfs access LVM as non-root user?
- Re: How to use libguestfs access LVM as non-root user?
- Re: How to use libguestfs access LVM as non-root user?
- Re: [ovs-discuss] Libvirt "tc ingress qdisc" automatically removed by ovs vlan tag setting, how?