So, today I needed to debug a performance problem I was having with my Linux virtual machine (vm). I was on the phone with a SAN vendor who had given me a performance testing program to install on linuxvm (don’t you just love my simplistic naming conventions?). But, the file was currently downloaded to my Windows virtual machine, and I needed to move it.
What would be the best method of moving this, and future files?
One idea that occurred to me was to create a Windows share and mount this in my linuxvm.
Here are the steps I took:
- Create a new non-administrative Windows user:
- Use Control Panel | Administrative Tools | Computer Management
- Expand Local Groups and Users | Users
- Right-click and select the New User menu item
- Enter a username and password
- Confirm the password by entering it a second time (make certain CAPS LOCK if off)
- Uncheck “User must change…” checkbox
- Check “User cannot change password” and “Password never expires” checkboxes
- Click the Create button
(Note: just to be cute, I named my non-administrative user “admin”)
- Create a Windows share:
- Open Windows Explorer in Windows
- Right-click in some convenient location | New | Folder menu item
- Name the folder something memorable (I called it share)
- Right-click the share folder, and select the Properties menu item
- Goto the sharing tab
- Click the “Advanced Sharing” button
- Check the “Share this folder” checkbox
- Click the Permissions button
- Click the Add button
- Enter the new user name (e.g. admin in my example) and click OK
- Give the new user full control if you want them to write files
(Note: by default the new user has only read rights. Also, best to remove read rights from the Everyone group.) - Click the Apply button and then OK
- Create a mount point in Linux:
- Login to your Linux machine (mine is called linuxvm)
- Become root (su – root)
- Change directory to your mount point (cd /mnt)
- Create a new directory (mkdir /mnt/xpshare)
- Mount the Windows share in Linux:
- Change directory to /etc (cd /etc)
- Edit the fstab file (vi fstab)
- Add a line which mounts the share
(Note: the line you add hard-codes the password of your Windows user, which is why the user should have no administrative privileges.) - Save and close (:wq)
- Restart services (mount -a) or reboot the vm (reboot)
The line added should be:
//winvm/share /mnt/xpshare cifs defaults,username=winvm/admin,password=password,uid=user,gid=group 0 0
Notice that this assumes your linux user is called “user” and is a member of the group “group”. Also, it is assumed that the Windows user is called “admin” and has a password of “password”. You should replace these generic values, with the values that are meaningful in your case.
Do not use a domain username in this command, because the fstab file is readable by everyone who has access to your linux vm. So, this is not a secure place to be putting domain passwords that have access to multiple machines. Needless to say, the password you use for this sharing purpose should not be re-used for other purposes in your domain.