LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-28-2006, 03:36 PM   #1
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,440

Rep: Reputation: 80
partitions to lvm2 without losing data and reverse order


I want to go from partitions to LVM2 without losing my data and want to know how to go back without using a separate drive to backup my data on because I do not have that. I have one drive that is 320 gigabytes, so if I want to keep my data such as music and pictures, how do I install FC6 with LVM2 without losing my data? Currently I am using Debian Etch Testing with separate /home and / partitions.

fdisk -l
Code:
debian:~# fdisk -l

Disk /dev/sda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1           14599       38913   195310237+  83  Linux
/dev/sda2           14356       14598     1951897+  82  Linux swap / Solaris
/dev/sda3   *           1       14355   115306506   83  Linux

Partition table entries are not in disk order
debian:~#
df -h
Code:
debian:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             109G  2.8G  100G   3% /
udev                   10M   60K   10M   1% /dev
devshm                380M  8.0K  380M   1% /dev/shm
/dev/sda1             184G   92G   83G  53% /home
debian:~#
 
Old 10-28-2006, 04:48 PM   #2
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,003

Rep: Reputation: 304Reputation: 304Reputation: 304Reputation: 304
There is no way to "convert" an existing hard partition to LVM, nor to "convert" an LVM logical volume to a hard partition. The only way is to copy data. You need free space to copy the data to temporarily during the process. Either an external drive or just free space on your current drive. You could also copy data by burning it DVD's.

You could do a single disk "conversion" with your current setup. You're currently using 92Gb of /home and you have 100Gb free on /. Make a new directory under / named home_tmp, then copy all of /home to this new directory (which is on a different partition than /home). Then you can wipe out /home and recreate it - empty - using LVM. Then copy /home_tmp back to the new LVM-based /home and delete /home_tmp.

Now you can install FC6 from scratch using LVM on that old / partition. That original / partition would become a LVM "physical volume", to be added to a "volume group", then divided back up into "logical volumes". You can add it to the same volume group that you used for your /home in the previous step.

If you ever want to go back to hard partitions and stop using LVM, you will have to do more moving/copying of data. There is no "conversion" available.

