Samba domain migration (to a new machine)


This project involved migrating a samba domain from an old server to a new server (different machine, different hardware), versions below

RedHat ES 3 –old server
Ubuntu 11.04 –new server

Samba 3.0.9 –old version
Samba 3.5.8 –new version

Mostly I used these instructions:
See the –“Replacing a Domain Controller”–

Get the SID: (security identifier for the domain)

Get the SID from the old machine:
net getlocalsid > /etc/samba/my-local-SID

The contents of the file will look like this

Restore the SID to the new machine:
net setlocalsid S-1-5-21-726309263-4128913605-1168186429

Files copied over from the old machine:
in the password and shadow make sure to get the user accounts and machine accounts, the machine accounts end with a $ e.g. “computername$”
/etc/group –I don’t think this this was necessary, but there may be groups you want to move

It isn’t necessary to use the entire files;
I copied the lines for users and machine accounts from old shadow and passwd and put them into the existing file on the new server. You may have to go to each workstation on the domain to get the machine names.

Make sure the hostname of the new machine matches the old one and there is a mapping in /etc/hosts for it if you start getting weird errors after you change the hostname.

IP address doesn’t matter, it can be different.

Samba files that need to be copied over;
smb.conf –main samba config file
secrets.tdb –stores machine account passwords
smbpasswd –stores user account and passwords, needs to be converted to tdbsam format “passdb.tdb”

I used pdbedit to convert the smbpasswd to passdb.tdb adjust your directories as needed;

pdbedit -i smbpasswd:/var/lib/samba/smbpasswd -e tdbsam:/var/lib/samba/passdb.tdb

To view what users and machine accounts made it to the new passdb.tdb file you can run the command. (The file is database file and cannot be viewed directly)
pdbedit -L

Errors you may get:

If you get these errors below:

idmap will be unable to map foreign SIDs: NT_STATUS_UNSUCCESSFUL


idmap will be unable to map foreign SIDs: NT_STATUS_UNSUCCESSFUL
ERROR: Initialization failed for alloc backend, deferred!
idmap_alloc module tdb already registered!
Idmap module passdb already registered!
Idmap module nss already registered!
idmap uid missing


idmap uid = 10000-15000
idmap gid = 10000-15000

to your smb.conf file and restart samba

I believe this sets the user and group Id mapping for machine ID’s

A problem I ran into:
The problem I ran into was finding the correct samba files to move over, for some reason there was a couple locations where the secrets.tdb and other files were, and I moved over the wrong files.

Leave a Reply

Your email address will not be published. Required fields are marked *