I use GNOME 3 in OpenSUSE relatively frequently at work. I’m familiar with this “shell” flavor of GNOME and have watched it evolve over recent years. But, I’ve stuck with XFCE on my personal machines for several reasons:

  • XFCE is very customizable.
  • It looks professional and doesn’t throw useless flashy buttons or movements in front of you.
  • While there are some pretty horrible themes, it generally hasn’t been hit with the ugly stick. This was my main reason for moving away from GNOME 2, which was my first Linux desktop environment after starting with Ubuntu years ago.

I revisited GNOME 3 today in Debian for my personal laptop. I’m sad to say that I still can’t use it. While there are great aspects to it, there are still bits that infuriate me.

Icon Sizes

Believe it or not, the issue of icon size was the original thing that pushed me from GNOME 2 to XFCE. Here’s a sample of what toolbar icons look like in GNOME 2.

This is the icon equivalent of bad kerning. Icons are simply stuffed full-size into a toolbar, with no space between them and no vertical padding in the toolbar. This drives me nuts and it looks horrendous. At least in XFCE, I get reliable spacing and padding around icons to make them look reasonable. Yep… that’s the original reason why I switched to XFCE. GNOME2 was just hit with the ugly stick in a big way.

Moving on to GNOME 3, it gets worse. While the toolbars are basically gone, I now have the currently open application showing in the top toolbar as follows.     So, Iceweasel (the Debian equivalent of Firefox) is open here and the icon is so big that it won’t even fit in the toolbar. Plus, there’s text to show me the application name associated with the icon that is now unrecognizable because it’s so huge. This is simply GNOME 3 trying to add some design appeal, while forgetting that this Iceweasel icon and text do absolutely nothing, except for possibly closing Iceweasel. It gets worse. If I click on this monstrosity, it pops up a menu with a single option: “Quit,” which stays open until I click the icon/text again. It’s useless, beyond letting you know which program you’re using, in case you forget. And, you can’t get rid of this ugliness.

Sure, there are add-on extensions to remove this little useless graphic, but I haven’t been able to get them to work. So, I’m stuck with ugly, space-sucking, useless graphics on my desktop. Good job.

While we’re on the topic of icon sizes, I should mention that I was able to find an extension that would allow me to change the notification icons on the right-hand size of the top toolbar in GNOME 3. They now, after being modified from their original form, look as follows.

That actually looks good. I like that. It’s clean and functional.

Activities

I like the mouse gestures associated with the “Activities” button in the upper-left side of my screen, but I don’t understand why it is called “Activities.” It would be more appropriately called “Stuff” or “Dashboard” or even “Oberoth,” the name of my laptop.

If you name it “Activities,” then it should actually be a route for accessing items that are actually activities: “write an email,” “browse a website,” etc. Instead, “activities” are things like “removable devices” and “windows.” I don’t even see why “activities” is there in the first place.

If I go in to “activities” and then click on “applications,” I get an array of huge icons associated with programs. I do like that I can start typing the name of a program and have this list be filtered. But, the array of icons and text isn’t incredibly easy to use. I was able to reduce the icon size a bit, but now we find ourselves in the following situation.

Just to recap, the six application options in these six icons are as follows: “gedit”, “GNU Im…”, “GParted,” “Hugin …”, “Hugin …”, “Hugin …”, “LibreO…”, “LibreO…”, and “LibreO…”. Only two of these nine options remove any doubt as to what they access. This is just horribly designed.

Conclusion

I could go on, but won’t. It’s this sort of nonsense that I don’t miss when using XFCE. I think the look and feel overall is nice, but it’s infuriating during actual use. I can’t find what I’m looking for, and thing I’m not looking for take up space. The clock, for instance, takes up about 3x the space on the GNOME 3 toolbar as my XFCE clock does on my XFCE toolbar.

I’ll try again in another year or so. Until then, XFCE still has my vote. By the way, below is a screenshot of what my XFCE environment currently looks like.


Problem

I have been using XFCE as a desktop environment in Linux ever since I became frustrated with GNOME 2 (it was hit with the ugly stick). I’ve used a few others (GNOME 3, LXDE, etc.) and some window managers as well (OpenBox), but I keep coming back to XFCE for its simplicity and elegance. What annoyed me for some time though was that the display manager of XFCE didn’t appear to support multiple monitors. In reality, you just have to know how to do it … which isn’t terribly complicated.

XRANDR

