Sharing files between host and guest under KVM

Patrick O'Callaghan pocallaghan at gmail.com
Tue Feb 9 00:13:25 UTC 2016


On Mon, 2016-02-08 at 22:13 +0000, Earl Ramirez wrote:
> On Mon, 2016-02-08 at 17:43 +0000, Patrick O'Callaghan wrote:
> > On Mon, 2016-02-08 at 12:35 +0900, Earl A Ramirez wrote:
> > > > Clearly this could be done using Samba or NFS. Is there an
> > > > easier
> > > > way?
> > > 
> > > Personally I have been using Samba, haven't seen an easier way.
> > 
> > Yes, that seems to be the way to go. I'm almost there (having
> > figured
> > out that I needed to open a hole in the host firewall), just having
> > a
> > problem getting the guest to authenticate. I don't understand CIFS
> > passwords :-(
> > 
> > poc

Thanks for the very complete reply.

> First you will need a local account on for this I usually create a
> user
> without any shell access
> $ sudo useradd -s /sbin/nologin smbuser
> 
> Then you will have to create the samba user
> $ sudo smbpasswd -a smbuser
> 
> start both samba services: 
> $ sudo systemctl start smb; sudo systemctl start nmb

For some reason I assumed that systemctl would start nmb automatically
with smb. Seems I was wrong.

> Open up the firewall ports
> $ sudo firewall-cmd --permanent --add-service=samba
> $ sudo firewall-cmd --reload
> 
> A very basic mount of the samba share
> $ sudo mount -t cifs -o username=smbuser,password=yoursmbpassword
> //192.168.124.1/smbshare /mnt/smbshare

I'm doing it the other way (mounting a Linux share on a Windows guest)
so this part is unnecessary.

> You can also use auto mount to achieve this or fstab; you can also
> use
> a credential file and only give root read only access.
> 
> if you are sharing your home directory don't forget to enable the
> SELinux boolean 
> $ sudo setsebool -P samba_enable_home_dirs 1

Check.

> Let me know if this helps

It did, I'm a happy camper. Thanks again.

poc


More information about the users mailing list