3

I have openvz vps and as I can see there's no disk device. But I really need to have a disk device there to check one thing.

The question is, can I create fake disk device that would be able to work with commands such as df or sfdisk?

Dmitrii Mikhailov
  • 199
  • 1
  • 1
  • 10

1 Answers1

1

I am not a user of OpenVZ, but on a standard Linux system I would create a big file and then just setup a loopback device.

# create 50mb file to act as my block device
dd if=/dev/zero of=/srv/loopfs bs=1M count=50
# setup loopback device
losetup /dev/loop0 /srv/loopfs
# verify that I have a loopback device.
fdisk -l /dev/loop0

Disk /dev/loop0: 52 MB, 52428800 bytes
255 heads, 63 sectors/track, 6 cylinders, total 102400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

# and detach the device because I am done.
losetup -d /dev/loop0

See:

Zoredache
  • 130,897
  • 41
  • 276
  • 420
  • 1
    Very good, but very irrelevant. – poige Jul 24 '14 at 18:15
  • Why? Are loopback devices blocked on openvz, or what? – Zoredache Jul 24 '14 at 18:17
  • 1
    It's OpenVZ specific question, everybody does know how to use `dd` and `losetup` in general. I guess it's even already answered in SF. – poige Jul 24 '14 at 18:19
  • I highly doubt 'everyone' knows how to use losetup. It is not a common task. I just did a search on OpenVZ, and some of the hits suggest that loopback devices may be used if OpenVZ is configured a certain way. – Zoredache Jul 24 '14 at 18:23
  • Well, it's trivial anyways, even if you're dull beggar to perceive "everybody" directly. Yeah, in OpenVZ you can set-up a VE to access block devices outside, but it's *outside* and you need access to VE0 aka HN to do that. – poige Jul 24 '14 at 18:26
  • @poige, I don't work with disks a lot in linux, so I didn't know about loop devices. – Dmitrii Mikhailov Jul 25 '14 at 05:34
  • 1
    Unfortunately, openvz doesn't allow working with loop devices. At least you can't do it without technical support from VPS provider. – Dmitrii Mikhailov Jul 25 '14 at 05:35
  • 2
    I'm being told by OpenVZ representative that block loopback device is intentionaly prohibited since it can crash the kernel. Fuse is being adviced for use instead. – poige Jul 25 '14 at 05:48
  • 1
    @poige, thanks! Could you add this info as answer so I could mark it? – Dmitrii Mikhailov Jul 25 '14 at 07:26
  • No, til it's on-hold, there's no way to provide answers to the question. – poige Jul 25 '14 at 07:31