Clone existing FreeBSD Install onto a disk with Windows 10 already

I have found out that the little netbook I use for learning about FreeBSD is capable (in theory at least) of running Windows 10. I am going to upgrade the RAM (to 2GB!) and add a larger HDD and give it a go but I am happy with the way I have FreeBSD set up so I would prefer to clone my current install rather than start again from scratch. Instead of just starting and then fixing problems as they crop up (my usual method) I thought I would try to think this one through before I start.

My plan is to wipe the larger HDD then clean install Windows 10 (It will be 32 bit and installed in BIOS mode as its an old low power netbook) Then shrink the main windows partition from inside Windows and then install FreeBSD in the free space.

One idea would be to boot from the FreeBSD install USB drive then get it to set up the partition scheme, then clone my old install over the top. Does this look like a good idea or are there better approaches to take? Thank you in advance.
 
You could use an adapted sequence of what I wrote in a respective BLog post:

The only difference would be not to reformat the entire disk, but only set up the partition for FreeBSD. Depending on the actual partition scheme (GPT or MBR) there might be some obstacles. In case you are in doubt, please inform the output of gpart show (a)daX of the new disk after Windows has been installed. Here X needs to be replaced by the real device index, of course.
 
Hello I'm back!

It took a while to get an extra 1GB stick that worked in my machine and to get Win 10 installed and working.
I have now done this and was hoping to boot off the old disk (with my freeBSD setup on it) but for some reason I couldn't.

I have now booted off a live freeBSD USB stick and get the following reading about the disk with my Windows install. (I shrank the main partition by 200GB to make some free space.)

Code:
    # gpart show ada0
       63    976773105    ada MBR (466G)
       63          1985        - free - (993K)
     2048       102400    1    ntfs    [active]    (50M)
   104448    566142976    2    ntfs    (270G)
566247424    409600000        - free - (195G)
975847424       921600    3    !39        (450M
976769024         4144        - free - (2.0M)

I also got the information about the old disk (plugged in via USB adapter) and got the following:

Bash:
        # gpart show da2
       40    156301408    da2     GPT        (75G)
       40         1024      1        freebsd-boot    (512K)
     1064          984              - free -      (492K)
     2048      4194304      2        freebsd-swap    (2.0G)
  4196352    152104960      3        freebsd-zfs        (73G)
156301312          136              - free -         (60K)

I would like to do the following:

1) Create the correct partitions on the new disk ( to clone freeBSD onto)
2) Clone my old install onto the new disk
3) Get the dual boot working (I don't mind using F11 TBH)

Thanks in advance...
 
Why won't you just tell us STEP BY STEP what you have done.
Without it, the only thing I can advise is: insert you old disk back into your machine, then GO TO BIOS AND CHOOSE WHICH DISK YOU WANT TO BOOT FROM.
It will be either your Windows OR your FreeBSD disk. Then hit F10 > yes > here you are.

In particular, you wanted to know why your old disk is not bootable after the installation. One explanation that suggests itself is that its boot sector was overwritten by Windows installer. Why would it do that? It would do so in case your FreeBSD (old) disk was seen by the Windows installer as the FIRST BOOT DEVICE during the installation.
If so, to undo this, you need to reinstall FreeBSD bootcode to your old disk's freebsd-boot partition. The command is well described in all manuals.
 
Thank you for your reply.
1) I did a fresh install of freeBSD on the old internal 80GB HDD and spent some time getting it working nicely.
2) I removed the 80GB HDD and replaced it with a 500GB HDD from another laptop. I then wiped this disk and did a clean install of 32 bit Windows 10 (this is an old x86 machine) because its an old system, it installed in legacy mode meaning an MBR set up.
3) Once Windows 10 was running OK, I shrank the main partition from within windows to leave around 200GB of free space.

I expected to be able to plug the old drive in via a USB adapter and boot from it but this is not possible and in fact the laptop will not boot at all if it is plugged in, maybe it draws too much power.

Once the laptop is running, I can plug in the old HDD and it is detected although of course Windows can't read it.

I got the partition information by booting the laptop using a live USB with freeBSD on it.

My plan is to clone my freeBSD install from the old 80GB HDD drive onto the free space on the new 500GB hard drive that is currently fitted.

To do this, I need to add the correct partitions on the 500GB HDD and then clone the 80GB hard drive onto it. I was looking for advice regarding how to do this. Thanks
 
Do you mean your laptop wasn't able to boot from a USB-inserted HDD? Must be an old one, I wonder how Windows 10 got installed on it...

Dual-booting your FreeBSD alongside Windows residing on the same disk... You'll need GRUB2 to do the job. I think, that'll be the package sysutils/grub2-pcbsd.

And what is partition #3 = 450M on your new drive? Are you sure you don't need it?
And why did you partition your new 500G disk as MBR? It only supports up to 4 main partitions, you already have 3. I would strongly recommend reinstalling your Win 10, this time format the disk as GPT. That would increase your chances of success with your crazy plan :)))
 
It is a 2008 Advent 4211b netbook with a 10" screen, 2GB RAM, 32 bit processor and an old fashioned BIOS set up. I was surprised that Win 10 installed but it is all very much legacy mode only. Does that mean I can't do a dual boot using mbr? Partition 3 is a recovery partition, I guess i could do without it. This is never going to be a main computer in Windows! Yes it is a crazy plan but sometimes it is useful to have access to the Office 365 universe, even at such a glacial pace! I will be mainly using freeBSD on this machine unless I particularly need Windows for something.
 
Look! What you're planning is not considered "standard" installation. Windows is NOT expecting other OSs to reside with itself on its own disks.
So! To make it work you'll have to do a couple of other "non-standard" things, isn't that logical?
For example, you can interfere during the standard Win 10 installation to tailor the disk to your unusual setup. Very logical, since Windows DOES NOT EXPECT anything else to be installed on the same disk PERIOD. Just keep this in mind.
GPT vs MBR has nothing to do with the amount of RAM or processor architecture. In my opinion, it IS more practical, especially when one plans to install multiple OSs on one hard drive. I'm writing here because I've been playing with that for quite a while now.
...But no problem, try your luck with MBR.
 
It is a 2008 Advent 4211b netbook with a 10" screen, 2GB RAM, 32 bit processor and an old fashioned BIOS set up. I was surprised that Win 10 installed but it is all very much legacy mode only.
Old-fashioned BIOS set up? There's nothing wrong with that setup, FYI. On the contrary, it is guaranteed that GRUB2 i386-pc will work fine on it, which means you'll be able to dual-boot . Besides, with GPT there is no "active" or "non-active" partition switching -- you just boot whatever partition you want, as many as you have.

EDIT: I think, they call it "legacy BIOS", not "old-fashined" :))))). Same thing, I know
 
...
I have now booted off a live freeBSD USB stick and get the following reading about the disk with my Windows install. (I shrank the main partition by 200GB to make some free space.)

Code:
    # gpart show ada0
       63    976773105    ada MBR (466G)
       63          1985        - free - (993K)
     2048       102400    1    ntfs    [active]    (50M)
   104448    566142976    2    ntfs    (270G)
566247424    409600000        - free - (195G)
975847424       921600    3    !39        (450M
976769024         4144        - free - (2.0M)

I also got the information about the old disk (plugged in via USB adapter) and got the following:

Bash:
        # gpart show da2
       40    156301408    da2     GPT        (75G)
       40         1024      1        freebsd-boot    (512K)
     1064          984              - free -      (492K)
     2048      4194304      2        freebsd-swap    (2.0G)
  4196352    152104960      3        freebsd-zfs        (73G)
156301312          136              - free -         (60K)

I would like to do the following:

1) Create the correct partitions on the new disk ( to clone freeBSD onto)
2) Clone my old install onto the new disk
3) Get the dual boot working (I don't mind using F11 TBH)

Thanks in advance...
Do the following:
  1. Make the free space into a FreeBSD partition:
    gpart add -b 566247424 -s 409600000 -t freebsd ada0

  2. Verify that it worked using gpart show. Identify the new partition index, most probable it is 4. This is out of sequence but it is no problem. If the index is different than 4, then you would need to adapt the following commands accordingly.

  3. Create the BSD scheme into the new partition, and add the slices for UFS and SWAP
    gpart create -s BSD ada0s4
    gpart bootcode -b /boot/boot ada0s4
    gpart add -s 405405696 -t freebsd-ufs ada0s4
    gpart add -t freebsd-swap ada0s4

  4. Verify with gpart show, that everything looks good, my similar setup with Windows 7 looks like this, the indices are different, but this is irrelevant:
    Code:
    =>       63  976773105  ada0  MBR  (466G)
             63  641226719     1  ntfs  (306G)
      641226782       2066        - free -  (1.0M)
      641228848  335544320     2  freebsd  (160G)
    
    =>        0  335544320  ada0s2  BSD  (160G)
              0  327155712       1  freebsd-ufs  (156G)
      327155712    8388608       2  freebsd-swap  (4.0G)

  5. Format the UFS slice (in case this is a SSD, add the options -t and -E to newfs):
    newfs -njU -L system /dev/ada0s4a
    tunefs -a enable /dev/ada0s4a

  6. Mount the UFS volume:
    mount -o noatime /dev/ada0s4a /mnt

  7. Mount the original ZFS file system to its own mount point, let's say /zfsmnt - I don’t use ZFS and can’t tell how. Perhaps somebody else want to vote in here.

  8. Clone the data at the file system level. For this you can use net/rsync or sysutils/clone:
    using rsync(1):
    rsync -axAHX --fileflags /zfsmnt /mnt

    or using clone(1):
    clone -c rwoff /zfsmnt /mnt

  9. Add a label for the SWAP volume using glabel(8):
    glabel label swap /dev/ada0s4b

  10. Edit /etc/fstab:
    Code:
    # Device            Mountpoint  FStype     Options      Dump   Pass#
    /dev/ufs/system     /           ufs        rw,noatime   0      1
    /dev/label/swap     none        swap       sw           0      0
    proc                /proc       procfs     rw           0      0
Now the FreeBSD system should be ready. For dual booting with Windows I use the method which is described on my BLog:

Unfortunately with the later Windows 10 incarnations the batch file for setting the FreeBSD partition active does not work anymore. The command sequence must be entered into cmd.exe which has been launched with admin rights.
 
T
Old-fashioned BIOS set up? There's nothing wrong with that setup, FYI. On the contrary, it is guaranteed that GRUB2 i386-pc will work fine on it, which means you'll be able to dual-boot . Besides, with GPT there is no "active" or "non-active" partition switching -- you just boot whatever partition you want, as many as you have.

EDIT: I think, they call it "legacy BIOS", not "old-fashined" :))))). Same thing, I know
The windows installer wouldn't let me install on the new disk when it was partioned GPT for some reason so I reformatted it as MBR. I agree that GPT is usually preferable. Worst of all worlds is the hybrid partition on older Macs with Bootcamp!
 
T

The windows installer wouldn't let me install on the new disk when it was partioned GPT for some reason so I reformatted it as MBR. I agree that GPT is usually preferable. Worst of all worlds is the hybrid partition on older Macs with Bootcamp!
I know, I know, Win installer wouldn't recognize GPT partitioned disks partitioned by OTHER OSs and utilities. What I meant was to make Windows installer itself partition the disk to GPT. Isn't that possible somehow? When dealing with Windows you have to rely on what little it can do itself...
 
Here they describe how you can manually partition your disk to GPT using Windows installation media. Though I can't be sure it will then install on the resulting disk... it seems the installer links your boot mode (BIOS vs UEFI) to the type of disk being used... That's why I LOVE Windows: when it can't do something it assumes NOBODY ELSE can do that.
 
Do the following:
  1. Make the free space into a FreeBSD partition:
    gpart add -b 566247424 -s 409600000 -t freebsd ada0

  2. Verify that it worked using gpart show. Identify the new partition index, most probable it is 4. This is out of sequence but it is no problem. If the index is different than 4, then you would need to adapt the following commands accordingly.

  3. Create the BSD scheme into the new partition, and add the slices for UFS and SWAP
    gpart create -s BSD ada0s4
    gpart bootcode -b /boot/boot ada0s4
    gpart add -s 405405696 -t freebsd-ufs ada0s4
    gpart add -t freebsd-swap ada0s4

  4. Verify with gpart show, that everything looks good, my similar setup with Windows 7 looks like this, the indices are different, but this is irrelevant:
    Code:
    =>       63  976773105  ada0  MBR  (466G)
             63  641226719     1  ntfs  (306G)
      641226782       2066        - free -  (1.0M)
      641228848  335544320     2  freebsd  (160G)
    
    =>        0  335544320  ada0s2  BSD  (160G)
              0  327155712       1  freebsd-ufs  (156G)
      327155712    8388608       2  freebsd-swap  (4.0G)

  5. Format the UFS slice (in case this is a SSD, add the options -t and -E to newfs):
    newfs -njU -L system /dev/ada0s4a
    tunefs -a enable /dev/ada0s4a

  6. Mount the UFS volume:
    mount -o noatime /dev/ada0s4a /mnt

  7. Mount the original ZFS file system to its own mount point, let's say /zfsmnt - I don’t use ZFS and can’t tell how. Perhaps somebody else want to vote in here.

  8. Clone the data at the file system level. For this you can use net/rsync or sysutils/clone:
    using rsync(1):
    rsync -axAHX --fileflags /zfsmnt /mnt

    or using clone(1):
    clone -c rwoff /zfsmnt /mnt

  9. Add a label for the SWAP volume using glabel(8):
    glabel label swap /dev/ada0s4b

  10. Edit /etc/fstab:
    Code:
    # Device            Mountpoint  FStype     Options      Dump   Pass#
    /dev/ufs/system     /           ufs        rw,noatime   0      1
    /dev/label/swap     none        swap       sw           0      0
    proc                /proc       procfs     rw           0      0
Now the FreeBSD system should be ready. For dual booting with Windows I use the method which is described on my BLog:

Unfortunately with the later Windows 10 incarnations the batch file for setting the FreeBSD partition active does not work anymore. The command sequence must be entered into cmd.exe which has been launched with admin rights.
I am struggling with point 7 and getting the syntax right. The ZFS partition I want to clone from is da2s3 but I can't work out how to find it.

I tried using similar syntax to your UFS example (I have set up the new disk using UFS as my laptop only has 2GB) but get an error.

I then tried
Bash:
zfs mount -a
which apparently mounts all zfs partitions but I am not sure where they go as I can't seem to specify a /zfsmnt point as in your step by step. Up to 6 all went through nicely.
 
If I leave the ZFS partition unmounted, can I use dd to clone it onto the new UFS partition? Will this make a working system?
 
Just something to keep in mind: ZFS does need at least 4GB of RAM to function properly. Even then, you do need to mess with L2ARC variables, and even if you get ZFS to work with that little RAM, don't expect to be able to use anything graphical on your hardware. I think you'd be better off with 8GB of RAM if you want a ZFS-backed FreeBSD install.

If you want to stick with the hardware you have, nothing wrong with that, but then I'd suggest going for a UFS-backed install, and do your homework on partitioning the disk.

UFS and ZFS are very different beasts that require you to switch mental gears completely. What works on UFS - you'd have to re-think from ground up how to accomplish something similar on ZFS. Simply trying the same command on UFS and ZFS - that won't work.

Most live USB images are UFS-backed anyway.

If I leave the ZFS partition unmounted, can I use dd to clone it onto the new UFS partition? Will this make a working system?
No. If you want a working system, use the installer, and tell the installer to use UFS.

RTFM.
 
I am struggling with point 7 and getting the syntax right. The ZFS partition I want to clone from is da2s3 but I can't work out how to find it.

I tried using similar syntax to your UFS example (I have set up the new disk using UFS as my laptop only has 2GB) but get an error.

I then tried I then tried
Bash:
zfs mount -a
which apparently mounts all zfs partitions but I am not sure where they go as I can't seem to specify a /zfsmnt point as in your step by step. Up to 6 all went through nicely.
I understand, you were planning to use "mostly FreeBSD" on this netbook of yours, right? What you're asking about is the most basic case of usage, so you need to learn that. So why do you want to make short cuts (like dd copying a partition, which is, BTW, not a very good idea, unless you know what you're doing)? You can continue your doc reading along these lines:
1. How do we see all mounted stuff on FreeBSD? (there is one simple command for that)
2. How do we see all ZFS partitions datasets on our system, including their mountpoints? (there is one simple command for that)
3. How do mount a ZFS partition? (two ways of doing it, depending on the mount point type)
3. Once we have mounted a partition, can we JUST copy all files from it to some other mounted partitions (no matter what type of partition)? Yes or no.

When you're done with these, you'll come out better prepared for using FreeBSD. My point is, if one doesn't want to fiddle with THIS basic stuff, one's better off using Windows :) And I"m not joking.

EDIT: different commands to see ZFS partitions and datasets, so I"m very sorry for the confusion.
 
Following the advice on here, I have decided to do a fresh install of freeBSD on my laptop using the UFS partition scheme. I can then use the config files from the old disk and what I learned previously to set it up how I want again. It does seem that I used the wrong filesystem originally for my type of device so hopefully it will work better with UFS. I am initially trying Grub to manage the dual booting.
 
I understand, you were planning to use "mostly FreeBSD" on this netbook of yours, right? What you're asking about is the most basic case of usage, so you need to learn that. So why do you want to make short cuts (like dd copying a partition, which is, BTW, not a very good idea, unless you know what you're doing)? You can continue your doc reading along these lines:
1. How do we see all mounted stuff on FreeBSD? (there is one simple command for that)
2. How do we see all ZFS partitions datasets on our system, including their mountpoints? (there is one simple command for that)
3. How do mount a ZFS partition? (two ways of doing it, depending on the mount point type)
3. Once we have mounted a partition, can we JUST copy all files from it to some other mounted partitions (no matter what type of partition)? Yes or no.

When you're done with these, you'll come out better prepared for using FreeBSD. My point is, if one doesn't want to fiddle with THIS basic stuff, one's better off using Windows :) And I"m not joking.

EDIT: different commands to see ZFS partitions and datasets, so I"m very sorry for the confusion.
Fair point, I lack patience sometimes and look for shortcuts which undermines the whole point of me setting up a system to learn about freeBSD. I could never use Windows full time although it has its uses and frankly the fact that it just found all the drivers and installed to give a usable system on a 2008 Netbook is quite impressive.
 
I am struggling with point 7 and getting the syntax right. The ZFS partition I want to clone from is da2s3 but I can't work out how to find it.

I tried using similar syntax to your UFS example (I have set up the new disk using UFS as my laptop only has 2GB) but get an error.

I then tried
Bash:
zfs mount -a
which apparently mounts all zfs partitions but I am not sure where they go as I can't seem to specify a /zfsmnt point as in your step by step. Up to 6 all went through nicely.
Sorry for the confusion, the ZFS mountpoint /zfsmnt was meant as an example, because I did not know where and how ZFS mounts its volumes. Old versions of the FreeBSD UFS installer smeared the system’s files over 5 volumes, namely /, /root, /tmp, /usr, /var. Modern UFS installations place everything on a single volume, and I assumed that ZFS does the same. In case it uses the old scheme, then you really need to look into the mounted ZFS partitions which appeared by zfs mount -a, and then find out where /, /root, /tmp, /usr, /var are?

Once you have this, you may continue with step 8, only use the name of the mount point(s) which you figured out the hard way.
 
Sorry for the confusion, the ZFS mountpoint /zfsmnt was meant as an example, because I did not know where and how ZFS mounts its volumes. Old versions of the FreeBSD UFS installer smeared the system’s files over 5 volumes, namely /, /root, /tmp, /usr, /var. Modern UFS installations place everything on a single volume, and I assumed that ZFS does the same. In case it uses the old scheme, then you really need to look into the mounted ZFS partitions which appeared by zfs mount -a, and then find out where /, /root, /tmp, /usr, /var are?

Once you have this, you may continue with step 8, only use the name of the mount point(s) which you figured out the hard way.
I once tried to play with that, as in set up ZFS datasets to mimic UFS partitions, (the zroot/usr/ports dataset getting mounted to /usr/ports, for example). I even set minimum and maximum limits on the datasets to mimic UFS. Good for practice, but a bad idea on a production system. I very quickly discovered that it's better to with the default datasets suggested by the installer. The reason I even got away with that kind of playing - my rig (which I built in 2017) has 32 GB of RAM.

You can force a partition to use ZFS as the base filesystem - but that's not what ZFS is even meant for. It's pretty liberating to not have to think about partitions, and set limits at a later time, like whenever :p

OP's laptop only has 2 GB of RAM, which makes it unsuitable for ZFS, unfortunately. So let's respect that, and steer OP towards UFS and the defaults suggested by the installer. Instead of fighting the system and trying to take shortcuts (and getting frustrated that nothing works), RTFM, and try to follow the manual for best results. There's a reason the manual even exists, y'know.
 
OP's laptop only has 2 GB of RAM, which makes it unsuitable for ZFS, unfortunately. So let's respect that, and steer OP towards UFS and the defaults suggested by the installer. Instead of fighting the system and trying to take shortcuts (and getting frustrated that nothing works), RTFM, and try to follow the manual for best results. There's a reason the manual even exists, y'know.
Look at my instructions, and OP's confirmation (Up to 6 all went through nicely). So he successfully set up and mounted an empty UFS file system, having space for 180 GB of data. Now the missing step(s) is/are to transfer the data from wherever in the hell ZFS mounted the volumes. In case it smeared the system over to different ones, no problem, then call:

clone /thefuckingzfsmountpoint /mnt
clone -i /thefuckingzfsmountpoint/root/mnt/root
clone -i /thefuckingzfsmountpoint/var /mnt/var
clone -i /thefuckingzfsmountpoint/usr /mnt/usr

I am always astonished how people can make a simple task complicated, by drawing the focus on irrelevant considerations.
 
Look at my instructions, and OP's confirmation (Up to 6 all went through nicely). So he successfully set up and mounted an empty UFS file system, having space for 180 GB of data. Now the missing step(s) is/are to transfer the data from wherever in the hell ZFS mounted the volumes. In case it smeared the system over to different ones, no problem, then call:

clone /thefuckingzfsmountpoint /mnt
clone -i /thefuckingzfsmountpoint/root/mnt/root
clone -i /thefuckingzfsmountpoint/var /mnt/var
clone -i /thefuckingzfsmountpoint/usr /mnt/usr

I am always astonished how people can make a simple task complicated, by drawing the focus on irrelevant considerations.
It's only simple if you actually RTFM'ed. It's obvious OP didn't do that. And even if you did, you're supposed to Keep It Simple, Stupid.

I'm always astonished at how people pull off twisted setups that are not in the manuals, and then call it 'simple'. It's not one or the other, but the combination of both that leaves me astonished. Dunno if the underlined, two-part sentence is too long and complicated for you to to understand.
 
I think the situation I got into was non-standard and obsigna tried to help me out of it. I had installed FreeBSD on an old netbook mainly just to try it out and compare with other operating systems that I have used. When I had it running nicely, it occurred to me to see if I could get Windows 10 to run on it too but decided it would be simpler to clone my working FreeBSD installation back onto the disk with Windows. I have dual and even triple booted before and even cloned but not with FreeBSD and it proved challenging to UTFM in my situation. Once I got the disk partitioned, I have done a fresh install and will apply the settings and install the software I had before and use the old disk for something else! Thanks for all your help with this!
 
My refurbished T430s came with win10pro on its 120G SSD, fortunately as MBR, taking 2 slices for W10.

I brought W10 up to date online then used its surprisingly good tools to shrink "C:" to 38G, then add a 32G FAT32 slice "D:" for sharing common data.

That left 48G slice 4 unused, which the FreeBSD installer happily chose to work with. Old-school, I prefer separate /, /var, /usr, /home partitions.

From the liveCD or after first booting into FreeBSD I ran
Code:
# boot0cfg -Bv -s 4 ada0

Without -B, you can run boot0cfg(8) anytime to update its settings.

Done. Unless adding Linux there's no need for Grub, and W10 is completely oblivious of the updated MBR.

I now have boot0cfg offer:
F1 Win
F4 FreeBSD
with -m 9 -t 72, booting the last used after 4 seconds unless selected sooner.
 
Back
Top