OpenVZ Forum

Home » General » Discussions » What is the difference between --devnodes and --devices?
What is the difference between --devnodes and --devices? [message #51105] Wed, 05 February 2014 14:21
PeterSteele is currently offline  PeterSteele
Messages: 5
Registered: February 2014
Location: United States
Junior Member
I created a CentOS 6 container and used --devnodes to make specific disks (block devices) available in the container. I decided to use the devnodes option to do this and used commands like this:

vzctl set 101 --devnodes sda:rw --save

After doing this, /dev/sda was visible in the container, and parted was able view this drive and all of its partitions.

However, we have an application that accesses one of the partitions of this drive as a raw device. It opens a handle to the device using code similar to this:

int fd = open("/dev/sdb2", (O_CREAT | O_RDWR | O_NOATIME | O_NONBLOCK | O_DIRECT), 0777);

This call failed, reporting the error "Operation not allowed". As an experiment I tried simplying the call to this:

int fd = open("/dev/sda2", (O_RDONLY), 0777);

which opens a read-only handle to the raw device. This failed as well. Unable to solve this problem, I decided to try --devices instead of --devnodes. My command was something like this:

vzctl set 101 --devices b:8:18:rw --save

where 8 and 18 are the major and minor numbers of the sda block device. This solved the problem--the open call worked correctly in this case.

So, what's the difference between these two approaches to making a block device visible in a container, and why would parted be able to access the device that's been created with --devnodes but a simple open call in C complain that the operation isn't permitted?
Read Message
Previous Topic: OpenVZ kernel based on CentOS 6.5?
Next Topic: OpenVZ running with CentOS in a VMWare VM
Goto Forum:

Current Time: Sun Oct 01 12:09:14 GMT 2023

Total time taken to generate the page: 0.02794 seconds