Personally, I would not want to do any of the above without first backing up my important data to offline storage (an external disk or a bunch of DVD's). But it sounds like that's exactly what you want to do. Not recommended, but it's your call.
 
Old 10-28-2006, 05:07 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,241

Rep: Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020Reputation: 1020
Side issue, sorry to butt in.
haertig, what happens if you take an LVM disk out and put it in another (non-LVM) system ???.
What about a disk that is dedicated (entirely) as a PV - I believe the partition table is modified in that case.
True ???.
Does the new system see it as a broken disk ???.
 
Old 10-28-2006, 06:22 PM   #4
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,003

Rep: Reputation: 304Reputation: 304Reputation: 304Reputation: 304
Quote:
Originally Posted by syg00
what happens if you take an LVM disk out and put it in another (non-LVM) system ???.
Do you mean what do you do to make it useable in that other system? First you would run pvscan so the new system can locate the physical volume(s). Then you run vgchange -a y to activate all the volume groups. Then the new system can mount the LVM volumes on the disk. These are the same steps I follow when I boot a Knoppix CD and want it to see the LVM logical volumes on my harddisk.

Quote:
What about a disk that is dedicated (entirely) as a PV - I believe the partition table is modified in that case.
True ???.
I do not have one of these personally. I've always used partitions as LVM physical volumes, never an entire disk. However, I'm 99.999% sure that an entire disk (not a partition) that is flagged as an LVM physical volume does not even have a partition table. The LVM header created by the pvcreate command replaces the MBR when you're talking about an entire disk. When you pvcreate on a partition, then it's only that partition that is modified, the MBR is left alone (except the partition type is flagged as "8e" in the partition table).

Quote:
Does the new system see it as a broken disk ???.
I would expect it to be seen as unpartitioned or "unknown" (if the entire disk was a physical volume), since no standard MBR would be present. After running pvscan and vgchange -a y then the new system should be OK with the "broken" disk. If some other OS (Windows?) refused to work with the LVM disk (say it refused to repartition or reformat it due to the confusing "MBR"), then you might have to use dd to zero out the MBR first.
 
Old 10-28-2006, 07:21 PM   #5
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,440

Original Poster
Rep: Reputation: 80
Quote:
Originally Posted by haertig
You need free space to copy the data to temporarily during the process. Either an external drive or just free space on your current drive. You could also copy data by burning it DVD's.
What I was saying is that I do not have an extra drive to do the backup otherwise I would not be here asking. For DVDs, that would be way too many and too much time.

Quote:
You could do a single disk "conversion" with your current setup. You're currently using 92Gb of /home and you have 100Gb free on /. Make a new directory under / named home_tmp, then copy all of /home to this new directory (which is on a different partition than /home). Then you can wipe out /home and recreate it - empty - using LVM. Then copy /home_tmp back to the new LVM-based /home and delete /home_tmp.

Now you can install FC6 from scratch using LVM on that old / partition. That original / partition would become a LVM "physical volume", to be added to a "volume group", then divided back up into "logical volumes". You can add it to the same volume group that you used for your /home in the previous step.
I was thinking if this would be possible with LVM2, but now I know how to do it after thinking about it and reading what you wrote. I've read and been taught about LVM, but never practiced with it on my own. Maybe I will play around with the partitioner part of the installer (disk druid I think on Fedora) but never apply the changes until I am confident on what I am doing. Then if I am unsure of something, I could take a picture with my camera and come back here to post the picture. I did use LVM a few times, but always used the automatic partitioning wizard, but that was before I learned much more about LVM. I only knew what LVM was good for. This time I must use Disk Druid right? For the first paragraph of what you said, I should use many commands, and then the second paragraph, I should use Disk Druid, right?

Now I'm thinking about something I never thought of. It seems that I have to have hard partitions to use LVM. Those hard partitions are are Physical Volumes used to be added to a Volume Group, so really LVM is done on top of hard partitions, not as a replacement for them, right or wrong?

Quote:
If you ever want to go back to hard partitions and stop using LVM, you will have to do more moving/copying of data. There is no "conversion" available.
I did not mean conversion. I did not see a solution to my problem, so that is why I was asking.

Quote:
But it sounds like that's exactly what you want to do. Not recommended, but it's your call.
Yep, I do, and there are many who reuse their home partitions without formatting them to easily reinstall a newer version of their Linux distro without losing their data, and also keeping their config that way too. This will be similar.
 
Old 10-28-2006, 09:03 PM   #6
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,003

Rep: Reputation: 304Reputation: 304Reputation: 304Reputation: 304
I am not familiar with this "Disk Druid". I assume it must be the partitioning part of Fedora's installer. I seem to remember reading that somewhere. I also seem to remember reading that newer versions of Fedora use LVM by default.

I don't know if you "must" use Disk Druid. That question might be better asked on the LQ.org->Fedora forum. I would think that Fedora would allow you to partition things manually first, before starting the Fedora install, and then have Fedora's installer work with your existing partitions. That's only a guess, I don't know Fedora's installer. I'm not sure that it really matters if you use Disk Druid or not, so long as whatever you do you do not let the installation partitioner/formatter touch your existing LVM partition (physical volume). I would stay far far away from anything that says "automatic disk configuration" or "default installation" or anything like that. Go for "manual". I would certainly assume that Disk Druid would have manual partitioning available as an option.
Quote:
so really LVM is done on top of hard partitions, not as a replacement for them, right or wrong?
Right and wrong. How's that for an answer?! You can use hard partitions as physical volumes for LVM. If you do that, yes, LVM is "on top of" regular hard partitions. But you can also use an entire disk as a single LVM physical volume. In that case, there are no hard partitions, no partition table, no MBR. So LVM is not "on top of" anything other than the physical disk.
Quote:
and there are many who reuse their home partitions without formatting them to easily reinstall a newer version of their Linux distro without losing their data
Of course. This is the main reason why you'd want your /home on a seperate partition. You just need to make sure that your Linux reinstall does not touch that /home partition. That's why you need to stay away from automatic and default installations. They might assume that you're giving them the entire disk to work with, and wipe out your /home during the install.

Also, the best laid plans of mice and men sometimes go wrong. So even if you tell the installer to leave your /home alone, you might have messed up your command or run into a bug in the installer. I'll never concede an argument and say, "You're right, you DON'T need to backup". Without backups, you always procede at your own risk. "Others have done it without losing data" may be true, but that means nothing to me. But if it's good enough for you, it's your computer and your data. I won't argue ... I just don't agree with your choice. Also, what happens if you successfully transfer your data without loss, and then you have a power surge and your disk frys the next week. You'll probably be wishing you had backups.
 
Old 10-30-2006, 11:36 AM   #7
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,440

Original Poster
Rep: Reputation: 80
Before installing and while preparing, I will create a partition but not format it with a filesystem. I think I saw something in the Fedora installer "create a LVM physical volume", and I wondered if it was the same or different as creating a partition, and not formatting it with a filesystem. Last night I just installed the package from the Debian Etch Testing repositories, lvm2. I plan on reading the man pages and studying lvm at www.tldp.org more before I do it on my own. I've also reorganized my backup, deleted files that I didn't need, and created the home-tmp, then moved it to /. I also burned the FC6 iso, booted it, and played around with the partitioner without saving any changes. Daylight savings time meant an hour extra of Linux for me

Quote:
Originally Posted by haertig
I am not familiar with this "Disk Druid". I assume it must be the partitioning part of Fedora's installer. I seem to remember reading that somewhere. I also seem to remember reading that newer versions of Fedora use LVM by default.
Yes, Disk Druid is what the partitioning part of the installer is called. It is for the manual partition. I plan to use it some, but I can't for everything. You are right about Fedora using LVM as default. That happened when I installed FC5 for somebody.

Quote:
I would certainly assume that Disk Druid would have manual partitioning available as an option.
Disk Druid is the manual partitioning software.

Quote:
If you do that, yes, LVM is "on top of" regular hard partitions. But you can also use an entire disk as a single LVM physical volume.
Creating seperate partitions is best in my case because I never know if I will end up going back to regular partitions, and it makes it easier to do that without losing my backup.

Quote:
This is the main reason why you'd want your /home on a seperate partition. You just need to make sure that your Linux reinstall does not touch that /home partition. That's why you need to stay away from automatic and default installations. They might assume that you're giving them the entire disk to work with, and wipe out your /home during the install.
Yes, that is what I have been saying. This is really not much different than just saving your home partition to have it mount as /home again with another install of Linux.

Quote:
Also, the best laid plans of mice and men sometimes go wrong...
Okay, that is fine, but I did not come to get help or ask about backing up. I don't want your approval for not doing it this time. In other words, I am not trying to get you to say "You're right". I'm here to get help with LVM, and I got what I need from you, asking questions, a linux user group presentation, and reading online. It's possible that while I was moving about 80 gigs of data from two different partitions, that the power could have gone out in the middle of it, and I would have lost data. I used copy instead, and then deleted the other one. I went to watch a video for my telecourse. When I have the resources, I will backup. Most of what is important is saved as a copy somewhere else. Thanks for the help. You made me think about some things I knew about, and pointed out some others that I did not know about.

Last edited by fakie_flip; 10-30-2006 at 11:43 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Resizing of Linux Partitions without losing data sandhyarevuri Linux - General 2 02-11-2006 10:22 AM
question about reinstalling without losing data on seperate partitions? Lleb_KCir Linux - General 4 04-18-2005 02:10 AM
Install Slack 10, resize partitions w/o losing data Hal Linux - General 4 09-03-2004 10:00 AM
Join Partitions Without losing data aeruzcar Linux - General 0 06-28-2004 11:54 PM
howto add 2 partitions together without losing data? dfuse Linux - Newbie 3 09-09-2003 07:47 AM


All times are GMT -5. The time now is 12:12 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration