Results 1 to 10 of 19
Long story short: I want to move my root partition to an empty logical volume. I have /boot mounted on a regular partition, so there won't be any worries about ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 05-02-2008 #1
Moving root to a logical volume
Long story short: I want to move my root partition to an empty logical volume. I have /boot mounted on a regular partition, so there won't be any worries about the machine not booting. What I want to know is if the following scheme sounds reasonable.
Long story: I have four 250 GB drives (sda - sdd).
Sda is split into four partitions:
sda1 == /boot
sda2 == swap
sda3 == /
sda4 == part of a logical volume that includes all of sdb (/dev/mapper/Main-MainVolume)
Sdc and sdd are all one logical volume -- /dev/mapper/Backup-BackupVolume
The volume Backup-BackupVolume is (surprise surprise) where I keep some of my backups and won't be touched. I want to move all the information currently mounted on sda3 on to Main-MainVolume.
My thoughts on how to complete the process are as follows,
- sudo cp -upr / /mnt/fakeroot # Main-MainVolume is mounted at /mnt/fakeroot
- sudo rm -rf /mnt/fakeroot/boot
- Edit fstab to mount Main-MainVolume at /
- Remove fstab line that mounts sda3 at /
- Reboot
So, do you think that will work, or will I be left with an unbootable mess?Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode
- 05-02-2008 #2
So does anyone see any errors in the little 5 point process in my previous post, or do you think it will work?
I'm mostly worried about the first point, since I'm not sure if "cp -upr" will be an accurate enough copy for the machine to boot.Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode
- 05-02-2008 #3
Hi smolley
This is probably a dumb question but ... are you trying to copy an active operating system with the first command? I would have thought you need to boot from another OS for example a live CD to do the copy.
Ed: maybe I'm taking the list a bit too literally but I don't think step 2 is required since you will mount your boot partition to your new /boot and I'd just # out fstab entries which are no longer required. btw I have never used LVM ... but that may be obvious from my post.
- 05-02-2008 #4
Thanks for the reply.
Yes, I'm trying to copy an active OS, and you bring up a good point. Maybe I should be doing this from a liveCD in order to prevent complications. Thanks for the tip.
Step 2 isn't strictly necessary since I'll be mounting sda1 onto /boot, but it will save a small amount of space on the LVM, and seems like the correct thing to do. The reason I need to keep /boot on a regular partition is that I don't think the machine can boot from a logical volume.
I need to be careful to execute step two in such a way that I only delete the contents of /mnt/fakeroot/boot and not the directory itself, since I will be mounting sda1 there after all's said and done.
Thanks for you comments.Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode
- 05-02-2008 #5
As you said ... I don't think you will be able to boot the system unless you retain the separate boot partition you have at present.
I guess as long as you have a live CD you should be able to put fstab back as it was if it all goes pear shaped. I'm working on the basis sda3 contains all root info at present and you are just copying it to your fake-root lvm. I'd use cp but leave the rm bit until after you prove the system boots.
I'm not sure how cp will cope with links etc. I've only used it to cp home rather than root partitions in the past. As I said I have not used lvm so partition copying and dd have been available to me.
btw why are you using the u option in the cp command?
- 05-02-2008 #6
Yeah, sda3 contains everything from root except for /boot, and I want an exact copy on Main-MainVolume (which will be temporarily mounted at /mnt/fakeroot).
I'll let you know how well cp goes after I try it (sometime tomorrow).
Force of habit!!!
I only really need -pr to recursively copy and preserve permissions. The -u is only there cos my fingers instinctively type it after typing cp 
Cheers for the advice.Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode
- 05-03-2008 #7
OK, done the copying, but, luckily, I've also done a bit of thinking.
My little five point plan will not work, and here's why. Altering fstab to mount my LVM at / is all well and good, but how does the machine know to look in the LVM for /etc/fstab rather than sda3 as previously? Some sort of mystical sixth sense?
No.
It knows where to mount the root filesystem because that information is in /boot/grub/menu.lstAll that "root=UUID=8ae29..." stuff is telling it on which drive to mount /. In this case it should mount it on the drive with that UUID, which can be found in /etc/fstab (sda3 as I said earlier)Code:title Ubuntu 8.04, kernel 2.6.24-16-generic root (hd0,0) kernel /vmlinuz-2.6.24-16-generic root=UUID=8ae29e85-952a-4e9e-88f4-45367f59d5fa ro quiet splash initrd /initrd.img-2.6.24-16-generic
So now I need to think carefully. I obviously can't just change the fstab, cos then god knows what sort of mess it would get itself into when it tried to boot. I'll need to edit menu.lst to let it know that root=/dev/mapper/Main-MainVolume. Also, I'll probably need to add a couple of lines to /boot/grub/device.map to define Main-MainVolume as a drive that grub can access.Code:# /dev/sda3 UUID=8ae29e85-952a-4e9e-88f4-45367f59d5fa / ext3 relatime,errors=remount-ro 0 1
Some careful thinking, and a little googling, is required before I continue.
Any advice is welcome
Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode
- 05-03-2008 #8
Yes it helps if you update grub boot options
how could I miss that! You should find you can refer to the volume ... example off the forums
I'm not sure you need to update device.map as I think this is only used during the grub install process.Code:title Fedora (2.6.24.5-85.fc root (hd0,2) kernel /vmlinuz-2.6.24.5-85.fc8 ro root=/dev/VolGroup00/LogVol00 rhgb quiet initrd /initrd-2.6.24.5-85.fc8.img
Has google turned up the solution yet?
Ed: I'm not sure if you will be able to use
replaceing /dev/sda1 with your volume info to determine UUID and use that to identify root in both fstab and the grub menu.lst file.Code:sudo vol_id /dev/sda1
- 05-03-2008 #9
So I didn't resort to google in the end. Just a lot of thought, a look at the configuration of another machine I have access to, and a few bottles of beer. :smoke:
After using a liveCD to copy the contents of sda3 onto Main-MainVolume, I booted back into Ubuntu (with / still on sda3). I then mounted Main-MainVolume at /mnt/fakeroot, and edited /mnt/fakeroot/etc/fstab to look like the following, (EDIT: In case it's not clear, I changed the mount point of root by editing the line with "/dev/mapper/Main-MainVolume")Then I opened up /boot/grub/menu.lst, and added an extra entry, as follows,Code:# /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 # /dev/sda3 /dev/mapper/Main-MainVolume / ext3 relatime,errors=remount-ro 0 1 # /dev/sda1 UUID=10882051-4902-40f4-98b6-f0062a589e51 /boot ext3 relatime 0 2 # /dev/sda2 UUID=89a269ef-c107-4d86-88b3-77b413971a18 none swap sw 0 0 /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0 /dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0 /dev/mapper/Backup-BackupVolume /mnt/backupdisk ext3 defaults 0 2
From looking at my work computer (which has / mounted on an LVM), I could see that no change was needed to device.map. As you said, it was probably just an installation file for grub.Code:title Ubuntu 8.04, kernel 2.6.24-16-generic root (hd0,0) kernel /vmlinuz-2.6.24-16-generic root=UUID=8ae29e85-952a-4e9e-88f4-45367f59d5fa ro quiet splash initrd /initrd.img-2.6.24-16-generic quiet title Ubuntu 8.04, kernel 2.6.24-16-generic (recovery mode) root (hd0,0) kernel /vmlinuz-2.6.24-16-generic root=UUID=8ae29e85-952a-4e9e-88f4-45367f59d5fa ro single initrd /initrd.img-2.6.24-16-generic title Ubuntu 8.04, memtest86+ root (hd0,0) kernel /memtest86+.bin quiet title Ubuntu 8.04, kernel 2.6.24-16-generic (new mount point) root (hd0,0) kernel /vmlinuz-2.6.24-16-generic root=/dev/mapper/Main-MainVolume ro quiet splash initrd /initrd.img-2.6.24-16-generic quiet
After making those changes, I rebooted, chose the last entry from grub, and crossed my fingers......
.......And here I am, logged in to the new system!
Turned out it was pretty easy in the end, but it was important that I took it slowly, and thought about every step. If I had have charged ahead with my original "5 point plan", I might have screwed my system quite badly (although maybe not unrecoverably). Instead, a bit of thought and a few beers resulted in a pain-free transition!
Thanks for your tips along the way Jonathan183.Last edited by smolloy; 05-03-2008 at 05:15 PM. Reason: Make things a little clearer
Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode
- 05-03-2008 #10
Glad it worked ... and the method is clear for others to follow if they have a similar issue ... including the beer!


Reply With Quote

