How to use a Mac Mini as a file server

How to use a Mac Mini as a file server


So a lot of my viewers keep asking me to explain how I’m using a Mac Mini G4 as a file server. So I thought I’d go ahead and put this video together, and I would like to go ahead and point out that the vast majority of everything I’m going to be showing you in this video Probably is not Mac Mini G4 specific would probably apply to almost any Mac whether it be Intel, G4, a laptop, or desktop, etc. I would also like to point out that there’s probably a lot of different ways to make a Mac Mini into a file server I’m just going to show you the way that I’m doing it and it may or may not even be the best way, but here you go Assuming you were going to use a G4, one of the things you’ll notice is that you only have two USB ports and one Firewire 400 port. You could use USB drives, but you’d need a USB hub in order to get them all connected. So for the G4, Firewire is definitely the way to go. Most of the newer drives are Firewire 800 which uses a different connector type. Fortunately, you can buy a 400 to 800 cable which will allow you to use the newer drives, but it will still be at the slower 400 speed. Don’t worry though, even Firewire 400 is still faster than USB 2.0 ports on this computer. I would just like to go on record and say something about the Firewire thing here, and even though I love Firewire, and I think it’s one of the best buses for connecting external drives, it is actually on its way out, and everybody in the industry is well aware of that. It’s been on its way out for the last couple of years and I think the USB 3.0 pretty much put the last nail in the coffin. So I would just Urge you to keep that in mind if you’re thinking about going out and buying a whole bunch of drives to use as a file server That would have firewire as the main connection. With Firewire I can daisy-chain one drive to another so that all four drives are working from that single Firewire port on the computer. When mounted, you should be able to see all of the drives on the desktop of the computer. In my case I have two primary drives named Storage01 and Storage02. I also have two backup drives named Backup01 and Backup02 – I’ll explain how the backups work later in the video. The first order of business would be to share the files that you want to share. With a Mac you can share files using four different protocols. You have AFP, or Apple Filing Protocol. This is the most common type of file sharing between two different Apple computers. You can also share with SMB, or Server Message Block. This is most commonly used with computers running Microsoft Windows. The third method is NFS, or Network File System, commonly used by Unix systems or Linux. Also, there is FTP, or File Transfer Protocol, and this is commonly used for transferring files over the internet. The easiest way to share your files is to go into the System Preferences and click Sharing. Look for the Checkbox for File Sharing and enable it. Once enabled, you can pick the drives or folders that you want to share, as well as who has access to them. By default, this shares folders using AFP. If you want to share for Windows computers or FTP, then click Options and you’ll have the choice to also share with FTP or SMB. If you want to share with NFS, you’ll have to do this from the terminal. So go to your Applications Folder, then Utilities, and find the terminal. Once opened, you’ll want to navigate to the ETC folder. Then you’ll edit a file called Exports. You’ll want to start by adding the path of the folder you want to share. In my case, I’m sharing a folder called Video, located on my external hard drive called Storage02. Then you’ll need to give an IP range and subnet mask that will be allowed to access this folder. I’m sorry I can’t explain this in more detail as would just take too long. Then hit Control-X to exit and save the file. You’ll need to make sure NFS File Sharing is enabled by typing sudo nfsd enable. In my case, it’s already running. You can type showmount -e in order to verify which folders are being shared. Okay, so if you’re still here, and you’re still following, I’m going to show you how to set up a script that will back up one drive to another. Now, I realize Apple provides Apple Time Machine which, I’m not real big fan of. I like to be able to have a little bit more control over what’s going on so I’m going to show you how I do it. Okay, So the first thing to do is double check the names of the hard drives you’re going to be working with. Type CD / to get to the root folder and then type LS to get a directory listing. You should see a folder called Volumes. Let’s go into that folder by typing CD Volumes. If you type LS here, you’ll see a list of all of the mounted drives on the system. There are five showing because one of them is my internal hard drive on the Mac Mini. The other four are the external drives. So let’s go back to the root folder and find a folder called Users. I’m going to go into dmurray since that’s my folder. At this point, I’m going to type sudo nano backupscript. Just to briefly explain what this means, you put sudo in front of a command if you want the command to have administrator privileges. Nano is the name of a great little text editor that you can run from the command line and is also very popular on Linux and other Unix systems. Backupscript is simply the name I am giving to the file that I’m creating, which is going to be a script for running my backup. I hope that clears things up. Notice that it asks for a password. This is because I used the sudo command. The password will not display but you’ll have to type the administrator password and press return. Okay, so I’m going to use the rsync command which will duplicate an entire folder from one location to another. -a stands for archive and progress tells it to show me what it’s doing as the command runs. Next I give it the path of the folder I want to copy on Storage01, and then I give it the path of where I want it to go on Backup01. In this case I’m copying a folder called pictures. I end with exit 0 to tell it to close the script when it’s done. Notice that if I browse to my personal folder, I will see the file I created here called backupscript. But it’s not yet executable so we need to fix that. So I’ll go back to the terminal and I’ll type sudo chmod +x backupscript You’ll notice the icon changed after I pressed enter. You’ll want to test the script. I opened up both hard drives on the screen together. You can see several folders on one and the other drive is empty. I’m going to double click the script to test it. If the script works, you should see the pictures folder begin to copy to the backup drive. Not only can you see the script running, but you can see the picture folder was created in the empty drive. Also you can see the lights flashing like crazy on the two drives that are working. The script obviously works. Ok so now that we’ve got a working script, what we need to do is set it so that that script runs by itself automatically every night. Now you can do this by setting up a Unix cron job, but I’m gonna make it a lot easier for you an show what I do. I actually downloaded and installed a free program called CronniX and it’ll set this up for you. Watch how it works. So, open CronniX, then click New. Click the Prepend button and add the full path to the script. In my case, that’s users/dmurray/backupscript Then click Simple to set up the time. Put a checkmark in Day of Month, Month, and Day of Week. This essentially means the script will run every day. I’m putting my hour slider at the 2, which means it will run at two o’clock in the morning. Then just click New and Save. Okay, now what I just showed you will work just fine and the script should run it at two o’clock in the morning. Now, The problem with this script is that it will leave a terminal window open in the morning when you turn on the monitor and look. Now that can be really annoying especially if you don’t use the computer very often, you may turn on the monitor in one morning and see 50 terminal windows up on your screen. Now I recommend doing it this way at least once just to make sure the script actually runs at 2:00 in the morning because you’ll be able to tell when you come in the next morning. Once you’re sure it’s working, you’re probably going to want to make it run silently so that you no longer see the terminal window coming up on the screen and here’s how you do that. I can edit your schedule again and change the command to /bin/sh and leave a space between that and the path of your script. Of course once you have all this working, you’ll need to add the rest of the folders to the script. In my case, I have quite a few here, as you can see. Alright, so I wanted to tell you just a little bit about the rsync command. Now, it’s actually very similar to the robocopy command that windows has, but rsync is very popular on Unix systems as well. Now, the way this works, and it’s really cool, is it checks to see if the file already exists on the other drive. The benefit of that is that when you have two enormous drives, like in this case I’m copying What? A whole terabyte drive to another whole terabyte drive, and I’m doing that twice over because I have four drives total. It would take forever if it had to copy every single file. So what it does is it actually checks to see if the file already exists on the other drive, and if the file, date, and the size, and everything is the same it just skips it. Which is great because that means if no changes were made It’s just gonna to go through every night, and it’s just going to check this file, this file, this file, this file, and if there’s no changes, it’s going to be done in like five or ten minutes. If there you know five or six files that are different, it’s going to copy those five or six files and again the script is only going to take just a few minutes to finish. And of course the very first time you run it it may take a day or two to finish the depending upon, you know, how much data is actually being copied. But once it’s done copying the bulk of it, it’s only just going to update as needed. Now, the way I have mine set, it does not do an exact clone. That is, it doesn’t delete files off the backup drive. Now You can add a command in there to make it do that, but I don’t like it to work that way and here’s the reason. If I accidentally delete a file off of my file server, then, if I don’t realize it, that night when the script runs, it’ll delete it off the backup drive too and then I’ve lost it. But if I if I don’t have it delete the files in the backup drive, then that means I can delete a file and then in four or five days later I can go “Oh man, where did that file go?” Then I can go over to my backup drive and there it is and I can copy it back. Now, the problem with that is though, is if you make a whole lot of changes you may end up with a whole lot of excess files over on your backup drive. So, pretty much the way I handle that is periodically once over a few months I pretty much just go in and erase the backup drive and let the script just run completely again and get a clean copy over to the backup drive. That may not necessarily be the best way to do things but that’s how I do it. Anyway I hope you enjoyed the video, hope didn’t melt your brain or anything. Hope it wasn’t too boring or complex or anything. I’ve been putting this video off for a while because I wasn’t entirely sure how to explain some of the stuff, so anyway, I hope you enjoyed it. Until next time. Thanks!

