Saturday, December 5, 2009

Proper Samba Sharing

I spent a huge amount of time trying to set up a samba share that was password protected and writable. It's amazing to me that such a basic use case isn't well supported using the gui and was so poorly documented. Ben was nice enough to listen to me rant about Ubuntu, Fedora, Gnome, FreeNas, Unetbootin, and more.

This is on Ubuntu 9.04 (Gnome).
  • Install samba, open firewall, etc.
  • sudo smbpasswd -a someuser to manually create the account for samba because automatic account sync with the system accounts didn't work.
  • net usershare info to show user shares (those created by non-root users; these are what gnome's nautilus creates).
  • net usershare add music /home/someuser/Music/ "" someuser:F
  • It may take a few seconds to take effect.
  • for more info on the net command.
Update Oct 25, 2011: You still need to create the samba user in Ubuntu 11.04.

Wednesday, January 28, 2009

Upgrading the hard drive on my Thinkpad X61

These directions ARE NOT a complete step by step tutorial for people who have no idea what's going on. They're a detailed enough account of what I did for someone with some decent computer knowledge to have a guide.

I wanted a bigger drive on my Thinkpad X61 (awesome machine by the way). The tricky thing is that the machine has a hard drive shock protection system which parks the hard drive head if it detects a physical shock to prevent damage to the disk and I wanted this feature to keep working with my new disk.

I did quite a bit of searching and it seems that for it to work, the new drive needed to support the UNLOAD feature of the IDLE IMMEDIATE ATA command. Shockingly enough, that just isn't one of the things that manufacturers put on the side of the box. I looked at a few drives. For one or two I found some mention of this on an obscure tech doc at some random location on their site (thanks google). I tried calling a couple of manufacturers, but couldn't usually get an answer to this question. One of them actually did contact their engineers in Taiwan and got back to me. Eventually I settled on a Fujitsu MHY2200BH. It's in the same or a similar series to the drive the machine came with, a MHW2080BH, and at the time seemed to be the best shot for supporting the head park feature. It's been a while, but I think that at the time I found a datasheet for that that said it supported UNLOAD. So I got it even though it wasn't the cheapest drive.

I don't have time to reinstall windows right now and set everything up again, so I just wanted to copy everything over from my existing installation. The machine also comes with a hidden partition at the beginning which I assume makes the easy diagnosis and reinstall tool (blue button at startup) work. I wanted that to keep working on the new disk too.

I put the new disk in an enclosure and connected it while windows was running. This might be necessary if windows needs to install drivers for the new disk.

Initially I tried copying the partitions with gparted. It hit an error so I used it to create empty partitions and tried to copy the data with ntfsclone. This copied ok, but the new disk wouldn't boot up. The gparted errors might be because (fdisk says) the original partitions don't end on cylinder boundaries. And I think the new partitions it created were slightly different because they did.

Next I tried using dd (while still booted to the gparted liveusb) to make an exact copy from the old disk to the new one. But partway through the copy, the disk in the external enclosure hit some kind of weirdness and disconnected. I suspect the enclosure was at fault because I had my original disk in there at the time and I know it works fine. Bad enclosure!

So I made an ubuntu 8.10 32-bit desktop live-usb using these directions although I expect you could use one of the easier ways. I booted it, enabled the universe repositories in /etc/apt/sources.list, and installed ddrescue (package is called gddrescue) which is like a souped up dd for data recovery. I think it allows resuming dd's, so my thought was that if the transfer failed again I could continue, but the transfer worked the first time so I didn't test this. I opened a terminal, left myself in my home directory which I think gets written to the flash drive, and ran it with "ddrescue /dev/sdc /dev/sda logfile". Again, at this point I had the new drive in the machine and the old one in the enclosure, but you may as well put the new disk in the enclosure until later. NOTE: Don't run that command without being very sure of what you're doing or you can delete your data. At the end, the new disk had exact copies of the old disks partitions and some free space at the end because it's bigger. And fdisk showed the new partitions not ending on cylinder boundaries just like the old one. Perfect.

Although I didn't do this until later, if you're swapping the disks now, you may as well switch the little metal tray attached to the old disk to the new one. You take off the two rubber things on the sides and there are 4 screws holding it on.

I disconnected the old disk, booted up the new one, and it worked perfectly.

I ran the active protection system tool and shook the machine a little bit. It said the head was getting parked and once I went to a quiet room, I heard the click I used to hear from the old drive when it parked the head. I also played a video and shook it again and sure enough, right after the utility said the head was parked, the video would freeze just like on my old disk.

Vista has a disk manager which can extend and shrink partitions. I extended my windows partition to use the rest of the disk. It took no time. Literally.

Finally, I rebooted and used the blue button to boot the diagnostic/reinstall tool. I didn't do too much with it, but it booted and launched the web browser so it seems to be fine.

Now I'm going to run a manual defrag from vista since my old disk has 200MB free and may have been pretty fragmented.

Life is good.