I am trying to mount /boot/config-4.14.90-v8 on to /usr/src/linux/.config. I’ve tried:
rpi-4.14.y:linux Necktwi$ sudo mount -o loop,ro -t vfat /boot/config-4.14.90-v8-g6d68e517b3ec /usr/src/linux/.config mount: /usr/src/linux/.config: cannot mount /dev/loop0 read-only.
notice the error cannot mount /dev/loop0 read-only.
rootfs is btrfs
/boot is vfat
/usr/src is nfs (I mounted remote server’s /usr/src)
I tried mount --bind but it failed.
rpi-4.14.y:linux Necktwi$ sudo mount --bind /boot/config-4.14.90-v8-g6d68e517b3ec /usr/src/linux/.config mount: /usr/src/linux/.config: bind /boot/config-4.14.90-v8-g6d68e517b3ec failed.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
If you want to mount a single file, so that the contents of that file are seen on the mount point, then what you want is a bind mount.
You can accomplish that with the following command:
# mount --bind /boot/config-4.14.90-v8 /usr/src/linux/.config
You can use -o ro to make it read-only on the /usr/src/linux/.config path.
For more details, look for bind mounts in the man page for mount(8).
Loop devices do something similar, yet different. They mount a filesystem stored into a regular file onto another directory.
So if you had a vfat or ext4 etc. filesystem stored into a file, say /vol/myfs.img, you could then mount it into a directory, say /mnt/myfs, using the following command:
# mount -o loop /vol/myfs.img /mnt/myfs
You can pass it -t vfat etc. to force the filesystem type.
Note that the -o loop is usually not needed, since mount will figure that out by you trying to mount a file and will do that for you automatically.
Also, mounting a file with -o loop (or automatically detected) is a shortcut to mapping that file to a /dev/loopX device, which you can also do using losetup, and then running the mount command, such as mount /dev/loop0 /mnt/myfs. See the man page for losetup(8) for details on loop devices.
Method 2
While you cannot mount a normal file, you could create a symbolic link /usr/src/linux/.config pointing to the specific local kernel config file. As your configs differ, this method has its own traps as you also would have to maintain a symbolic link locally like /boot/config-default pointing to the actual config file which then can be used in the NFS share.
Better would be to use the environment variable KCONFIG_CONFIG to point to alternate kernel configuration file.
make menuconfig KCONFIG_CONFIG=/boot/config-4.14.90-v8
From kernel.org:
KCONFIG_CONFIG -------------------------------------------------- This environment variable can be used to specify a default kernel config file name to override the default name of ".config".
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0