Solved Creating a bootable image file from bootable usb?

I've installed FreeBSD with KDE and some basic apps using the UFS. I labeled the flash drive "FreeBSD-KDE" with glabel. I set up fstab to point to the correct directory /dev/label/FreeBSD-KDE. Now I am wanting to back this up in the form of a persistent storage img file so i wont have to go through the entire lengthy installation process to get everything how I like it every time I want a fresh install of this setup.

Is there any way to do this? I dont really care about having it installed anywhere but to flash drives so I can take it wherever i go and not leave a bunch of crap behind on various computers. I wanted the img file to keep the label created by glabel so that when I write the image to a new flash drive it will be able to boot with the same directory predefined by fstab and just work out of the box after everything is all said and done. If there is any way to make this happen, what would I use?

I've tried the dd command several times now to make a duplicate of my working flash drive and while it boots up with the FreeBSD logo just fine, after that it can't seem to mount the drive, no label kept, but I can for example enter ufs:/dev/da0 rw and even though that is verified to be the correct location it errors every time.

I also tried re-adding the label with glabel and doing ufs:/dev/label/FreeBSD-KDE rw and no dice.

Thanks in advance for any help or suggestions!
 
  1. Yes, this is possible, and already done e.g. Wikipedia: List of FreeBSD Products: NomadBSD
    You may want to read through their ChangeLog, e.g. they changed from GPT to MBR
  2. Read through RTFM boot(8) and the examples in gpart(8)
    AFAIR the FreeBSD USB stick image can boot under EFI and legacy BIOS (MBR)
  3. IMHO you do not need a glabel, maybe simply label with a partition label ( gpart -l mylabel) and a UFS label ( tunefs -L mylabel) and in /etc/fstab use "/dev/ufs/mylabel"
  4. The key is the right bootcode (gpart(8))
  5. loader.conf(5): you may want to adjust vfs.root.mountfrom in /boot/loader.conf and let the root free in /etc/fstab
  6. I would suggest to install sysutils/devcpu-data, integrate into loader.conf[.vendor], and sysutils/cpupdate, integrate into rc.conf[.local] to be shure to catch buggy CPUs
    2nd suggestion: set efi_max_resolution="720p" in loader.conf[.vendor], else the boot menu can get really small on modern high resolution displays.
    3rd: for UFS I'd like to promote to insert an I/O scheduler (gsched(8)). You can grab a /etc/rc.d service script to start that here.
  7. I did this once and had the same issues like you. gpart bootcode and "vfs.root.mountfrom=ufs:/dev/ufs/mysystem" will solve it.
 
Thank you so much for the in depth response! I will try this and will mark this topic as solved if I figure it out and all goes well.
 
I mixed the vendor thingy. You can have a /etc/rc.vendor but no /boot/loader.conf.vendor.
Another thought: you could leave the installation partition (take from FreeBSD or NomadBSD) as is, or only minimal changes, and add a 2nd UFS partition with all your packages and pre-configuration. Nowadays a 64GB USB thumb drive costs ~20 $/€/£, so you have much space to fill with your favourites.
 
Thank you! So many options! And I absolutely love how well this stuff is documented, it makes things so much easier. I develop for macOS and they have hundreds of pages for functions that are completely undocumented where people find out how to use the features simply by guesswork, same with Darwin. I am so glad the open source community actually takes the time to make their tech learnable for new users, it's very refreshing considering they are doing this as an unpaid service and then look at Apple who makes billions and doesn't give back to their developers hardly at all, they mostly take away.

Anyway I'm going to research this more, and the links you gave are a huge help, I wanted my img file to be distributable so that other people may use it as well if they wanted to, like a semi-distro but not completely. Marking as solved for now, but if I have more questions I'll ask them here.

Edit: don't mean to bash apple at all, that was just an observation I made. I do like the quality of their products dont get me wrong.
 
To mark the thread solved, click on the "..." of the 1st posting, ->Edit thread->prefix: Solved.
Yeah with Apple that's double-faced. E.g. AFAIK they give great support to LLVM, maybe some other Open Source projects, too - on the other hand they set up a closed universe, grab user profiles and hide or make information hard to find itentionally.
 
Anyway I'm going to research this more, and the links you gave are a huge help, I wanted my img file to be distributable so that other people may use it as well if they wanted to, like a semi-distro but not completely. Marking as solved for now, but if I have more questions I'll ask them here.

Can you now install the FreeBSD desktop system on a USB stick ? What would be the requirements that the USB memory stick should have for this purpose and not be slow or fail in its attempt?
 
Can you now install the FreeBSD desktop system on a USB stick ? What would be the requirements that the USB memory stick should have for this purpose and not be slow or fail in its attempt?

Well, I have FreeBSD installed with the KDE desktop environment on 32GB sandisk ultra. It works great. However if you need to install more stuff on there than I have, you will need more storage. What I have right now is pretty bare bones KDE. It has Falkon, Kdenlive, and Krita installed on top of the base KDE apps, I also installed a wifi manager, but nothing else.
 
Well, I have FreeBSD installed with the KDE desktop environment on 32GB sandisk ultra. It works great. However if you need to install more stuff on there than I have, you will need more storage. What I have right now is pretty bare bones KDE. It has Falkon, Kdenlive, and Krita installed on top of the base KDE apps, I also installed a wifi manager, but nothing else.
Interesting, you have managed to install the FreeBSD system with desktop on a USB stick, I would like to know how to do it, which guide I use, because it is very complicated due to the system booteable and the disk partition in the same USB stick.
 
Interesting, you have managed to install the FreeBSD system with desktop on a USB stick, I would like to know how to do it, which guide I use, because it is very complicated due to the system booteable and the disk partition in the same USB stick.
What is complicated about it? You need two usb memory sticks; one with the FreeBSD installer, another to install on (and it has to have enough space for the installed system and to grow). The rest is exactly the same as a normal install. It can be smart to use labels instead of partition names if you want the installed usb stick to be portable between machines.
 
What is complicated about it? You need two usb memory sticks; one with the FreeBSD installer, another to install on (and it has to have enough space for the installed system and to grow).
You do not need two sticks. Instead you can do that w/ two partitions on one large USB thumb drive. As I mentioned above, 32 or 64GB on USB 3.1 are relatively cheap nowadays for people in the so-called 1st world.
The rest is exactly the same as a normal install. It can be smart to use labels instead of partition names if you want the installed usb stick to be portable between machines.
To use filesystem labels ( tunefs -L) for the FS and partition labels ( gpart modify -l) for e.g. swap and efi-boot has the advantage that more information is in the device name, e.g. /dev/ufs/KommunityBSD (c) (FreeBSD Community Edition (KDE)), /dev/msdosfs/EFISYS (you see the FS type) and /dev/gpt/gptboot0 (you see it's GPT, thus it's most likely on permanent storage). With glabel(8) labels, you don't have that information just by looking at the device name. GPT partition labels are portable, too. The use of glabel(8) labels is justified for additional information, e.g. you jingle around with different versions or drives of different machines or multiple architectures, then it's clever to encode the version, machine's hostname, or architecture in the label.
 
You do not need two sticks. Instead you can do that w/ two partitions on one large USB thumb drive. As I mentioned above, 32 or 64GB on USB 3.1 are relatively cheap nowadays for people in the so-called 1st world.
I know. ;) I was just trying to make it extremely uncomplicated to the poster.
 
Back
Top