Tuesday, March 20, 2012

Partitioning a new 2 Terrabyte disk

To make sure it will be a while before we have to revisit my wife's backup strategy, I bought a 2TB drive and installed it in my machine to serve as a Samba network drive for her backups. The physical install didn't present any nontrivial problems.

I ran into the first puzzle when I booted-up the machine for the first time. After selecting the default boot kernel via grub I got an error message indicating a missing partition table or some such. Ack! Did I somehow damage my primary drive while installing the new one? Then, I realized---the order used by grub might have changed. I edited the boot commands, changing "hd1" to "hd0". Viola! Back to normal.

After booting-up, I ran fdisk /dev/sdb. I created a single primary partition for the entire disk, but then got a strange warning message:

Partition 1 does not start on physical sector boundary.

A Google search indicated that I might need to start at 8 or 64 or some such. But, when I tried that, I got the same warning. Some more searching led me to an IBM article on Linux on 4KB-sector disks. After finding the fdisk section, I followed their advice to turn off DOS compatibility ('c') and change display units ('u'); when I again tried creating the partition, the warning disappeared.

Note: If I had been more observant, I would have noticed that fdisk told me about the 'c' and 'u' options when it started-up. Doh!

Note: I needed the disk UUID in order to make a proper /etc/fstab entry. The easiest way I found to get this is to run

ls -la /dev/disk/by-uuid/
Each UUID is linked to its corresponding device.

Note: I was slightly upset that only 1.7T of the 1.8T was available immediately after formatting. I learned that this was probably due to the 5% reserved for system use. I lowered this to 2% using the following command:

sudo tune2fs -m 2 /dev/sdb1

Sunday, March 18, 2012

Setting up Samba for Windows Backup

Until recently, my wife has been a happy Mozy customer. She didn't mind paying for the 50 gig plan because she runs a website and blog for her business and needs a reliable backup solution that she doesn't have to worry about. About a month ago, she got a notification that Mozy hadn't performed a backup for 7 days because she exceeded her quota. This was the first time she had ever hit the 50 gig limit. She opted to pay for an extra 20 gig quota, thinking it would last quite a while. A month later, she got the notice again about being out of quota. Then, she realized, videos take up a lot of space! I helped her start looking at other backup options---paying for an additional 20 gigs of space every month did not seem like a good plan to either of us.

After looking into various options, I realized that the best one might be free---using backup software on her machine to save her data to a samba share on my Ubuntu box. I followed the Ubuntu instructions for setting up a Samba file server. Here are two notes that would have saved me a lot of time:

  • Try using a workgroup name of "WORKGROUP" unless you have explicitly changed it on the Windows machine. I saw mentions of "HOMEGROUP" on my wife's Vista box and tried that first, but the real workgroup name was "WORKGROUP".
  • To access the shared drive, enter "\\machinename". If there is a "Run" option in your Start menu, enter it there. For Vista, I entered this into a Start menu "Search files and programs" search box.

I then went searching for Windows backup software. I found and tried Cobian backup. After much fiddling and reading, I learned that "backup" software is not what I was looking for---I wanted software to (efficiently) keep a current replica of my wifes files. Cobian could only do this by running a "full" backup each run. I wanted the functionality of "rsync" which apparently is known as "file synchronization". Next, I discovered GoodSync which seemed to have the right functionality. One annoying part is that it required my wife's Windows account to have a password in order to set up an automatic sync. Easy enough. At this point, I had the desired automatic file synchronization functionality as long as I had the "guest ok = yes" setting for the samba share.

Next, I wanted to require authentication for the samba share. I followed the "Security = user" instructions provided by Ubuntu, but then found that I could authenticate with my Ubuntu account, but not the one I had set up for my wife. Next, I created an samba user/password for my wife with smbpasswd. I could access the share, but GoodSync was giving me strage errors every time a automatic backup tried to run. Finally, I realized my wife's account didn't have permission to write to the share. I learned of the "admin users" samba option and added my wife's Ubuntu account to the list of admin users for the share. Finally, the automatic file sync worked without issue.

P.S. At some point, I tried mapping the samba share to a Windows drive letter (e.g. "Z:"). But, that didn't help and only created more confusing error messages. In fact, GoodSync had no trouble using the "\\machinemame" notation to reference the samba share.