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
Richard W.M. Jones
2013-May-31 07:55 UTC
Re: [Libguestfs] How to use libguestfs access LVM as non-root user?
On Fri, May 31, 2013 at 10:58:30AM +0800, Qiu Yu wrote:> Unfortunately, the standard 'disk' group permission only applies to > /dev/sdX device nodes, not to device mapper nodes created by LVM commands.Actually, it depends on udev rules. On my machine device mapper nodes very much are owned by the disk group: $ ll /dev/dm-* brw-rw----. 1 root disk 253, 0 May 15 13:26 /dev/dm-0 brw-rw----. 1 root disk 253, 1 May 15 13:26 /dev/dm-1 brw-rw----. 1 root disk 253, 10 May 24 13:54 /dev/dm-10 brw-rw----. 1 root disk 253, 11 May 15 13:26 /dev/dm-11 brw-rw----. 1 root root 253, 12 May 29 21:29 /dev/dm-12 [etc] You can add udev rules to change the ownership. See: https://wiki.archlinux.org/index.php/Udev Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Qiu Yu
2013-May-31 08:03 UTC
Re: [Libguestfs] How to use libguestfs access LVM as non-root user?
On Fri, May 31, 2013 at 3:55 PM, Richard W.M. Jones <rjones@redhat.com>wrote:> On Fri, May 31, 2013 at 10:58:30AM +0800, Qiu Yu wrote: > > Unfortunately, the standard 'disk' group permission only applies to > > /dev/sdX device nodes, not to device mapper nodes created by LVM > commands. > > Actually, it depends on udev rules. On my machine device mapper > nodes very much are owned by the disk group: > > $ ll /dev/dm-* > brw-rw----. 1 root disk 253, 0 May 15 13:26 /dev/dm-0 > brw-rw----. 1 root disk 253, 1 May 15 13:26 /dev/dm-1 > brw-rw----. 1 root disk 253, 10 May 24 13:54 /dev/dm-10 > brw-rw----. 1 root disk 253, 11 May 15 13:26 /dev/dm-11 > brw-rw----. 1 root root 253, 12 May 29 21:29 /dev/dm-12 > [etc] > > You can add udev rules to change the ownership. See: > > https://wiki.archlinux.org/index.php/Udev > > Rich. > >Thanks Richard, you're right. I just find out myself few moments ago. Actually I'm looking into an issue with OpenStack / Libvirt manipulating LVM as an image backend. When the logical volume is created, udev rules will set the ownership to root:disk. After libvirt actually starting an instance, device node ownership will change to qemu:qemu by libvirt. Then, if you stop an instance, the device node ownership will change back to root:root. Seems there's some inconsistency here. Anyway, it has nothing to do with the libguestfs. Thank you so much for your help and the information! :) -- 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?
- Strange problem with LVM, device-mapper, and software RAID...
- How to use libguestfs access LVM as non-root user?