Puppet -- Mount with Bind - puppet

I have a cluster of 500 linux boxes which now need to use the mount resource with the bind option (see man 8 mount) to support a chroot jail. The mount points need to be enforced and maintained after boot. I am unsure how to describe this state with puppet. Is it like this?
mount { "/gpfs20/home":
ensure => mounted,
name => "/chroot/centos5/home",
fstype => "none",
options => "(rw,bind)",
}
TIA -- Charles

For the record it is done this way:
mount { '/chroot/centos5/home':
ensure => mounted,
device => '/gpfs20/home',
fstype => 'none',
options => 'rw,bind',
}
~Charles~

Related

Confused by the source and target keyword in mount system call

I am implementing a container which is cloned with a new namespace including mount, pid, user namespaces, etc. The first step the child does is to mount several important points such as /proc, /sys and /tmp using mount system call.
if(::mount("proc", "/proc", "proc", 0, NULL)==-1) {
printf("Failed on mount: %s\n", strerror(errno));
return -1;
}
if(::mount("sysfs", "/sys", "sysfs", 0, NULL)==-1) {
printf("Failed on mount: %s\n", strerror(errno));
return -1;
}
if(::mount("tmp", "/tmp", "tmpfs", 0, NULL)==-1) {
printf("Failed on mount: %s\n", strerror(errno));
return -1;
}
However, I am a bit confused by the source field in the argument list passed to mount.
int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data);
What does the source mean exactly? For example, mounting /tmp seems have nothing to do with the source char string. I can still see a new /tmp folder created under the new namespace even using ::mount(nullptr, "/tmp", "tmpfs", 0, NULL). Am I missing something?
It is just supposed to match the argument such as those provided in your /etc/fstab file. For instance, on my fstab I have:
# <file system> <mount point> <type> <options> <dump> <pass>
...
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
But those examples are a bit different, because of their nature. Indeed, both proc and sysfs are not general filesystem. Hence, if you would have mounted a hard drive, the source would be more straightforward, being /dev/sda1 for instance.
And because you're implementing an isolation on top of namespaces, beware if the container calls umount on /proc for instance. It might reveal the host's proc, thus, breaking the isolation.
To add a bit to Aif`s answer: according to the mount manpage:
mount() attaches the filesystem specified by source (which is often a
pathname referring to a device, but can also be the pathname of a
directory or file, or a dummy string) to the location (a directory or
file) specified by the pathname in target.
In the case of tmpfs, it is very much a dummy string. You are simply creating a temporary file system. tmpfs is stored in volatile memory and is temporary, not really having a source.
For other filesystem types, source will be very important, specifying which filesystem you are mounting to that directory, e.g. /dev/sda1 or what have you.

mount: you must specify the filesystem type

I was trying to execute qemu while following the qemu/linaro tutorial,
https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Virtual_ARM_Linux_environment
I was executing the command,
sudo mount -o loop,offset=106496 -t auto vexpress.img /mnt/tmp
mount: you must specify the filesystem type
so i did fdisk on the img file and got the following,
Device Boot Start End Blocks Id System
vexpress.img1 * 63 106494 53216 e W95 FAT16 (LBA)
vexpress.img2 106496 6291455 3092480 83 Linux
The filesystem is Linux according to the fdisk command. But I get error,
sudo mount -o loop,offset=106496 -t Linux vexpress.img /mnt/tmp
mount: unknown filesystem type 'Linux'
Kindly help.
You correctly decide to mount the particular partition by specifying its offset but the offset parameter is in bytes and fdisk shows the offset in blocks (the block size is shown before the partition list --- usually 512). For the block size 512 the command would be:
sudo mount -o loop,offset=$((106496*512)) -t auto vexpress.img /mnt/tmp
If the automatic file system type detection does not still work there is another problem. Linux is not really a file system type. In the partition table it is a collective type used for multiple possible particular file systems. For mount you must specify the particular file system. In Linux you can list the supported ones by cat /proc/filesystems.

UBIFS mount in busybox via fstab does not recognize relatime option

I am getting this error when I try to mount my UBIFS filesytem:
mount -o remount,rw /config
UBIFS error (pid 1265): ubifs_parse_options: unrecognized mount option "relatime" or
missing value
The content of my fstab is :
root#drgos:~# cat /etc/fstab
# WARNING: this is an auto generated file, please use uci to set static filesystems
/dev/ubi0_0 /config ubifs ro 0 0
And when I type mount the result is :
root#drgos:~# mount
rootfs on / type rootfs (rw)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime,size=512k)
none on /dev/pts type devpts (rw,relatime,mode=600)
/dev/ubi0_0 on /config type ubifs (ro,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
I do not understand why I have the option relatime since that one is not present in my fstab!
I am using BusyBox v1.11.2 (2014-01-13 09:35:41 CET) multi-call binary.
These options are dependent on the Linux kernel version. relatime is a general mount options. relatime is the default for newer Linux kernels. Other filesystems may quietly ignore unknown options, whereas ubifs is failing. You can try mount -o remount,rw,noatime,norelatime /config. Your mount command shows the /config directory is mounted with relatime; this is information that busybox mount applet collected.
This information is collected with the getmntent_r() function. If busybox is dynamically linked, then the 'C' library may be giving this information as part of the *mnt_opts* string.
The idea with mount -o remount,rw,noatime,norelatime /config is to try and over-ride this information so that UbiFs will be happy with its mount options. The other way is to simply umount and then mount again manually.
umount /config
mount -t ubifs /dev/ubi0_0 /config
This way previous mount information will not be retrieved.

How do I check the filesystem type of a device?

I formatted a partition using mkfs.xfs /dev/mydevice in Ubuntu and then I mounted it using /etc/fstab. When I type mount, it tells me that my device is mounted as ext3.
Output of mount:
/dev/mydevice on /mnt/mymount type ext3 (rw,_netdev)
First question: How do I know if it's xfs or ext3? What am I missing?
Second question: If it's xfs, how do I know if it's xfs-256 or xfs-512?
loading the device in a utility like gparted tells you FS types.
for fstab file it's enough, I think, to say only xfs.

Mounting block device driver module on linux stopped working

I make block device driver module and insert module on Ubuntu. And then I want to mount that module as file system using 'mkfs'command. But, mkfs command didn't work more with following message:
writing superblocks and filesystem accounting information
mkfs doesn't mount block devices. It creates filsystems on them. (I hope that there was nothing interesting on you device; mkfs has deleted the data on block device). To mount a block devices (or better to say to mount the filesystem that is on the blockdevice) you must use mount:
# mount /dev/sda1 /mnt
(presuming /dev/sda1 is the device you try to mount).
Don't forget to unmount the device when you need it no more:
# umount /mnt

Resources