Can you please describe how you changed the drive to fixed size?
For those who find Homestead/Vagrant/Virtualbox slow on Windows
There are a few threads on here and laravel.io in regard to how slow homestead can be on Windows. I appear to have solved this, or at least improved it drastically, without the negatives associated with some of the methods I've see mentioned.
Basically, you just need to change the VM to use a fixed sized 'drive' rather than a dynamically sized one. I'm not going to try write a guide on how to make this change on an existing vm 'drive' because it was a bit messy the way I did it, but there are a few guides you can find via google.
There are a couple of other tweaks I've done that improved speed slightly, but by far the most major performance increase came from the above.
Not sure if this has improve the random freezes I get when using vagrant ssh through git bash, but it's improved page loading substantially.
This was the guide I used http://maxrohde.com/2014/06/21/convert-dynamically-sized-virtualbox-vdi-hard-drive-to-fixed-size/
Let me know if you have any problems
Is there a way i can configure homestead to create a fixed size drive, instead of modifying the existing drive?
There's a few ways, some stuff here https://gist.github.com/christopher-hopper/9755310
And could be possible to edit the Vagrantfile for Homestead (taken from some random Vagrantfile on GitHub)
vb.customize ['createhd', '--filename', diskname, '--size', 8 * 1024]
vb.customize ['storageattach', :id, '--storagectl', 'IDE Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', diskname]
Personally, I don't think it will give that much performance gain. Reading up on it (creators of VirtualBox) saying it's not that much different apart from if you make the disk really small and the data (sectors) are close together.
I'd like to suggest another method to speed it up. (That does work in windows now!)
From this archived forum: https://laracasts.com/forum/?p=1757-slow-responses-on-homestead/0
Enabling NFS makes it significantly faster.
@Stricken suggested the following:
# EDIT:
# Reorder folders for winnfsd plugin compatilibty
# see https://github.com/GM-Alex/vagrant-winnfsd/issues/12#issuecomment-78195957
settings["folders"].sort! { |a,b| a["map"].length <=> b["map"].length }
# Register All Of The Configured Shared Folders
settings["folders"].each do |folder|
config.vm.synced_folder folder["map"], folder["to"],
id: folder["map"],
:nfs => true,
:mount_options => ['nolock,vers=3,udp,noatime']
end
And @adamwathan mentioned:
Make sure you edit /etc/nginx/nginx.conf and set "sendfile" to off if using NFS or you will run into weird caching issues.
I wanted to add to that discussion, but the thread is archived. It comes up as one of the first results for a search of the issue, so it's a shame I can't link from there.
It was mentioned in that thread that that solution doesn't work on Windows. Fortunately, I must missed that part and went to find a solution for NFS in windows. So I was lead to here, and found this great plugin that adds NFS support to vagrant in Windows. Simply install it:
$ vagrant plugin install vagrant-winnfsd
And add that NFS code to the homestead.rb (in windows C:\Users\username\AppData\Roaming\Composer\vendor\laravel\homestead\scripts\homestead.rb)
Find the section where it's already looping through the settings["folders"] and replace it with the nfs code.
And you should see massive speed increases.
EDIT: Added sort of folder in code to fix bug in winnfs
Should be on by default for Homestead ^
It seems working for me. thank you so much for guidance. I see there is delay in pages response in browser. any help in improving pages response ?
I've just implemented @phazei nfs steps and it works great. Great performance improvement! I'm using Windows 7 64bits
I've tried @phazei instruction's above and unfortunately vagrant hangs when mounting NFS shared folders. Any ideas?
@dusangregor Thanks for the tip, I tried disabling the firewall but I still get the following:
==> default: Exporting NFS shared folders...
==> default: Preparing to edit nfs mounting file.
[NFS] Status: halted
[NFS] Start: started
==> default: Mounting NFS shared folders...
At this point it just freezes
If it's not mounting properly, this might fix it if multiple folders are being attempted: https://github.com/GM-Alex/vagrant-winnfsd/issues/12#issuecomment-78195957
Basically there's a problem where path length makes a difference and mounting breaks if a longer dir path is before a shorter one. So they need to be in length acceding order, weird, huh?
Also, it seems that sometimes mounting it the first time works, but not subsequent times. The winnfsd service doesn't stop itself when stopping vagrant, so it needs to be killed manually between instances.
Oh, and make sure to update the vagrant winnfsd, there have been a number of fixes recently.
Hopefully that will help some people.
From:
"Booting (978.98ms)"
To:
"Booting (31.56ms)"
Wow! =D Thanks my friend.
Nice :)
I've done this, and set sendfile off, but i'm havin problems with caching... Someone know how to solve this?
@EliasSoares I'm having the same problem. Did you manage to solve it?
No, I've not solved this! :( I'm back to slow, but working, homestead.
It is just annoying AF
Hi
Had lots of problems after cloning github/bitbucket repos. Could not manually remove files, folders, etc. Back to dev on windows side and only use homestead for services that are not available in windows like beanstalkd, latest redis or any other.
Cheer
Every time after "homestead suspend", when I wanna turn homestead on again with "homestead up", it seems that works but website cant load in browser. so I have to destroy homestead and build it again to woks. (in this case when it loads, it will also open another cmd panel for vagrant-winnfsd, but for first case it doesn't come up) any idea? thanks
@Shovels If you didn't figure out why it was freezing I found here: https://laracasts.com/discuss/channels/requests/nfs-on-homestead-20/replies/23098 You need to install nfs server on your machine first, then you can reload or up
sudo apt-get install nfs-kernel-server
Thanks @alberto1el I actually run Windows, so needed to install the plugin (https://github.com/GM-Alex/vagrant-winnfsd ) but that didn't work either. (That is unless you mean this needs installing on the VM??)
In the end I ended up getting the VMWare license and VMWorkstation. NFS worked straight out the box :)
@Shovels, I did mean inside the VM, I also run Windows (7) and got the same error, after I installed the nfs server on the VM then I was able to 'vagrant up' and have the files synced, now is working smooth. (virtualBox for provider)
@alberto1el ahh... Thanks for the clarification - I'm guessing this means you need to do this every time you re-provision the box, or have you been able to add this to part of the config?
Homestead.yaml
folders:
- map: ~/Code
to: /home/vagrant/Code
type: "nfs"
That's all you need, Homestead will take care of the rest.
Thanks @sitesense - It was more if/where the following line was put into the config so that it's there the next time the box is created:
sudo apt-get install nfs-kernel-server
@sitesense I am not trying to disagree with you or anyone on this post but I did get the same 'error' @Shovels got:
==> default: Exporting NFS shared folders...
==> default: Preparing to edit nfs mounting file.
[NFS] Status: halted
[NFS] Start: started
==> default: Mounting NFS shared folders...
And the way I found out to make it work on my machine was to run this command on the VM
sudo apt-get install nfs-kernel-server
(Which I found here https://laracasts.com/discuss/channels/requests/nfs-on-homestead-20/replies/23098 )
Also edited the homestead.rb file (\Homestead\scripts\homestead.rb)
#Long short path bug
settings["folders"].sort! { |a,b| a["map"].length <=> b["map"].length }
# Register All Of The Configured Shared Folders
if settings.include? 'folders'
settings["folders"].each do |folder|
mount_opts = folder["type"] == "nfs" ? ['actimeo=1'] : []
config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil, mount_options: mount_opts
end
end
(I also the configured the yaml file with 'nfs' for the folders and installed the plugin (winnfsd) as instructed).
And @Shovels I have not tried to get that line in the provision script, at this point I do not know if it is a bug or a particular scenario we have, for now I only use that machine for a Laravel5 app I am working on.
@alberto1el Sorry, I hold my hands up! It seems I misunderstood the instructions on the Homestead installation page. Well, not misunderstood but took for granted that if the NFS flag was set then it would be installed when provisioned.
I have since looked at the script that provisions the VM and NFS is indeed NOT installed, so a bit of a let down - and a shortfall in the docs there.
A shame because it doesn't look that difficult to add.
Maybe this might help...
You'll find a file called after.sh in your .homestead folder. It's probably as simple as adding the command in here:
#!/bin/sh
# If you would like to do some extra provisioning you may
# add any commands you wish to this file and they will
# be run after the Homestead machine is provisioned.
Thanks @alberto1el and @sitesense for the clarification - I think this 'issue' has had a fair few people pulling their hair out. :)
@Shovels i am windows user , i faced your problem i found solution form me http://iteration9.com/2015/using-laravel-homestead-on-windows/ may help you
Please or to participate in this conversation.