100 thoughts on “How to use a Mac Mini as a file server

  1. Thanks for the video, this is very informative without the information overload. I'm planning to purchase a mac mini to use as my mini media & file server.

  2. Everyone is complaining about commands, the solution etc. I can complain about how much power this guy is actually using for everything in his house.

  3. Thanks for sharing. Wonder if I can do this to a network drive. Time machine can't access our network drive at work.

  4. my brain melted….but then again my kids tell me it didn't have far to go anyway!!! Thanks for the vid….

  5. Sooo…

    Great video! I was wondering if I could use your method, but replace firewire daisy chaining multiple drives with a NAS with multiple drives (WD My Cloud EX4) and replacing a Mac Mini with a MacPro (1,1) with 4 internal drives in a JBOD (or RAID 5 if it supports it) to backup my 12TB WD EX4 in RAID 5…

    I've got an old MacPro and an old PowerMac G5 when my Dad died. I'm using to be the base of a bench (like this: http://gizmodo.com/this-bench-is-built-using-two-power-mac-g5s-1649709456 but more like an entertainment center). Both of the computers still work, and I'd like to gain some functionality from them. Since the MacPro has 4 drive bays, can add an SSD through a PCI adapter to run the system, and I probably won't be using a monitor for it; this seems like a worthwhile endeavor.

  6. If some files on drive A are actually corrupted. rsync will still copy them to the backups. For important data, backup script should always run manually with actual human to confirm which folder/files are being updated

  7. Help Needed. I shared an external hard drive via ftp but when I connect to it, the external hard drive isn't there. Every other file on the computer is but I only selected to share the external hard drive.

  8. You should've put all four drives in RAID 1. But I'll go along with this since the drives can be replaced if lost storage ever happens.

  9. Hey 8 bit guy, how fast is the transfer speed to your storage drives? My USB 2 Seagate external drive is getting up to 18 MB/s when next to the router (using the 5 Ghz wifi) I can't connect an Ethernet cable.

  10. Couldn't you just have each backup and storage device in a raid 1 config which automatically sets the second drive to be an exact copy of the original

  11. Wow this video was helpful, mostly for the backup script since I don't use a mac for my fileserver but I use a raspberry pi. I use it because it draws less power and it's cheap and powerful enough for what I am going to use it for.

    For those who are curious I am using a single 1TB drive that I got a few years ago from my mom, a 2,4 watt usb power supply, a black case and a 16 gb sd card for the operating system.
    Programs i use are samba and ntfs-3g. Samba is the SMB file sharing server and ntfs-3g is so that I can read and write to NTFS drives. So far I've backed up 1.2 GB of video files and I can stream to 6-8 devices at the same time.

    Transfer speeds are not great which isn't something I was expecting either.
    Right now I am getting 2-3 MByte/s (16-24 Mbits/s) up and down for video files. This speed gets even worse when I am uploading smaller files. Then it's better to just ZIP the files together and send them as one big file. For the video files that I upload and stream to my devices this is plenty. I can even stream 1080p60fps content of quite high quality. Though I only stream 720p video at 1200 kb/s which means that I can stream those files to 13 different devices, in theory at least. I don't think the processor would be very happy or the RAM.

    Eventually I will add another Terabyte drive and make a backup script that runs every 24h with cron.

  12. Rsync is awesome, and I use it in a similar setup (NOT having the automated rsync job delete files from the backup disk).
    What I do instead of periodically erasing the backup drive and more or less starting over, is that when I make the backup script, I make TWO SCRIPTS, which are identical except that the version that's scheduled to run automatically is like you've shown in the video, and the second script has the commands to allow rsync to delete files that are no longer present on the source drive. This second script is only ever run manually, when I know I need to clear out the excess junk off my backup drive. The key benefit here is that you don't end up needing to re-copy everything back over to the backup drive upon the next backup; the rsync deletion process can run in a couple minutes for a backup set that's a couple terabytes.

  13. I use a Buffalo LinkStation 8TB NAS box as my file server. I used to have it set up so all my devices could access it, so my parents could watch movies I downloaded for them on their networked blu-ray player, but a firmware update wiped out all my shares and changed the sharing interface so I can't for the life of me figure out how to re-enable it. So all I have now is network shares on all my Windows machines/home theatre PCs. Annoying, but at least it still works for myself. I would like to do something like your setup one day, but that won't be until my NAS box gets filled up and I need to upgrade it.

  14. I have two external drives mounted on my Mac, but cannot back those two drives do my Time Machine. Is there a way to do this in Terminal since they are external drives?

  15. I have this huge video DVD library (850+ DVDs with 4-10 video's all with +/- 6hrs of video) I have been converting the individual movies/TV shows to MP4 or AVI. I have managed to condense them down to 8 – 1&2 TB 3.5" Hard Drives. I then printed an index to each drive, so I can locate my favorite show/movie to watch. I use the horizontal drive dock with fan to play the various disk for the movie wanted.

  16. I'd love to do this, since periodically every few years I'll end up breaking whatever laptop I have at the time, and end up back on my 2006 HP Pavilion (the thing's a trooper, I tell ya!). My last laptop had a whole terabyte of storage, so with the HP's 80 gig hard drive…Yeah. I literally don't have the space for all my files. But I can't do this or anything else about it, 'cause I'm dirt poor. 😛

  17. Does anyone else only get the option for 'personal file sharing', as opposed to, 'file sharing'? I don't get any options to configure, can someone please advice me.

  18. just curios, I am only doing this since I got some hard drives and a Mac mini for free since someone thought it was broken when it wasn't, and I find it very interesting. My question is , where could I go for some more detail on this. I would not just like to know what I did, but also, know what exactly the changes made do. For example, I don't just want to know to that I must add a path to share the drive, but also, what that does. I know the example I gave is fairly self explanatory, but that type of stuff is the stuff I'd like to know.

  19. I got lost @ 12:26 and got my computer stuck on xvideos under some old mattress in the alley outside @ 2:00 in the morning. I think I'm doing this wrong. Can you slow down.

  20. You know, Western Digital hard drives have the same functionality with backups. They run their own script every now and then (depending on how you schedule it) to back-up to an external hard drive. I think this only works for Windows, though.

  21. Hi there,
    I followed all the process but not for rsync but for Chmod issue (I need to change the permissions of files everyday), everting works fine, except the fact that the script is not running as a root.
    so when I add, sudo "script", it works fine , but when the script is running automatically with cronninx , some files mode can't be changed.
    Even if when creating the script I started it with "sudo" like it's shows in the tutorial.
    Any help ?
    Thanks in advance

  22. Hi 8 bit guy. Please tell the command of rsync which can able to delete files on 2nd hdd which were deleted in original hdd

  23. Any new users here, the best way to make a media sharing server is Plex, you can use it with a Mac Mini. It's easier and faster to do.

  24. The real solution for his file deletion problem is to have a snapshot-capable target file system and let the backup script create a new snapshot after every backup (and perhaps delete the oldest snapshot to conserve space). This way you can request to see your backup drive as it was n days ago by mounting the snapshot. Funny that he complained about Apple's Time Machine, as it's one example implementation of this very idea.

  25. Hi there, thank you for this great Tuto, it's inspired me for doing something similar but instead of "backupscript", I'm propaging authorisations to some files… so my script looks like this… " sudo chmod -R 777 /Volumes/….etc" and I'm using Cronnix as well.
    My problem is, it asked me every time Root password, even if in the script I have put "sudo"….am I doing something wrong?
    Your help would me very appreciated.

  26. The best thing on OS X is that it is UNIX, so a Linux user can easily understand how the command line works and what are the commands doing.

  27. Thinking of doing this with my netbook once win7 support ends and I build a closed network between my 4 old dell laptops.

  28. 8:45 If you don’t use a computer very often, why would you go as far as to design a script like this for that computer in the first place? That does seem at least kind of rare to me as something that can happen.

  29. Direct Download macOS Server 5.7 Beta 4

    http://appmhs.blogspot.com/2018/08/direct-download-macos-server-57-beta-4.html

  30. Why would I use a Mac Mini G4 when I can use my double dual-core G5 watercooled PowerMac? Who even looks at their electric bill

  31. Is it worth it buying this? Mac Mini + Firewire drives. Currently i have a Linksys NSS4000 NAS (Enterprise model) 4TB. But it's slow as hell with only 4MB/s. Is it worth it buying the Mac mini and the drives? And then keep it mirrored with my NSS4000. So it's just like the mac mini is a cache server

  32. great video, love watching all your vids and how humble and open the phrasing and language you use – i find it really accessible. Great work

  33. This is great 👍 I would like to try it! No special software needed for making the server accessible to ios and other macs?

  34. After I watched this video which was nearly a year ago(2018.12). I’m still using this server as my NAS, even though my main pc is a Alienware and laptop is the latest MacBook Pro lol.
    It’s really an interesting experience when u using the latest iOS13 built-in “files” app to open a folder which’s in a late 2009 Mac mini.
    Huge thanks to this video. This NAS possibly the most useful thing I have ever made.
    Greeting from China. Thank you!

  35. Mom and lul will fuck with me allnight huh David and its lul saying f mom and Amy here's so do u David and I'm not fucking my mom huh david.

Leave a Reply

Your email address will not be published. Required fields are marked *