Archive for the ‘Hardware’ Category

Feb
11/10
Migrate users from one Linux machine to another
Last Updated on Thursday, 11 February 2010 12:36
Written by satukila
Thursday, February 11th, 2010

Have you ever had a need to migrate current running Linux users from installation to another? That would be a simple task if the user count was low. But  what happens when the user count is in the hundreds? What do you do then? If you’re not using LDAP, you know you will have to migrate the users’ data, passwords, etc from the old machine to the new. Believe it or not, this is just a matter of a few commands – not necessarily simple commands, but it’s not as complex as you would think.

In this article I am going to show you how to make this migration so your Linux users do not loose their data and their passwords are all retained.

What we migrating

The list is fairly simple:

  • /etc/passwd - Contains information about the user.
  • /etc/shadow - Contains the encrypted passwords.
  • /etc/group - Contains group information.
  • /etc/gshadow - Contains group encrypted passwords.
  • /var/spool/mail - Contains users email (the location will depend upon the mail server you use).
  • /home/ - Contains users data.

Unfortunately these files can not simply be copied from one machine to another – that would be too easy.  Just make sure you enter the following commands correctly.

Source machine

These are the commands you will need to run on the machine you are migrating users FROM. I will assume you are doing this on a system that uses a root user (such as Fedora), so all commands will be done as root:

mkdir ~/MOVE

The above command creates a directory to house all of the files to be moved.

export UGIDLIMIT=500

The above command sets the UID filter limit to 500. NOTE: This value will be dictated by your distribution. If you use Red Hat Enterprise Linux, CentOS, or Fedora this value is shown in the command above. If you use Debian or Ubuntu that limit is 1000 (not 500).

awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534)’ /etc/passwd > ~/MOVE/passwd.mig

The above command copies only user accounts from /etc/passwd (using awk allows us to ignore system accounts.)

awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534)’ /etc/group > ~/MOVE/group.mig

The above command copies the /etc/group file.

awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534) {print $1}’ /etc/passwd | tee – |egrep -f – /etc/shadow > ~/MOVE/shadow.mig

The above command copies the /etc/shadow file.

cp /etc/gshadow ~/MOVE/gshadow.mig

The above command copies the /etc/gshadow file.

tar -zcvpf ~/MOVE/home.tar.gz /home

The above command archives /home.

tar -zcvpf ~/MOVE/mail.tar.gz /var/spool/mail

The above command archives the mail directory. NOTE: If you are using Sendmail this is the correct directory. If you are using Postfix that directory most likely will be /etc/postfix.

Now it’s time to move everything in ~/MOVE over to the new server. You can do this using the scp command like so:

