Web Dev Blog

Looking for help with WordPress, Apache, Vim, Web Security and more. Here are a few tips.

Category: Hardware

Replacing Hard Drive under LVM in Ubuntu

Recently had a hard drive start acting strangely on my development server. It is a 2TB Seagate drive and it started causing errors in the logs, nothing major and it still worked. I put off ordering a new drive, a mistake, I know, but thought maybe it was just some kind of software issue.

Then the machine started getting slow. Really slow. So I ordered a new 3TB Toshiba drive. Finally received it and thought I would use Clonezilla to copy the drive. Created a live USB Linux flash drive with the Clonezilla image. Worked like a champ, but the cloning was going very slowly due to the problem with the drive, so I bailed. After some additional tinkering, and fixing grub because Clonezilla had modified it, I was able to boot back up and I realized that I was using LVM and this creates another problem.

I’m not sure if cloning and replacing the drive would have worked or not, but found some guides on replacing a drive in LVM.

Here is the one I used
http://www.microhowto.info/howto/replace_one_of_the_physical_volumes_in_an_lvm_volume_group.html

Basically you add the new drive to the LVM and then use pmove to migrate the content off the old drive. Honestly, I’m not sure yet how this is going to work, it’s been almost a day and a half and I’m at 45.8%. If it fails I have a backup, but it would be nice if this process works and everything moves.

Which physical partition are my Ubuntu files on?

LVM, the Linux logical volume manager included in the Linux kernel uses the device-mapper functionality to allow easy administration and creation of logical volumes in your file system. This is great technology, but what happens when you are having hard drive problems and want o troubleshoot. How do you determine which physical drive your volume is mapped to? How to find out if the drive you are replacing is storing critical parts of your system?

Here is the technique I’ve used and it works pretty well.

The df command will tell you what volume a specific directory is on. the output of this command might look like this

# df /foo
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/kubuntu--vg-Video 739G 645G 56G 93% /foo

Once you know the volume you are looking for you can use the lvs command to report information about logical volumes. Note, lvs seems to need root access so you may need to use sudo.


# sudo lvs -o +devices /dev/mapper/kubuntu--vg-Video
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices
Video kubuntu-vg -wi-ao---- 750.00g /dev/sda5(128000)

So now we can see that the logical volum in question is on /dev/sda5

lshw can now show us what drive is on sda


# sudo lshw -class disk
*-disk
description: ATA Disk
product: ST2000DM001-1CH1
vendor: Seagate
physical id: 0.0.0
bus info: scsi@0:0.0.0
logical name: /dev/sda
version: CC27
serial: Z340BEHG
size: 1863GiB (2TB)
capabilities: partitioned partitioned:dos
configuration: ansiversion=5 logicalsectorsize=512 sectorsize=4096 signature=000c3f21

Now we know which drive is storing the content from the LVM in question and can migrate this over to a new hard drive.

Shut Off Monitor With Nircmd

I have multiple computers on my work desk and sometimes I want to shut off a monitor.  Maybe I’m watching a video or playing a game with the lights down – whatever the reason, I haven’t found an easy way to blank out a monitor under Windows 7 until now.

Found this great article on howtogeek.com about disabling a monitor.

Create a Shortcut or Hotkey to Turn Off the Monitor

 

It uses the Nircmd.exe app to create a shortcut to disable the monitor.  Very cool.

M570 Mouse Button Click Problems – How Long Should They Last

m570-wireless-mouseI have a Logitech M570 Wireless Trackball.  I’ve had it for a few years, and love it.  Recently I’ve noticed the the right mouse button has click issues.  Sometimes it will right-click and act like a double click.  Sometimes it will stick.  This was a problem during gaming, working in Excel and while completing other tasks.

Finally, I was tired of this problem, so I did a search.  Amazingly, this is a huge problem.  The Logitech forums are littered with complaints.  What is the problem?  It seems to be the microswitches Logitech is using are not holding up.  Many users are able to contact Logitech and have the mouse replaced under warranty, but the Logitech hasn’t officially addressed the problem.

How to fix the M570 Wireless Trackball right click

There doesn’t seem to be a consensus on fixing this problem.  A site called Red Ferret has an article on repairing a switch in a Logitech mouse (not the M570) (http://www.redferret.net/?p=31008)

The symptoms are that the mouse click delivers two clicks for one press, which can be extremely annoying and renders the mouse unworkable for important tasks. This time, however, instead of consigning the device to the trash and buying another, we decided to see if we could solve the situation with a bit of DIY. And the answer is yes!

A quick search on Google revealed that other more intrepid souls had managed to fix their own meeces, and so we got to work on two ‘dead’ mice lying around in Ferret Towers, a Logitech M705 and an older MX Revolution. The first thing to note is that the culprit is tiny, a sliver of copper which can’t be worth more than £0.02p.

Their solution is to re-bend the spring or “sliver of copper” and they even have a video showing how to fix this.

Logitech Mouse Double Click Problem and How To Fix It

While this seems like a cheap fix, it does seem annoying to tear the whole thing apart just to tweak that spring. Why not replace the switch with a new one?

What switch is in the M570 and what do we replace it with? The consensus is Omron makes the best switches, but no one really made a distinction on what is the “best” switch for a mouse button. This forum lists the Omron switches and lists the D2F-01F as one of the better switches. Interestingly, it seems the Logitech uses Omron switches in many of their products, like the trackball in this post that clearly has a DF-01F-T switch.

Is the M570 mouse worth fixing or should we just buy a new one?

The M570 sells new on Amazon for about $40.  A new switch is only a couple dollars on ebay, but the labor to put it in is probably an hour and some soldering.  So, is it worth trying to fix?  That’s a tough question.  There are reports that some users are only getting a few months out of the M570 before experiencing the problem.  If that’s true, it might be worth fixing, but if Logitech will warranty the trackball, buying a new one may be a better option.

Finally, is Logitech to blame for this problem?  Is there something they should do?  It appears that Logitech is using the best switches available in their products, unless the M570 has a non-Omron switch.  Maybe these switches just won’t stand up to the kind of abuse the users are giving them.  Maybe a mouse only has a lifespan of a few months for some people and a couple years for others, at least until someone builds a better switch.