Backing up the entire file system, LVM problems
Hello everyone. Until recently I had running Ubuntu 8.04 and I opted to clean my laptop up, and install Fedora 10 (Its a bit of a habit of mine to ever so often just clean house and start from scratch >.< I know, I should stop, but I'm still looking for that one distro that I completely fall head over heels for). So I might have been a bit mindless on the installation of Fedora, and didn't look much into the details of what was going on during the instalation. As a result of this, Fedora created an LVM2 group and added both my hdds (creating 1 partition per hard disk plus the MBR in the first HDD) from both my hard disks. I hadn't noticed this until today, when I was looking into resizing my partitions to install another distro to multiboot and saw LVM2 in there, which I'll be honest about I had no idea what it was until I saw it there and googled it for a while.
(From now on, I'll say a few LVM2-related things which I may be wrong about, because I'm pretty new to it and my knowledge of it very small.)
After reading up on LVM2, it made perfect sense why my instalation may have defaulted to this option (because of my 2 hdd setup, it makes it easier to just represent the whole thing as one big group), but I am not very familiar with it. The problem that I have with this, is that for the Logical volume size was created to be EXACTLY the same size as the addition of the space of both my hd's. Because of this, I don't know whats the best approach to make space for a new partition for another distro. So, with this in mind I thought about perhaps just backing up the whole system, formatting my HDDs, and "manualy" reinserting the filesystem. I know that this is a REALLY ignorant and caveman way to fix my current problem. So I am very open to suggestions to deal with the problem the LVM way, as from what little I've read, LVM looks like something that would definately be worth a read if I ever plan to have some form of a modular grid (which I do plan to at some point :D)
However, I'm also curious as to a good way to backup a whole filesystem (by this I mean everything, starting from the "/" (root) directory, to all of it subdirectories and files recusively), keeping all permissions, symbolic links, etc intact. Would tarring everything handle that? How about mkisofs? I know a good way to do this with a whole drive is to dd, however, because of the current LVM setup this would not give the desirable result. Also, another consideration is that my drive that I'll be using is of a differente size than the disk I'll be moving from, and this drive already has alot of information I want to keep. And also, should I keep a copy of the MBR as well, or will the transition from LVM to a partition formatted to ext3 change the MBR completely?
So, anybody have any recommendations? If you know of a good way to do both, even if one is prefered to the other (and you have the free time ofcourse :D) please post both, because although my primary reason for wanting to know this is to resolve my problem, I'm also extremely curious as to the possible solution to both, and would make a nice addition to a little text file I've been building for a while about useful tools for certain purposes, and useful workarounds to certain issues.
Well, thanks in advance for anybody that read this whole thing, and even further thanks if you take time to write out a recommendation.
Two questions really deserves two posts. You won't get proper attention paid to one or the other question when you post like this (in my experience). So, to fulfill my prophecy, here's my answer to resizing your LVM.
Firstly, resize the LV down by the size you want to allocate to the new partition on the second disk (man lvresize). Then resize the physical partition down by the same amount (man pvresize). Now you should have free space on drive B that you can use to add a second Op/Sys.
If you are able to resize the logical volume so it only uses the first disk, you can even use vgreduce to remove the second drive from the volume group (man vgreduce).
Tar should work fine for backing up your filesystem, although you need to take some care in what you backup. For example you won't want to backup /proc and /dev.
Note that you will need to take some care with the tar options you use. On systems that use SELinux for example, you will want to use the --selinux option. If you use extended attributes, you may need to use star instead.
You probably don't need to keep a copy of the MBR, but that depends on how you plan to restore. For my system, I would expect that catastrophic failure would require replacement of the disk(s) and that a reinstall would be necessary. Hence my backups are only for those directories that would not be reinstalled (/etc, /home, /root, var, etc).
Thanks for the posting tip. Although I've browsed around this forum frequently I didn't join recently and don't post with enough frequency to have known that, so definitely appreciate the tip :D
Also thanks for the tip about resizing the LV. I haven't tried it yet (a bit busy with something with a deadline right now that came up out of nowhere), but I'll definitely give it a try as soon as possible.
Thanks for the tip. I did already start tarring just about everything (except proc, which I thought I wouldn't need because of its purpose, but tried it just as well and stopped when after a while of running it I stopped, and hexdumped it to see that it was starting to get the whole filesystem again because it stumbled into itself..or at least thats what I understood).
One question I do have about proc though, is how it works with a new installation. What I wish to do is basically backup my whole installation and just pass it over to the HDD again once reformatted, to have it be "identical" to what I had (something similar to whats done with clonezilla for multiple dekstops, but with my current filesystem). But what I'm not sure about is how the /proc directory works. Does it generate all the appropriate files within it to represent the running processes by itself, or do I need to keep anything.
Also, for tarring what I did tar, I used the following:
tar --create --verbose --atime-preserve --preserve --file=dir.tar dir
Should this keep all the appropriate elements I want to keep (basically, permissions and symlink references)?. A NOTE: I do have SELinux installed by default, but I haven't set anything up, so I'm guessing that my files are not configured for it. How can I find this out for sure?
Thanks for both of you for spending the time to answer my questions :D
Greatly appreciate it.
Try "getenforce" to see if SELinux is active, however I would expect it to be active and the contexts set. No harm is preserving them if you don't need them and a major pain if you don't but do need them.
I can't give you details on /proc I'm afraid. If you want to back everything up, boot a live CD that can handle LVMs, and back the lot up.
I use tar --selinux cjf to do my backups - the default behavious of tar in CentOS is to preserve ownerships, permissions, symlinks, etc, so I don't need to explicitly specify these.
What exactly are you trying to achieve here?
|All times are GMT -5. The time now is 10:08 AM.|