The Red Hat corporate help desk kindly sent me a new laptop for temporary use until I get the replacement for my XPS M1330 from Dell. The loaner was a 32-bit machine, and my old drive was 64-bit, so rather than bother with a hard disk transplant, which would mean reinstalling the system, I decided to move my data from my old laptop hard disk (which survived just fine) to the new system, and figured I might as well document it for newer folks who might not know how to do it cleanly.
Keep reading “below the fold” to find out what I did and why.
Set up new system. Obviously I used Fedora 10! I set up LVM on my hard disk, as I always do, and tried to make a guesstimate of how much space I needed in each logical volume (file system). That turned out to be wrong, but LVM made it easy to fix later without starting all over again.
Word to the wise: Never use the built-in default name “VolGroup00” for your volume group. Name it something more descriptive, like “vgDell” or “vgF10lap.” This makes later steps much easier. My old system had “vgM1330” and my new system is “vgT60.” Also, I’m assuming you make a separate logical volume for /home, which I recommend to everyone.
Create an equivalent first user. When the initial boot screens (firstboot) came up, I created a new user pfrields which would get the same UID/GID (500/500) that was used on my old system (also pfrields — this does make things easier too).
Attach the old laptop drive, presumably removed from the old system by now, into a USB carrier. I happened to have one that was SATA compatible, so this was a snap. Attach the USB and turn it on.
Activate the LVM volume group on the old drive. Fedora automatically detects the volume group, but it does not activate the logical volumes until you make the VG available. I used this command after doing su - to become root:
vgchange -a y vgM1330
Mount the volumes you need. I only needed the /home volume and a couple files in /etc. My old root volume / was called root and my old /home was called home (go figure), so I did this:
mount /dev/vgM1330/root /mnt
mount /dev/vgM1330/home /mnt/home
Now I could do some selective copying from /mnt/home/etc to /etc as needed.
Oops, here’s a problem — am I sure I have enough space for all my old system’s /home data on the new system’s logical volume for /home? I used df to check, and sure enough I flubbed it. I had only made a 32 GB partition on the new system, and I had almost 60 GB of data on the old system to move!
On the new system I had made two 32 GB volumes, one possibly to use as a local Fedora mirror, and the other for /home. So now I needed to basically reduce one volume to close to nothing and increase the size of the other. The mirror volume device name is /dev/vgT60/fedora, mounted at /var/www/fedora. It’s very important to perform these steps in this order, or else you risk losing data! First, I unmounted the mirror volume:
umount /var/www/fedora
Next I checked the file system for consistency. If you don’t do this, you can’t proceed with safety:
e2fsck -f -y /dev/T60/fedora
Then I resized the file system down to 1 GB using the device name that was previously mounted:
resize2fs -p /dev/T60/fedora 1G
Next I reduced the size of the logical volume where that file system is stored:
lvreduce -L 1G /dev/T60/fedora
Now I could bring the volume back online by mounting it:
mount /var/www/fedora
Voila! A quick lvs command showed me that volume was successfully shrunk. Next I needed to take care of the other volume, increasing its size. This part I could do without taking the volume offline. First, I extended the volume itself to reclaim almost all of that newly freed space in the volume group:
lvextend -L +30G /dev/T60/home
That made the container volume about 62 GB in size (my original 32, plus 30 more) — plenty to hold the 60 GB of data I needed to move. But that wasn’t the end, because I also needed to resize the file system to use that extra space on the logical volume:
resize2fs -p /dev/T60/home
Without any parameter, resize2fs resizes the file system to fill the entire logical volume or partition, which you can do while the file system is online, and even in active use.
Copy user data. Now I wanted to forget about selective copying, and bulk copy my old /home data to the new system. I find that rsync is best for this:
cd /home
rsync -av /mnt/home/ .
Note the precise use of the trailing slash in /mnt/home/, which means the contents of that folder will be copied to my current location, not the folder plus its contents (which would give me an erroneous /home/home). Get it?
I always make sure I don’t have a user logged in anywhere when I do that last step just so I can get a clean environment when I’m done. It can take many minutes to move that much data, so I wandered off to do other things and came back later to find everything completed. I logged in and was ready to go!
By the way, to deactivate the USB-connected old laptop disk, you don’t want to just turn it off. First unmount the partitions, and then remove the old drive’s LVM volume group from play. Make sure you have no processes running that are using the old drive, using fuser or lsof to find out if you’re not sure. So I did the following:
umount /mnt/home
umount /mnt
vgchange -an vgM1330
Then I could turn off the USB carrier and unplug it.
I know this is not rocket science to many of our Fedora community experts, but hopefully this will help any new folks who wind up in the same position.
Instead of shrinking your “fedora” LV, couldn’t you simply add a PV to your VG and then expand your LV ?
That’s what I do: I never partition fully my hard-drive but instead make smaller PV. When I need more, I just add more 🙂
This is more flexible, and it also saves me some space to try installing other OSes.
This post reminded me that we’ve been telling users to change the default VG name for too long 🙂 Fresh bug number is 473364 (//bugzilla.redhat.com/show_bug.cgi?id=473364)
…which is a duplicate of 461682, which I somehow missed.
Hi Paul,
Please keep us posted about what make/model you replace the XPS M1330 with, and how it runs with Fedora. I for one am quite interested in finding a 100% Fedora-compatible laptop, and it would be great to know what the gurus at Red Hat use 🙂
ps. in your experience, how well did the XPS M1330 run with a deafult Fedora install?
Regards,
mosno.
@bocheca: The new system was also a laptop, with no more physical devices to add as a PV.
@Chris Tyler: Great, thanks for catching that as a bug, even as a dupe it’s useful. I moved that bug back to Rawhide to see if we could get it addressed for F11, because I agree that like UUIDs on file systems we should promote device portability, storage included.
@mosno: The XPS M1330 is an awesome box for Fedora. I chose the version with Intel graphics and Intel wireless and everything worked out of the box, including the webcam, in F9. There was a brief regression in the webcam for F10 but I believe it’s fixed now.