Xrandr is the “primitive command line interface to the RandR extension.” This is what will allow us to enable and configure multiple monitors via the terminal. The first thing we’ll do is see what sort of displays are available. I’m running a Lenovo ThinkPad on a dock, so I’m going to have a load of display ports at my disposal. Xrandr is almost certainly installed if you’re running a distro such as Debian, Ubuntu/Xubuntu, etc.

We can get a list of available display ports by simply typing ‘xrandr’ at the prompt.

jason@oberoth:~$ xrandr
Screen 0: minimum 320 x 200, current 1600 x 900, maximum 8192 x 8192
LVDS1 connected 1600x900+0+0 (normal left inverted right x axis y axis) 309mm x 174mm
   1600x900       60.0*+   40.0  
   1440x900       59.9  
   1360x768       59.8     60.0  
   1152x864       60.0  
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
VGA1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
HDMI3 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)

As xrandr shows, I’m currently running with only my laptop screen, which is named LVDS1. This screen has a resolution of 1600×900, and it’s currently running at that resolution. If I connect a VGA cable from my dock to my monitor, I’ll get a slightly different output.

jason@oberoth:~$ xrandr
Screen 0: minimum 320 x 200, current 1600 x 900, maximum 8192 x 8192
LVDS1 connected 1600x900+0+0 (normal left inverted right x axis y axis) 309mm x 174mm
   1600x900       60.0*+   40.0  
   1440x900       59.9  
   1360x768       59.8     60.0  
   1152x864       60.0  
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
VGA1 connected (normal left inverted right x axis y axis)
   1920x1080      60.0 +
   1600x1200      60.0  
   1680x1050      60.0  
   1280x1024      75.0     60.0  
   1440x900       75.0     59.9  
   1280x960       60.0  
   1280x800       59.8  
   1152x864       75.0  
   1024x768       75.1     70.1     60.0  
   832x624        74.6  
   800x600        72.2     75.0     60.3     56.2  
   640x480        75.0     72.8     66.7     60.0  
   720x400        70.1  
HDMI1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
HDMI3 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)

Now, VGA1 is connected and the data shows that it is capable of running at 1920×1080. There are multiple ways to tell xrandr that we’d like to use both LVDS1 (laptop monitor) and the external monitor connected at VGA1. First, we need to determine the orientation of how we’d like to set things up. My preference is to have my laptop monitor maintain my XFCE desktop toolbar and be viewed as the “primary” screen. My external monitor will sit off to the right size of the laptop screen, and I need to tell xrandr where to place this monitor in reference to my laptop screen. I do that like so.

xrandr --output LVDS1 --auto --primary --output VGA1 --auto --right-of LVDS1

This tells xrandr that the first output is LVDS1, which is set to automatically register resolution and also be set as the primary output. The second output is VGA1, which also has resolution set automatically and resides to the right of LVDS1. Once we issue that command, the second monitor becomes active and I can move my mouse pointer and drag windows between monitors. If we issue an xrandr command now, we see this.

jason@oberoth:~$ xrandr
Screen 0: minimum 320 x 200, current 3520 x 1080, maximum 8192 x 8192
LVDS1 connected 1600x900+0+0 (normal left inverted right x axis y axis) 309mm x 174mm
   1600x900       60.0*+   40.0  
   1440x900       59.9  
   1360x768       59.8     60.0  
   1152x864       60.0  
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
VGA1 connected 1920x1080+1600+0 (normal left inverted right x axis y axis) 477mm x 268mm
   1920x1080      60.0*+
   1600x1200      60.0  
   1680x1050      60.0  
   1280x1024      75.0     60.0  
   1440x900       75.0     59.9  
   1280x960       60.0  
   1280x800       59.8  
   1152x864       75.0  
   1024x768       75.1     70.1     60.0  
   832x624        74.6  
   800x600        72.2     75.0     60.3     56.2  
   640x480        75.0     72.8     66.7     60.0  
   720x400        70.1  
HDMI1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
HDMI3 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)

We see that screen 0 now registers as being 3520×1080, and it holds two outputs: LVDS1 with resolution 1600×900 at 0×0 and VGA1 with resolution 1920×1080 at location 1600×0.

The only awkward issue here is that my external monitor is taller than my laptop. Right now, the monitors are aligned vertically at the top. What if I want them aligned vertically by the bottom of the screens? Keeping in mind that the external monitor is 180 pixels taller than the laptop, I could position the external monitor manually as so.

xrandr --output LVDS1 --auto --primary --output VGA1 --auto --pos 1600x-180

Rotating the External Monitor

One thing I like to do while coding, or even reading webpages, is to rotate my external monitor for a taller reading profile. I do that as follows.

xrandr --output LVDS1 --auto --primary --output VGA1 --auto --right-of LVDS1 --rotate right

Maybe some time in the future I’ll come up with a script to automate this.


There’s this annoying thing that’s happening at work. It started with one or two sites being blocked from access while on the company network. It has grown to the point where standard, run-of-the-mill stuff is blocked. For instance, the Google image search for “Linux Mint XFCE” (I’ve been considering switching my work desktop to Mint) turns up results that are blocked by the network. Here’s a screenshot of the warning that a Linux Mint screenshot image link produces.

It would be one thing if I only ran into this “access denied” warning while browsing during lunch. But, this keeps popping up for work-related searches, including the recent issue of not being able to access a page about Python’s Twisted module because it … apparently … contained information about weapons.

Forwarding HTTP Traffic over SSH

So, what I’m going to do is to reroute all of my browser traffic over SSH and through a server that I administrate. Come to think of it, this is a safe solution for many situations (travels, working on sensitive data over an open wifi connection, etc.).

First, you need to have SSH access to a server that can act as a proxy for your web browser connection. I’m using a server that I’ll call proxy.myserver.com. We’ll set up the forwarding here. There are a few command options that we use for the ssh command here. Namely, the D option specifies a local application level port forward and the N tells proxy.myserver.com that we don’t want to interact… we’ll just open a connection in the terminal and let it sit there without a prompt. The real data transfer work is going to be done through the web browser.

Here’s how we set it up, forwarding port 9999 from my desktop to proxy.myserver.com, I enter the following in the terminal on my desktop.

$ ssh -ND 9999 jason@proxy.myserver.com

After entering the password, it just sits there, which is exactly what should happen. Now, let’s set up the browser. I’m using Iceweasel (Firefox) on Debian. By entering the options menu at Edit->Preferences and finding our way to Advanced->Connection->Settings, we get the following menu.

By entering a manual proxy configuration with a SOCKS host, we will be able to utilize our SSH port 9999 connection.

Now, Firefox/Iceweasel will use the proxy connection through proxy.myserver.com to fetch any web traffic. If for some reason that connection dies, we’ll get a warning from the browser stating that the proxy isn’t accepting any connections.


If you run Debian Squeeze, you could simply add backport repositories to your apt sources if you want to force an upgrade to a new kernel. At the time of writing this, Squeeze is using Linux-image-2.6.32, while Wheezy (testing) and Sid (unstable) are both using Linux-image-3.2. However, on kernel.org, the latest stable release is Linux-image-3.8.2.

One of the few packages that can have multiple versions installed simultaneously, in apt or otherwise on the system, is the Linux kernel. This can be useful, for instance, if you find that your new hardware isn’t supported properly by a slightly old kernel.

Dependencies

Since we’re going to be compiling our own kernel, we need a few things. These are:

  • build-essential
  • module-assistant

Make sure those packages are installed (through apt or aptitude) before continuing. I’m guessing that most of those reading this post will already have the first installed, but perhaps not the second.

Downloading the Kernel Source

Visit kernel.org and decide on a kernel. There probably is a “latest stable release” version that is clearly highlighted, and that’s what I’d recommend. There are also some older, yet still maintained, “longterm” releases of the kernel that may provide updates that suite your needs.

Copy the link. In my case, I’m using the link to the “latest stable” 3.8.2.

Make yourself root, or otherwise superuser, for the rest of this process.

$ sudo -i

Download and unpack the kernel source.

$ cd /usr/src/
$ wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.8.2.tar.bz2
$ tar -jxf linux-3.8.2.tar.bz2
$ cd linux-3.8.2/

Configuring Old to New

Running the following command will check your current kernel configuration and prompt you when there is a new option available in your new kernel. Most of the time, accepting the preselected values is fine. Sometimes, this is a short process and sometimes it may take a while. If you already know that you want to accept the recommended values, holding the “enter” button down will work just fine and the script will exit back to your working directory.

$ make oldconfig

Build and Install the Kernel

Now, the standard build routine with a module install sandwiched inside.

$ make
$ make modules_install
$ make install

My ThinkPad Dies With 10-30% Battery Remaining

Many ThinkPad batteries shipped within the recent months have bad firmware, causing the machines to read the battery charge incorrectly. This can cause the ThinkPads to shut off unexpectedly, and eventually can lead to them not charging at all. If your battery “FRU” (printed on the inside edge of the battery) contains any of the following, you very, very probably have a faulty battery: 42T4708, 42T4714, 42T4737, 42T4757, 42T4797, 42T4803, 42T4783, 42T4789, 42T4831, 42T4807, 42T4815, 42T4839, 42T4848, 42T4849, 42T4850, 42T4851, 42T4852, 42T4853, 42T4854, 42T4855, 42T4856, 42T4857, 42T4858, 42T4929, 42T4933, 42T4937, 42T4939, or 45N1039. These batteries shipped with ThinkPads with model names/numbers L410, L412, L510, L512, SL410, SL510, T410, T420s, T420si, T430s, T430si, T510, W510, X1, X100e, Edge 13″ (Machine types: 0196, 0197, 0492), Edge 14″, Edge 15″, Edge E30 (Machine types: 0196, 0197, 0492), Edge E40, Edge E50, Edge E220s, and Edge E420s. The “machine type” can be found on the bottom of the machine, or inside the battery bay.

To be clear, what’s going on here is the following: These batteries have software running on them (firmware) that incorrectly reports to the computer what the charge state of the battery is. This is clearly, without question, a hardware problem. Let’s get that straight, before going any further. Now, going further, your warranty covers this if you own an affected machine, as I do. Panasonic screwed up in that they placed bad firmware inside these batteries. Lenovo screwed up in that they used those batteries in ThinkPads.

Lenovo has issued an update for Windows machines here (accessed 2-27-13). This will place new firmware on the batteries, mostly if not entirely resolving the issue.

But I don’t Run Windows

If you’re like me and you’re running a Debian-based Linux machine (I run Debian Wheezy), then you can find much of the information about your battery by running a command such as

$ cat /sys/class/power_supply/BAT0/manufacturer
Panasonic
$ cat /sys/class/power_supply/BAT0/model_name
45N1039

Depending on your specific distro, you’ll find things in /proc/acpi or (more reliably) in /sys/class/power_supply. There is generally a good amount of information there, which is what your system is actually using when it displays information about the battery charge and health. For instance, on my Debian machine, I can clearly see an issue with my battery by simply looking at the Wh design and current reported capacities for the battery. Something here look fishy?

$ cat /sys/class/power_supply/BAT0/energy_now
47620000
$ cat /sys/class/power_supply/BAT0/energy_full_design
43290000

In essence, my battery is designed to hold 43290 mWh of charge, while it apparently is currently holding 47620 mWh. In other words, the battery is reporting that it is maintaining a charge 10% higher than it’s design capacity. Oops.

One can think of watt hours as available power over time, whereas amp hours would correspond to current over time, and multiplying amps by voltage gives you watts. We could report in amps instead by using acpi (advanced configuration and power interface) as follows.

$ acpi -V | grep mAh
Battery 0: design capacity 3464 mAh, last full capacity 3811 mAh = 100%

Again, oops. OK, so we know that there is something weird going on with the battery. Before I found the firmware fix, I was trying to diagnose this a bit myself. I used fwts (firmware test suite), which ran me through a process of plugging in and unplugging my machine. This took about five minutes, while it tested the charge and discharge properties of the battery and compared those numbers to what the battery was reporting. Here’s the output.

$ sudo fwts battery
 
Battery Tests.
----------------------------------------------------------------------------------------------------
Test 1 of 1: Check batteries.
This test reports which (if any) batteries there are in the system. In addition, for charging or
discharging batteries, the test validates that the reported 'current capacity' properly increments
/decrements in line with the charge/discharge state. This test also stresses the battery state
reporting codepath in the ACPI BIOS, and any warnings given by the ACPI interpreter will be
reported.
Found 1 batteries.
Test battery 'BAT0'.
Got 105 interrupt(s) on GPE gpe11.
Got 105 interrupt(s) on GPE gpe_all.
Got 105 SCI interrupt(s).
PASSED: Test 1, Detected ACPI battery events.
PASSED: Test 1, Detected ACPI event for battery BAT0.
FAILED [MEDIUM] BatteryNotDischarging: Test 1, Battery BAT0 claims it is discharging but no charge
is used.
Got 131 interrupt(s) on GPE gpe11.
Got 131 interrupt(s) on GPE gpe_all.
Got 131 SCI interrupt(s).
PASSED: Test 1, Detected ACPI battery events.
PASSED: Test 1, Detected ACPI event for battery BAT0.
FAILED [MEDIUM] BatteryNotCharging: Test 1, Battery BAT0 claims it's charging but no charge is added
Please ignore this error with a new battery
FAILED [LOW] BatteryZeroCycleCount: Test 1, System firmware may not support cycle count interface or
it reports it incorrectly for battery BAT0.
Test battery 'BAT0' downward trip point.
Got 75 interrupt(s) on GPE gpe11.
Got 75 interrupt(s) on GPE gpe_all.
Got 75 SCI interrupt(s).
FAILED [HIGH] BatteryNoEvents: Test 1, Did not detect any ACPI battery events.
FAILED [HIGH] BatteryNoEvents: Test 1, Could not detect ACPI events for battery BAT0.
Test battery 'BAT0' upwards trip point.
Got 69 interrupt(s) on GPE gpe11.
Got 69 interrupt(s) on GPE gpe_all.
Got 69 SCI interrupt(s).
FAILED [HIGH] BatteryNoEvents: Test 1, Did not detect any ACPI battery events.
FAILED [HIGH] BatteryNoEvents: Test 1, Could not detect ACPI events for battery BAT0.
 
====================================================================================================
4 passed, 7 failed, 0 warnings, 0 aborted, 0 skipped, 0 info only.
====================================================================================================
 
4 passed, 7 failed, 0 warnings, 0 aborted, 0 skipped, 0 info only.
 
Test Failure Summary
====================================================================================================
 
Critical failures: NONE
 
High failures: 2
 battery: Did not detect any ACPI battery events.
 battery: Could not detect ACPI events for battery BAT0.
 
Medium failures: 2
 battery: Battery BAT0 claims it is discharging but no charge is used.
 battery: Battery BAT0 claims it's charging but no charge is added
 
Low failures: 1
 battery: System firmware may not support cycle count interface or it reports it incorrectly for battery BAT0.
 
Other failures: NONE
 
Test           |Pass |Fail |Abort|Warn |Skip |Info |
---------------+-----+-----+-----+-----+-----+-----+
battery        |    4|    7|     |     |     |     |
---------------+-----+-----+-----+-----+-----+-----+
Total:         |    4|    7|    0|    0|    0|    0|
---------------+-----+-----+-----+-----+-----+-----+

So, time to call Lenovo. Here’s where things got a bit interesting.

Warranty Through Lenovo

You can’t really expect a service representative to know the difference between firmware and drivers, and you really can’t expect a service representative to know what a monolithic kernel is. Anyway, I expected to be told to “update your power management drivers,” which is just a fancy way of telling me to get the firmware update … assuming I use Windows. And, that’s what I was told to do. When I mentioned that I don’t use Windows and that this is a hardware issue, not a driver issue, things got a bit heated.

First, they offered to send me a copy of Windows on a DVD. I’m not interested in that, as I can use Windows … but haven’t loaded it on my personal machines in 7 years at this point. I was then told, and I quote:

“We do not support Linux. Please call Linux to resolve this issue.” ~Lenovo support

I told them that I might as well call my dining room table in the process. That caused a bit of an awkward silence for a few moments. Making a long story short, at this point the representative was clearly on the phone with a supervisor, as I could hear parts of their conversation. I restated how this was a hardware issue … that simply booting into the BIOS and running my machine would cause this problem to happen. And, while I think it’s awesome that Lenovo has a Windows-based solution, my warranty doesn’t say that I have to use Windows in order for the hardware itself to function correctly.

So, this all went down on Friday of last week. I received my new battery, a Sanyo produced FRU 45N1037, in the mail today. This one, some internet searching shows, has solid firmware on it.


Running this command in the terminal (I ran it as root) managed to move the window buttons back to the right and arrange them in the correct order.

gconftool -s /apps/metacity/general/button_layout -t string menu:minimize,maximize,close

In Linux, assuming that the program xclip is installed, the following command will copy the contents of a file to the clipboard. I find this useful for doing such things as posting programs here on this site.

cat filename | xclip -selection clipboard

I’m migrating my servers from Ubuntu 10.04 LTS (Lucid Lynx) to Ubuntu 12.04 LTS (Precise Pangolin), and both servers have multiple users and a complex network of user groups that I’d like to maintain. This is a bit more complicated than simply copying files, as many system processes have their own user IDs/groups and I don’t to mess with how the system defines those processes in the new install.