scp -r ~/MOVE/* USER@IP_OF_NEW_SERVER:/home/USER/

Where USER is the username you will use to send the file and IP_OF_NEW_SERVER is the address of the new server. NOTE: If this server is not on line yet you can always copy these files onto a thumb drive and move them that way.

Target machine

Now we’re working on the new server. Follow these commands (run as the root user):

mkdir ~/newsusers.bak

The above command will create a new directory that will house the backup of the current users.

cp /etc/passwd /etc/shadow /etc/group /etc/gshadow ~/newsusers.bak

The above command will copy the necessary files to the new backup directory.

cd /PATH/TO/DIRECTORY
cat passwd.mig >> /etc/passwd
cat group.mig >> /etc/group
cat shadow.mig >> /etc/shadow
/bin/cp gshadow.mig /etc/gshadow

The above commands will restore all password files onto the new system. NOTE: Where /PATH/TO/DIRECTORY is the location where you copied the files onto the new system.

cd /
tar -zxvf /PATH/TO/DIRECTORY/home.tar.gz

The above commands will first change you to the / directory and then unpack the archived /home directory. NOTE: Where /PATH/TO/DIRECTORY is the location where you copied the files onto the new system.

cd /
tar -zxvf /PATH/TO/DIRECTORY/mail.tar.gz

The above commands will first change you to the / directory and then unpack the archived/var/spool/mail directory. NOTE: Where /PATH/TO/DIRECTORY is the location where you copied the files onto the new system.

You can now reboot your system with the users in place.

Possibly Related Posts:


Feb
08/10
Build Your Own PC February 2010: CPU, Motherboard And RAM
Last Updated on Monday, 8 February 2010 04:35
Written by kuldeep singh
Monday, February 8th, 2010

Whenever I’m thinking of building a new PC I’m starting the selection process months earlier. I begin with an analysis of the needs, something that is often forgotten by users. What will the computer be used for? Will it be a gaming PC, office, photo manipulation, server or all purpose PC? What connectors do I need? Someone with a digital camera that connects via Firewire for instance should make sure that the PC has Firewire. The same is true for other elements like USB or eSATA.

The PC that I want to build for instance has to be an all purpose PC. It should be able to run the latest games but it will mostly be used for work. The PC should be as silent as possible without running to hot. The operating system will be Windows 7 64-bit. It should support USB 3.0 which has been released some time ago and will become the new standard to connect USB devices.

I have decided to divide the article into different parts to be able to concentrate on specific hardware and why I have chosen them. We begin with the selection of the CPU, motherboard and RAM, the core components of a computer.

Build Your Own PC: CPU

PC users have a wide selection of CPUs. It basically comes down to the two manufacturers AMD and Intel who both produce processors for lots of different purposes. We are looking for a desktop cpu which means that we will concentrate our search on those. Top of the line CPUs are usually to expensive for their performance gain over the rest of the CPU lineup (unless you have the cash lying around).

This basically leaves two options: An Intel Core-i7, Core-i5 or an AMD Phenom II X4. It is now time to use the Internet or computer magazines to find benchmarks and reviews of those CPUs. You can use many hardware shops like Newegg, CPU Benchmarks or Tomshardware as well as many other sites for that.

You will end up with a few CPUs that would make a good selection: Intel Core i7-860, Intel Core i7-920, Intel Core i5-750 or AMD Phenom II X4 965 BE. The final selection now is not only determined by the performance but also the price and quality of the CPU. The AMD CPU is cheaper than all Intel CPUs. It’s performance is lower than the Intel CPU performance but it should be sufficient for all computing tasks.

The Intel Core i7-860 is the fastest Intel CPU in this field but also the most expensive one, we are talking about a difference of €100 here.

  • My Selection: Intel Core i7-860
  • Alternative: AMD Phenom II X4 965 BE

Build Your Own PC: Motherboard

The selected CPU leads directly to the motherboard that we need. The Intel Core i7-860 needs an LGA-1156 CPU socket type  motherboard. We use our needs and wishes that we came up with earlier in this step. The motherboard needs to offer all the connectors that we need, e.g. Firewire, which makes the selection process easier for us as we need to find and evaluate only those motherboards that support all the features that we need.

What should the motherboard offer?

  • Minimum number of memory slots: 4
  • CPU: At least Intel Core i7-860
  • Memory: At least DDR3 1600
  • USB 3.0
  • Onboard Lan: 1000/100/10
  • Onboard Sounds: Indifferent
  • Onboard Video: No
  • SLI: No
  • SATA 3 GB/s: At least six
  • Raid: No
  • Other Connectors: Not needed

This may obviously look different when you build your own PC. It is again important to make an initial selection of 2-3 motherboards that offer what you are looking for. The next step is very important. Perform a search for that motherboard on the Internet and add keywords like problem, error, or help to it. Take a look at those posts and the number of them to see how likely it is that you might run into troubles.

The Gigabyte GA-P55-USB3 is one of the few motherboards that support USB 3.0 right now. It is not as expensive as many other  motherboards that offer USB 3.0 (costs $120).  The other motherboards that I have taken a look at are the  MSI P55-GD85 which retails for about $220 which has a surprisingly similar configuration to the Gigabyte motherboard and the ASUS P7H57D-V EVO for $200 which is the only one of the three with an HDMI port.

The Gigabyte GA-P55-USB3 offers everything that I need plus it is roughly $100 cheaper than the rest of the motherboards. That’s enough to make it my pick in the motherboard category.

My Selection:

  • GIGABYTE GA-P55-USB3

Build Your Own PC: RAM

The selection of the motherboard determines the RAM – or computer memory – that we can use. We also need to determine at this point if we want more than 4 Gigabytes of RAM. We would need a 64-bit operating system if we do.

We do need DDR3 RAM (to be precise 240-Pin DDR3 SDRAM)  as this is the computer memory supported by our motherboard. We also need dual-channel or quad-channel and not triple-channel RAM as we have selected the Core i7-860 cpu. This means that we either need to shop for 4 Gigabytes of RAM or a factor of that (8, 12 or 16 which is the maximum supported by the motherboard).

It does not really make sense to buy less than 4 Gigabytes as it would limit the PC’’s performance. Avid gamers or those that run applications that need as fast RAM as they can get might want to take a look at overclocked RAM or RAM that can be overclocked nicely. I usually stay away from that RAM though as the performance gains usually do not justify the price increase. The motherboard supports up to DDR3-2200.

My Selection

  • CORSAIR XMS3 8GB (4 x 2GB) 240-Pin DDR3 ($270)
  • G.SKILL Trident 8GB (4 x 2GB) 240-Pin DDR3 SDRAM DDR3 2000 (if you want faster) ($290)

This was the first part of the Build your own PC February edition. I hope you enjoyed this as much as I do. Leave a comment if you have questions or suggestions.


Possibly Related Posts: