Solved Move partitions to new hard drive

My existing FreeBSD system is great. It needs to be moved to another hard drive. Both file systems are conventional /, swap, /var, /tmp, /usr. Both file systems are of the the type ufs in a freebsd partition under mbr. I use mobile computing exclusively. To do this physically the new drive is in the laptop and the existing drive is cabled into a usb port. The new drive has the partitions ada0s3 parent, ada0s3a /, ~ ada0s3f /usr. The cabled in hard drive (file system to be replicated) has the partitions /dev/da0s1 parent, /dev/da0s1a /, ~ /dev/da0s1f /usr.
What exactly is the correct thing to do using dump and restore? I can't quite put together the correct mount points and what the final execution line would read like.
 
Greetings, rhsbsd.
The best solution; well the one I use. ;)
is to drop to single user mode, before performing a dump / restore.
First off, you'll need to insure the "target" drive is all partitioned correctly, and recognized. If you're satisfied that's the case. You'll need to create a level 0 dump(8). It would probably be easiest to dump the filesystems to a flash drive. But you might also consider dumping things to /tmp on your current drive. Which you can then mount(8) later, and use as the source for restore(8).
Booting to your current drive in single-user mode; you'll need to perform a level 0 dump(8) of all your slices. I'd start by doing / first (I'll explain later). So once at the prompt; mount(8) / first;
Code:
mount -u /
mount -a -t ufs
As suggested earlier, save your dump(8)s in /tmp. So mount each slice, dump it. Traditionally, and on most of my systems, I have the following layout (modify/adapt to your own layout)

/
/var
/usr

We'll start with /, and save it to /var/empty, because we don't want a copy of our dump:
Code:
dump -C32 -b64 -0uanL -f /var/empty/root.dump /
When that's completed, you'll want to move it to /tmp
Code:
mv /var/empty/root.dump /tmp/
Now perform the same for the rest of your slices:
Code:
dump -C32 -b64 -0uanL /tmp/var.dump /var
dump -C32 -b64 -0unaL /tmp/usr.dump /usr
Now you have fresh level 0 dumps of all your file systems, located in /tmp.
We could have performed a dump(8), followed by a restore(8) all in one go. But for simplicity, and better understanding. I'm listing the operations individually. :)
Now you'll need to mount your new filesystems individually. The easiest way, would be to simply mount them in tmp:
...
Wait a minute, I forgot, wblock@ has already outlined all this. Have a look at all his fine work on this subject: http://www.wonkity.com/~wblock/docs/html/backup.html

--Chris
 
You know I think that I read that article once but had forgotten about it. Thanks for the reply. I got my answer.:D
 
Just would like to share my experience with moving my FreeBSD r10.1 p6 system over to another hard drive. Thanks to FreeBSD Manual 8.2, Warren Block (Backup Options for FreeBSD), and my previous poster Chris_H.
This all started after "Windows update" crashed out my Windows 7 boot. Just google it. Hundreds of them, all with the same sob story. So I was faced with rebuilding my Windows 7 drive. I use Windows 7, only, for my Garmin device, programing PLC's, commissioning drives, and Adobe Professional, and a ScanMaker 4900 scanner not supported by FreeBSD. I actually thought my hard drive failed because after I re-installed Windows for the "SECOND" time it crashed out at boot time again, after attempting to eat yet another update, and this happened, after being fully updated again, or so I thought. I purchased another 1T hard drive because it just had to be a hard disk failure right? Wrong! When the new hard drive crashed out on me again after windows updates did whatever, I put my BSD drive back in and started googling. I was really shocked by what I found which is, 1) there is no resolution to this problem yet 2) some updates fail because users are using there computers to boot other operating systems. Imagine that. 3) at the time my problems started I was using that drive in single boot mode only, and had never dual booted with it. 4) I have turned windows update off until such time I get contacted from planet X by a MS professional telling me to go ahead and turn them on again. Ha! Good luck with that. 5) Now in there ever increasing paranoia MS have decided to not offer images of operating systems to users so that they can perform clean installs. If you want to do that you now have to buy an operating system from Micro Soft on top of the one loaded with bloat ware that you get when you purchase a new computer. Check it out. Its really true. I cant believe it. Are they not wallowing in enough cash yet? >>>>>> Good things are about to happen.
Put new hard drive inside laptop. Nuke'n boot new hard drive. I reinstalled Windows 7 for the 4th time and did only one round of updates. Turn off windows updates. I used the Lenovo "Restore DVD's" as it gets all the drivers installed correctly. Lenovo along with Windows use x4 partitions to get x1 operating system up and running. Windows 7 has a boot managed MBR partition on this machine and the bios does not support UEFI and windows can not use GPT without a UEFI bios. You need both for Windows 7. Lah-t-dah! I partitioned the drive before the Windows install but Windows took the whole drive anyways even after it appeared as if the installer pointed it to the 1st partition. Need I say more about 2nd party vendor software? DONE WITH WINDOWS. Delete the third (extended) partition. Shrink the second partition. Delete any formatting and file systems on the unused partition. Leave as unused space. I'm not good enough to fdisk this unused space so I just use my FreeBSD 10.1 image and do an install and manually create my FreeBSD slice ada0s3 which the FreeBSD installer is intelligent enough to sniff out and use the unused space located between two existing partitions. Perfectly I might add. How nice is that? Create the other partitions and complete the install. Reboot back into single user mode (SUM) and using boot easy put the boot code on the windows boot partition. Now to move partitions from existing (been working on this one since Nov, 2014) FreeBSD 10.1 system drive to newly created partitions on new hard drive.
Physical arrangement as follows: new drive cabled into machine and original drive inside machine. Boot into SUM and
Code:
# mount -u /
# mount -at ufs
# cd /dev
Take note of your partition arrangement. Mount them, check them, and make sure you know what's what. In my case the FreeBSD slice is /dev/da0s3. That's the case here because the two slices ahead of this one are for Windows. If you have done previouse backups using dump on your original file system then go ahead and delete the time stamps of the dumps in /etc/dumpdates. This insures that you will get ALL the data and also you will avoid FreeBSD complaining about symmetrical links it can't find. This is because I'm using a live file system and not dumping from a restore which would have the symlinks in the root path, I believe. This is the way I had to dump my /usr partition, exactly:
Code:
# umount /mnt
# cd /
# mount /dev/da0s3f /mnt
# dump -c16 -b64 -0uanL -h0 -f - /dev/ufs/hmusrfs | (cd /mnt && restore -ruf -)
Repeat the umount /mnt as many times as needed to make sure nothing is mounted. That last line looks a bit strange. The partitions on my original drive are labeled. The partitions all that data is going into are not. I will explain in a minute. I tried using /dev/ada0s1f but I got an error. Can't exactly remember what the number was. Just remember I am dumping a live file system from labeled partitions to an unlabeled file system on new drive. Go ahead and finish the dumps /var, /tmp, /. 1hr 24 mins for me. Not bad really. I think its definitely faster than an image. Swap out drives, reboot, and epic fail (no boot device found). That's because etc/fstab is now the fstab from the original drive (the one with the labeled partitions). Open CD bay, insert FreeBSD 10.1 image and boot into SUM and mount your root partition:
Code:
# mount /dev/ada0s3a /mnt
Edit /etc/fstab. I commented out the labeled file system lines and entered new file system layout, which of course reflects this installation. Then reboot into a carbon copy of what you have been using (exactly) save for the file system which is 10 minutes tops. That's the only adjustment (so far) that's required, and I'm sure that there is a better way.
I now have an extra 1T, and 750GB spare SATA drives. I'll use the 1T to image my existing dual boot 1T and put the 750GB into full experimental mode. There is good in almost everything. Thanks again to everyone that helped.
 
Back
Top