Source Machine: Make a Backup Directory

We just need somewhere to save our information before we do the transfer. I’ll be performing all of these operations as root. (Super user access is required to read the files we need.)

$ mkdir /user_migrate

Source Machine: Saving User Info

User info is saved in the /etc/passwd file. Each line in the file looks something like this:

jsmith:x:1001:1000:Joe Smith,,,:/home/jsmith:/bin/sh

The first field corresponds to the user’s login name. The second is “x” and represents the user’s password, which is encrypted and stored elsewhere. The third and fourth fields are numbers representing the user’s ID number on the system and the user’s primary group’s ID number. The next field is a comma-separated list containing text information about the user, with the first entry typically being the user’s name. (There may be extra commas for fields that are left blank.) The second to last field points to the user’s home directory, and the last identifies the user’s shell.

In Debian based systems such as Ubuntu, user ID numbers typically start at 1000 (500 on some other machines), with root being 0 and system IDs somewhere under 999. We’re really interested in saving the user information for any users over UID 1000. The strange exception to this is the UID 65534, which is commonly reserved for the “nobody” user (required for various processes), for whatever reason. We’ll save user data with the following command.

$ awk -F: '($3>=1000) && ($3!=65534)' /etc/passwd > /user_migrate/passwd.back

Source Machine: Saving Group Info

The group info is saved in /etc/group, and using the same idea as above we issue the command:

$ awk -F: '($3>=1000) && ($3!=65534)' /etc/group > /user_migrate/group.back

Source Machine: Saving Encrypted Passwords

This is a little bit more tricky. The /etc/shadow file contains passwords (and information about how frequently they are and need to be changed), but we only want to get password information for the users that have the appropriate UIDs, which aren’t listed in /etc/shadow. So, we issue the following command.

$ awk -F: '($3>=1000) && ($3!=65534) {print $1}' /etc/passwd | tee - | egrep -f - /etc/shadow > /user_migrate/shadow.back

 Source Machine: Saving Group Shadow Info

We’ll do the same for groups, saving only information that pertains to the UIDs that are being transferred.

$ awk -F: '($3>=1000) && ($3!=65534) {print $1}' /etc/passwd | tee - | egrep -f - /etc/gshadow > /user_migrate/gshadow.back

 Source Machine: Saving Users’ Data

We need to backup the /home directory. As we’re running tar with root permissions, this should automatically preserve permissions. Just in case, I’ll contain the preserve flag anyway.

$ tar -pzcvf /usre_migrate/home.backup.tar.gz /home

 

Save The Data

Use a command such as scp to transfer the data to another machine, or save somewhere reliable. Once the new machine is set up, create a directory at /user_backup/ (or somewhere reasonable) and transfer the files created above to that directory.

 

Transferring Users

Change directory to where the files are and become the root user. Then, issue the command:

$ cat passwd.back >> /etc/passwd

 Transferring Passwords

$ cat shadow.back >> /etc/shadow

 Transferring Groups

$ cat group.back >> /etc/group

Transferring Group Shadow

$ cat gshadow.back >> /etc/gshadow

 Transferring Users’ Data

$ cp home.backup.tar.gz /home
$ cd /home
$ gunzip home.backup.tar.gz
$ tar -xvf home.backup.tar

That _should_ do it.


A hard drive is going bad and I need to back it up (or, backup as much as possible) before it totally dies. I’ll clone the drive, to a new, working hard drive. This is also a handy way of completely duplicating a drive for backup or other purposes.

I’m going to use the command dd. This is an old UNIX command to convert and copy files. It will mirror the two drives for me. Of course, I can’t be logged in to the OS on the drive that I want to copy, so I’m going to use a live CD. I’m using an Ubuntu disc, because it’s what I have laying around.

  1. Boot into the live CD.
  2. Open a terminal, or use Ctrl+Alt+F1 to change virtual screens (Ctrl+Alt+F7 gets you back).
  3. Find where your drives are located. You can do this by typing “fdisk -l” or looking around in /dev. The drive I want to copy is /dev/sda and the destination drive is /dev/sdb
  4. Use the command “dd if=/dev/sda of=/dev/sdb conv=noerror,sync bs=1024″ where the “if” stands for “input-file”, “of” is “output-file”, “conv” gives a list of conversion options (in this case I’m saying to ignore read errors and “sync” tells dd to pad the blocks on the new drive with zeros), and “bs” gives the byte-size for incremental copying.
Now, sit back and wait a while.