Preserving /home directory on LVM while switching distros

I have been using Slackware since I remember. Well, it wasn’t that long ago but  it was one of the first distros I tried to use. It works (like a charm, I can’t deny) on my laptop, PC, VMs and in few other places. Times changed and now I decided to switch to other distro I know and like which is Debian. The question is, how to do this and not to loose any data in /home directory?

On virtual machine with Slackware I have four partitions:

/dev/sda1 – / ext4 (root directory)
/dev/sda2 – swap
/dev/sda3 – LVM PV
/dev/sda4 – LVM PV

As numbers say (and I say), all of them are primary.

Two PVs, sda3 and sda4 are merged into one VG named “user_data” and on this there is one LV named “home” containing /home directory with ext4 filesystem. I know this design is a bit weird but on this machine I used to play with LVM (adding, removing, resizing and more) and this is what has left. What I want to do is to throw away everything except /home directory. The final, satisfactory result will be fresh Debian installation with the same /home content. There is not much to do with partition design in my case, so I won’t be doing strange joining nor splitting.

So this is what to do if you want to save existing LVM partitions while installing Debian.

Start normal installation. Go through first steps, then in “Partition disks” window select manual partitioning method. Installer should properly recognize existence of LVM volumes. There should be two lists of devices on the screen, one starting with “LVM” referring to VG and one entitled “SCSI1” which is hard disk (virtual in my case). In both there are sublists of devices.

Under “SCSI1” there are all physical partitions. Since we do not want to change PVs we are interested only in sda1 (#1) for root and sda2 (#2) for swap. In “Partition settings” displayed after selecting #1 choose filesystem type you  want in “Use as”, set mount point to “/” and agree on formatting partition. Be sure that bootable flag is set and that’s it. Swap (#2) configuration is straightforward as installer should detect it automatically.

Under “LVM” there are listed all existing LVs.  In our example there is only one and we want it to be /home. What we need to do is to select it and setup as a normal partition. Extremely important is to not format it. Make sure the chosen option says “no, keep existing data”.

After that just select “Finish partitioning and write changes to disk” then confirm formatting of partitions #1 and #2. Continue normal installation and  after reboot we have what we wanted: /dev/mapper/user_data-home device mounted to /home directory with all data already there.

21. October 2011 by resset
Categories: Software | Tags: , , | Leave a comment

Moving existing local GIT repository into a fresh gitolite setup

One of the tools I use is gitolite, a nice solution for hosting GIT repositories with privileges control and many more. Installation is trivial, just follow the tutorial instructions.
Let’s say you already have local repository and start to use gitolite on a remote server. This may happen when changing servers, git hosting provider etc. How to safely transfer your project? Firstly, you have to create new (usually bare) repository. In gitolite you just add to gitolite-admin/conf/gitolite.conf something similar:

Then go to your local working copy and type:

This will show you all remote repositories that you used to connect with. In my case there was only “origin”, and it was the exact one I wanted to replace. With following commands you remove existing repository:

and add a new one:

What will show more verbose version of “git remote” now?

That’s it. Now you can send your data to server:

Because it is very first “push” into an empty repo, you must explicitly point which remote and what branch you are sending data to. This will be remembered as default, so you don’t need to type it anymore. The same applies to the first “pull” or “fetch”:

21. October 2011 by resset
Categories: Software | Tags: , | 4 comments

Newer posts →