Install/Update cifs-utils before mount smb - linux

I'm currently trying to get Vagrant to provision a working CentoOS7 image on Windows10, using Hyper-V. Vagrant 1.8.4, current latest.
I envcounter a problem where the provisioning fails and I need to workaround each time. The CentOS7 image is a minimal image and does not include cifs-utils, therefore the mount wont work. So, I need cifs-utils installed before mount.
Error:
==> default: Mounting SMB shared folders...
default: C:/Programs/vagrant_stuff/centos7 => /vagrant
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t cifs -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3`,sec=ntlm,credentials=/etc/smb_creds_4d99b2
d500a1bcb656d5a1c481a47191 //192.168.137.1/4d99b2d500a1bcb656d5a1c481a47191 /vagrant
mount -t cifs -o uid=`id -u vagrant`,gid=`id -g vagrant`,sec=ntlm,credentials=/etc/smb_creds_4d99b2d500a1bcb656d5a1c481a
47191 //192.168.137.1/4d99b2d500a1bcb656d5a1c481a47191 /vagrant
The error output from the last command was:
mount: wrong fs type, bad option, bad superblock on //192.168.137.1/4d99b2d500a1bcb656d5a1c481a47191,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount.<type> helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so.
As it is now, the provisioning has to fail, and I need to:
vagrant ssh (powershell)
(connect to instance via putty/ssh)
sudo yum install cifs-utils -y (putty/ssh)
(wait for install...)
exit (putty/ssh)
vagrant reload --provision (powershell)
This is obviously a pain and I am trying to streamline the process.
Does anyone know a better way?

You can install the missing package in your box and repackage this box so you can distribute a new version of this box containing the missing package.

In order to provision a vagrant box you need to create it from an iso. While preparing the box you can install all needed packages for you. In your case it is Hyper-v - https://www.vagrantup.com/docs/hyperv/boxes.html
Best Regards

Apparently my original question was downvoted for some reason. #whatever
As I mentioned in one of the comments above:
I managed to repackage and upload an updated version. Thanks for the advice. Its available in Atlas as "KptnKMan/bluefhypervalphacentos7repack".
Special thanks to #frédéric-henri :)

Related

No Internet on Custom Image VM for Azure

I launched an Ubuntu 18.04 VM with Azure. I installed a bunch of stuff that I need. Then, I used the dashboard to create a custom image from this machine. After that, I checked that the image was okay by launching some machines with that image. Everything seemed to be working fine.
Today, I launched a new instance with my custom image. Then I tried to install a few things with apt-get install and I get the following error (e.g. for unzip):
sudo: unable to resolve host ABCDEFG: Resource temporarily unavailable
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package unzip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'unzip' has no installation candidate
This same thing happens for any package I try to install. After testing some basic things with my repositories, I checked the internet connection with ping. E.g. ping www.google.com which is also not working. I launched a vanilla Ubuntu 18.04 instance and I am not having these problems with that machine.
I have also tried sudo reboot but no luck with that. I did notice that when the system booted it shows the following error, also indicating that something is wrong with the internet:
Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
Any help is greatly appreciated.
So, after some digging around, I found this answer to something similar: https://askubuntu.com/questions/1045278/ubuntu-server-18-04-temporary-failure-in-name-resolution.
I used the following command and the internet started working again:
sudo ln -s ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
This is a little different than the answer on askubuntu because this is on an Azure image. First, I noticed that my image was missing resolv.conf in /etc. Using ls -la /etc/resolv.conf on a different azure image, I saw that it was a symbolic link to ../run/systemd/resolve/stub-resolve.conf, so I created a link that matched this format on my machine and that fixed things.
** EDIT **
It's worth noting that when you deprovision the VM to create the custom image, it does say:
WARNING! The waagent service will be stopped.
WARNING! Cached DHCP leases will be deleted.
WARNING! root password will be disabled. You will not be able to login as root.
WARNING! /etc/resolv.conf will be deleted.
WARNING! xxxx account and entire home directory will be deleted.

How to fix virtualbox unknown filesystem type 'vbox'

I want to make a virtual machine for web development on archlinux guest that acts like vagrant box. I don't want to use vagrant box because I want to learn how to do things on my own first and I want to keep the disk space used by the machine at minimum as possible. For this I have installed and configured apache2, php, mariadb with a total of 640M used on disk. I have forwarded guest 80 port to host 127.0.0.1:8080.
I encounter an error with the vboxfs module, I have installed virtualbox-guest-module as described here and after a machine reboot tried:
mount -t vboxfs share_name mount_location and I get this error unknown filesystem type 'vbox'.
I have searched google and all the results make reference to the virtualbox-guest-utils from archlinux but the problem is I don't need all the dependencies that package has (alsa, xorg, video driver etc.) and I don't know witch deps I need or I don't need from that package... so I wander if it is possible and it is enough to use just the vboxfs module to be able to use the share functionality from Virtualbox.
You made a typo. It should be vboxsf instead of vboxfs. I did the same and was wondering why it doesn't work. So the full command is:
sudo mount -t vboxsf share_name mount_location
To remember the correct type you can think of it as the abbreviation of VirtualBox Shared Folder.

Can not install Guest Additions in VirtualBox for CentOS 6 guest

I've just got my guest box running CentOS working perfectly, except for one problem. I'm trying to mount a shared folder. I've followed the instructions for getting the shared folder "Mountable" by using this code:
VBoxManage sharedfolder add "TEST - 250" --name "github" --hostpath "C:\filepath\github"
Where "TEST - 250" is the name of the VM, "github" is the name of the folder as I'd like to call it in my VM, and "C:\filepath\github" is the directory path on the Windows host where I can find the contents I would like to share.
All seems well, and as instructed by Oracle, I am to use this command in the VM:
sudo mount -t vboxsf shared ~/host
I've made a directory off of the root called "host". The problem here is that I'm getting the following message:
mount: unknown filesystem type 'vobxsf'
Looking at this further, I'm told that in the /sbin/ folder, there should be a file called mount.vboxsf, where there is not.
I then read chapter 4 here: http://www.virtualbox.org/manual/ch04.html ... more specifically section 4.2.2.1.6 for Oracle Linux, Red Hat Enterprise Linux and CentOS. I follow ALL commands they ask for:
yum install dkms
yum update
yum install gcc
yum install kernel-devel
And just in case...
yum install kernel-uek-devel
All seem to work fine. I reboot the system to activate the updates. Once I login to the rebooted system, I type:
ls /sbin/mount*
... and I do NOT see the mount.vboxsf file. What am I doing wrong?
Also, is there a way to just get this file, and place it there? If I had that, I could perform my drive mounting, and be done with what I need to do. Any suggestions?
You need to install guest editions.
"The VirtualBox Guest Additions for all supported guest operating systems are provided as a single CD-ROM image file which is called VBoxGuestAdditions.iso. This image file is located in the installation directory of VirtualBox."
create mount directory
sudo mkdir -p /media/VirtualBoxGuestAdditions
mount guest additions iso
sudo mount -t iso9660 -o loop /installation/directory/of/VirtualBox/VBoxGuestAdditions.iso /media/VirtualBoxGuestAdditions/
Install guest additions
sudo /media/VirtualBoxGuestAdditions/VBoxLinuxAdditions.run
Then mount.vboxsf file should be in sbin and you can mount with
sudo mount -t vboxsf shared ~/host
See https://www.virtualbox.org/manual/ch04.html
After following the steps described by the given answer and experiencing a kernel header issue i came across this link which has a command that does simplify things.
/etc/init.d/vboxadd setup
Hope it helps future explorers on this question. :)
I got the same error.
When I tried to install VBoxGuestAdditions (Devices -> Insert Guest Additions CD Image) on Ubuntu 16.04 x86, it throws error message "Unable to insert the virtual optical disk ..."
SOLUTION:
1. Open a terminal and enter: sudo apt-get install virtualbox-guest-utils
Reboot and enjoy.
sudo ./whateverTheArchitectureTypeYouHaveIs.sh worked for me. By default, VBOXAddition folder is in /media/..

Accidentally deleted symlink libc.so.6 in CentOS 6.4. How to get sudo privilege to re-create it?

I accidentally deleted the symbol link /lib64/libc.so.6 -> /lib64/libc-2.12.so with
$ sudo rm libc.so.6
Then I can not use anything including ls command. The error appears for any command I type
ls: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
I've tried
$ export LD_PRELOAD=/lib64/libc-2.12.so
After this I can use ls and ln ..., but still can not use sudo ln ... or sudo -E ln .... I always get this err
sudo: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
It's a remote server so I can not use a live CD. I now have a ssh bash session alive but can not establish new ones. I have sudo privilege, but don't have root password.
So currently my problem is I need to run sudo sln -s libc-2.12.so libc.so.6 to re-create the symlink libc.so.6, but I can not run sudo without libc.so.6.
How can I fix it? Thanks~
I resolved the issue by using a statically linked version of "ln" that was already in the server's /sbin.
E.g., this restored it for my configuration:
/sbin/sln /lib64/libc-2.5.so /lib64/libc.so.6
A bit embarrassing :) but it happened to me as well on Ubuntu 12.04.3 (which is not CentOS 6.4 but I thought this could still help maybe).
Because my Ubuntu wouldn't start I used a liveUSB to boot up and then mounted my hard drive and created the symlink (I did have the file itself libc-2.15.so) and that did it.
Just a few specific details:
I asked a good friend to use his computer for half an hour
I Downloaded my exact Ubuntu iso (12.04.3, if you're on;y missing the symlink, it could be any version so much that it can mount drives) from here: link
I made sure his Ubuntu has usb-creator-gtk ($ sudo apt-get install usb-gtk-creator, I'm sure Windows has an equivalent usb boot creator)
Created the liveUSB using usb-creator-gtk
Booted my computer with it (you'll probably need to change your BIOS settings to allow external USB to be booted first)
Once I booted from the live USB I figured where my hard drive partition by running the Ubuntu partition tool (the live USB has one) - mine was of type ext4 and in /dev/sdb1
I mounted it by doing $ mkdir /home/ubuntu/mnt and then $ sudo mount-t ext4 /dev/sdb1 /home/ubuntu/mnt
I then proceeded to that folder $ cd /home/ubuntu/mnt
From that location I then created the symlink by $ sudo ln -s lib/x86_64-linux-gnu/libc-2.15.so lib/x86_64-linux-gnu/libc.so.6
After a reboot I was good.
Hope it helps you (or someone..)
I would add some thing more to #wilfo answer as same also happened with me [accidentally deleting lib.so.6 and was getting /sbin/init missing libc.so.6 on boot up] .
After creating liveUSB in windows (using UNetbootin etc [http://unetbootin.sourceforge.net/]) or in ubuntu as #wilfo suggested.
Booting from liveUSB, I selected "experience ubuntu without installing it" and was happy applying wilfo's method until step 6 and then i couldn't find my hard drive partition of type ext3/4. All were nftf/fat/extended stuff.
So i recovered previous ubuntu (the one with missing libc.so...) by following this link
https://help.ubuntu.com/community/Boot-Repair
make sure to follow all necessary steps and take a backup of your ubuntu partition.
you can see your previous ubuntu files inside /mnt/boot-sav/wubi1/home
take a backup from here to your windows partations /mnt/boot-sav/sda...
and follow remaining procedure here https://help.ubuntu.com/community/Boot-Repair

SCP error: Bad configuration option: PermitLocalCommand

When I execute this command below:
scp -P 36000 hdfs#192.168.0.114:~/tmp.txt SOQ_log.txt
I get an error:
command-line: line 0: Bad configuration option: PermitLocalCommand
Does anyone know why?
scp runs a copy of the ssh program to create the communications channel, and it runs ssh with the options:
-oForwardAgent=no -oPermitLocalCommand=no -oClearAllForwardings=yes
So that explains where the "PermitLocalCommand" option is coming from in the first place. I'll add that sftp uses the same options to run ssh, so it'll probably display the same behavior.
"PermitLocalCommand" is normally a valid ssh configuration option. If your copy of ssh is complaining about it, then it seems that your copy of ssh isn't the normal copy of ssh that goes with your copy of scp.
This serverfault question suggests that the error could be due to someone installing a malware version of ssh (ie, a rootkit) on your system. This forum thread also suggests that the problem is due to having an altered version of ssh, which was fixed by removing and reinstalling the OpenSSH client utilities.
An alternate explanation would be that someone--maybe your Linux distro maintainer--has installed a version of ssh on your system with that option removed, and you're using it unawares. Or you have a very old version of the ssh program for some reason, which doesn't support the option.
My system is CentOs 5.9
I'm facing the same problem, I found it to be due to this configuration line in /etc/ssh/sshd_config:
# override default of no subsystems
Subsystem sftp /opt/libexec/sftp-server
But I cannot run /opt/libexec/sftp-server, it is broken for some reason
now it is solved by reinstall the remote openssh-server:
yum erase openssh-server
yum install openssh-server
now the changes to
# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server
and /usr/libexec/openssh/sftp-server is runnable
don't forget to execute:
/etc/init.d/sshd restart
Sometimes command cannot parse this kind of stuff
:~/
Id change it to the full path.

Resources