Mounting a disk


#1

About 6 months ago, maybe 7, I posted a question about mounting a disk volume for use with containers on RancherOS. The only working answer was to create a startup.sh file and have that manually mount any other disk volumes that happen to be on the box.

I have to say that is not a satisfying response. Operating Systems have been able to mount multiple disks without having to write custom startup scripts since the 1980’s. Even DOS could do this :slight_smile:

What am I missing? The documentation hints that a cloud-config.yml operator “mounts” exists. I’ve tried several incantations without success. Here’s what I want to do: I want to mount /dev/vbd (that’s right there is no partition) onto /mnt/s on bootup. According to the docs, adding mounts: [[“vdb”,"/mnt/s",“ext4”,“defaults”]] to cloud-config.yml via ros config set is the way to do this. Even with RancherOS 0.5, the device does not get mounted. So I do this:

ros config set mounts ‘[["/dev/vbd","/mnt/s",“ext4”,“defaults”]]’

or this:
ros config set mounts ‘[[“vbd”,"/mnt/s",“ext4”,“defaults”]]’

and reboot. /mnt/s doesn’t have the device mounted (/mnt/s exists, it’s empty). The device is not mounted at all anywhere. Mounting it by hand mounts the device.

I’ve tried editing /etc/fstab, but of course that doesn’t work because it just gets replaced on startup. Not sure where else to turn (and avoid writing a script to mount the device).

I feel like I’m really missing something fundamental here. Surely there are other people who would like to mount more than the root volume onto a RancherOS based host for use by containers. How are they accomplishing this?

Thanks for you time, desperately trying to adopt RancherOS…

-Eric


#2

We recently updated our docs regarding this and hopefully this updated page will help.

http://rancher.com/docs/os/latest/en/storage/additional-mounts/


#3

Hi Denise. Thanks for the response. Unfortunately, it does not help. As I said in my note, I’ve tried the mounts directive with no success. Perhaps you can give it another look and help me see where I’m making the mistake?

All I’m trying to do is mount a second disk so that multiple containers can use the second disk without having to write a custom script to run a mount command on bootup.

Thanks again!

-Eric


#4

Are there any issues if you try performing the mount manually in the console container?

Would you mind trying to use an empty string rather than defaults as the last parameter for the cloud-config mount? That might be a concept specific to the mount command and not the syscall (which RancherOS uses internally).


Mounting external NFS shares on RancherOS nodes
#5

No issues manually mounting. Did this and rebooted:

[root@be002 ~]# ros config set mounts '[["/dev/vdb","/mnt/s","ext4",""]]'
[root@be002 ~]# ros config get mounts
- - /dev/vdb
  - /mnt/s
  - ext4
  - ""

and… it worked. Cool! So it might be a good idea to update the storage page in the docs to give a more concrete example. https://cloudinit.readthedocs.io/en/latest/topics/examples.html#adjust-mount-points-mounted shows that the fourth element of the array are for mount options; apparently “defaults” is not a valid mount option (don’t know why).

Thanks @joshwget!!

-Eric


#6

Thanks for trying that out! I agree, it’s not a particularly helpful example. I’ll update that and add a note about using defaults.


#7

Probably important to notice, that this seems not to work on 0.4.5:

[root@rancher conf]# ros os version
v0.4.5
[root@rancher conf]# ros config set mounts '[["/dev/vdb","/data2","ext4",""]]'
[root@rancher conf]# ros config get mounts

So it seems to not be able to set it

while under 0.5.0

[root@rancher rancher]# ros os version
v0.5.0
[root@rancher rancher]# ros config set mounts '[["/dev/vdb","/data2","ext4",""]]'
[root@rancher rancher]#  ros config get mounts
- - /dev/vdb
  - /data2
  - ext4
  - ""

@denise this is probably something for the docs, so people know when the feature has ben introduced


#8

@EugenMayer The docs currently have been written to assume that you are running v0.5.0 as we introduced a lot of new features that don’t exist in previous releases. We hope our users to adopt the latest versions of RancherOS as we are constantly improving and stabilizing it.

We also don’t have the bandwidth to version the docs for RancherOS at this time. There are no plans on versioning RancherOS docs until GA.


#9

@denise i understand that versioning docs is not a minimal time job. Just maybe a notice. I tried to get this feature working for over one hour. The issue is, you do not have any error message when seeing mounts in 0.4.5 and due to this, it could make sense, warning you user base.

Also this is not mentioned in the changelogs, only shared mounts are mentioned there (and resizefs)

A lot of other features introduced at least have an error or “missing” button making it easy to distinct.

Nevertheless, its not too critical either - maybe google will help one or the other


#10

I am seeing a similiar issue, AWS w/the 0.5.0 AMI, using a preformatted 50G ext4 volume for /dev/xvdf:

# ros os version
v0.5.0

# ros config get mounts
- - /dev/xvdf
  - /var/lib/docker
  - ext4
  - ""

# fdisk /dev/xvdf
[snip]
Device /dev/xvdf already contains a ext4 signature.

My cloud-config:

#cloud-config
mounts:
  - ["/dev/xvdf", "/var/lib/docker", "ext4", ""]

Yet no mount and no error message about it in any docker or system log.

I used a preformatted volume as I can’t find a way to format a new EBS volume at boot time.


#11

If you perform the mount manually does it work? Can you show the output of system-docker logs console?


#12

It doesn’t seem to work on v0.7.1 when booting from iso with a RENCHER_STATE drive set.

[rancher@rancher ~]$ sudo ros os version
v0.7.1
[rancher@rancher ~]$ sudo ros config get mounts
- - /dev/sdb
  - /mnt/sdb
  - ext4
  - ""

Edit:
Never mind, it works. I had to create /mnt/sdb prior boot.


#13

Just stopped to say that seems link you provided doesn’t work.


#14

@Mountain_Storm updated to http://rancher.com/docs/os/latest/en/storage/additional-mounts/ .


#15

FYI - I know this is an old thread but trying to find info on where this is documented. This link redirects to:
https://rancher.com/docs/os/v1.x/en/storage/additional-mounts/
Which is also a 404


#16

https://rancher.com/docs/os/v1.x/en/installation/storage/additional-mounts/


#17

Coming back to this. Without a nfs client i can just mount via a simple line:
sudo mount -t nfs4 192.168.0.2:/mnt/volume01/data /mnt/data

However when i translate thet line to a cloudconfig with either:

#/var/lib/rancher/conf/cloud-config.d/z.yml
mounts:
- ["192.168.0.2:/mnt/volume01/data", "/mnt/data", "nfs4", ""]

or with

ros config set mounts '[["192.168.0.2:/mnt/volume01/data", "/mnt/data1", "nfs4", ""]]'

it just doesnt work, what am i missing, i crawled by now through the documentation that is available or cached 404 pages, along side closed github issues. does anyone have a pointer here?


#18

@bott0r


Try using runcmd:

#cloud-config
runcmd:
  - [ mkfs.ext2, /dev/nvme1n1 ]
  - [ mkdir, -p, /storage]
  - [ mount, -t, ext2, /dev/nvme1n1, /storage ]

#19

I tried various combinations and it wont work for me on 1.5.
this is the last i tried.

#cloud-config
runcmd:
- [ mkdir, -p, /mnt/storage]
- [ mkdir, -p, /mnt/data]
- [ "mount", "-t", "nfs4","192.168.0.2:/mnt/volume01/data", "/mnt/data" ]

Folders get created, but nothing will be mounted, if i take the quotation marks away ros config validate will complain. anything else i could try?


#20

I will try nfs on my own rancheros1.5 and will give you feedback tomorrow.