FreeBSD on usb stick (Live USB)

I'd like to have FreeBSD even while travelling so I'm trying to install FreeBSD on usb stick.
I tried to boot from CD and install from FTP on usb stick. This works but with 2 issues:
1. Despite I have a line in /etc/fstab:
Code:
/dev/da0s1a     /     ufs    rw    1    1
root cannot be found on boot and I have to mount it manually in loader prompt. Then everything goes well.
2. /tmp and /var are on the stick so lots of writing occurs that is not good for this kind of media.

I also tried this but there is a mess with fstab in that "howto": it drops me to single user mode and asks to correct fstab that is indeed unusual:
Code:
# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/ufs/FreeBSDonUSB   /               ufs     rw,noatime      1       1
md                      /tmp            mfs     rw,-s16M,nosuid,noatime 0       0
md                      /var/run        mfs     rw,-s4M,nosuid,noatime  0       0
md                      /var/log        mfs     rw,-s16M,nosuid,noatime 0       0
/dev/acd0               /cdrom          cd9660  ro,noauto,nosuid        0       0
/proc                   /proc           procfs  rw,noauto       0       0
/tmp                    /var/tmp        nullfs  rw              0       0

I prefer first option but I suspect that something wrong with that (looking normal) fstab too because trying to boot my another machine I'm getting something like: "no boot" "no ufs".

Did somebody successfully installed FreeBSD on usb-stick with swap, /tmp and /var on local HDD or in memory?
 
...gosh, what could be wrong?
I just rebuilt world and kernel from 8-b2 t0 8-rc1. Cannot mount root at all and da0 is not in the list of valid devices:OO
before I at least could mount as ufs:/dev/da0s1a, not now.
 
You meant kernel+world or usb install?
I followed the install by character, but... yes, mistakes happen :)
Mergemaster? I checked, main configs are correct.
Do you have exactly the same fstab as I posted?
One more strange thing: the flash appears as twice mounted if inserted into working system. I need to check what's bootable on the stick...otherwise I have to repeat:)
 
This is my fstab:

Code:
/dev/ufs/FreeBSD	/               ufs     rw,noatime      1       1
md                      /tmp            mfs     rw,-s16M,nosuid,noatime 0       0
md                      /var/run        mfs     rw,-s4M,nosuid,noatime  0       0
md                      /var/log        mfs     rw,-s16M,nosuid,noatime 0       0
/dev/acd0               /cdrom          cd9660  ro,noauto,nosuid        0       0
/proc                   /proc           procfs  rw,noauto       0       0
/tmp                    /var/tmp        nullfs  rw              0       0
 
Looks the same. What partitions do you have on the stick?
I chose "entire disk" but I have unused before (understandable) and after.
The after unused space looks as marked A and I cannot remove it.
The stick in mounted as 2 partitions.
I'd rather not to reinstall everything 'cause I have only beta2 CD to mount. How to move A from unused to da0s1a?
 
I have two partitions (slices). One FAT32 slice for generic data, and one BSD slice for my FreeBSD system. I have boot0 installed in the MBR (just in case).

fdisk(8) will allow you to set the active partition.
 
I reinstalled everything. Anyway I have to do the following at mountroot> prompt that appears every time.
Code:
mountroot> ufs:/dev/da0s1a
But at least fstab is mounted now.
The only thing I changed in the howto is my volume label: I called it FBSDUSB instead of FreeBSDonUSB.
I have in /boot/loader.conf:
Code:
geom_label_load="YES"
and dmesg shows:
Code:
user@: /usr/obj/usr/usr/src/sys/GENERIC
module_register: module g_label already exists!
Module g_lable failed to register: 17
........................................
Trying to mount root from ufs:/dev/ufs/FBSDUSB
BOOT MOUNT ERROR:
If you have invalid mount options, reboot, and first try the following from the loader prompt:
set vfs.root.mountfrom.options=rw
and then remove invalid mount options from /etc/fstab
there is nothing in my us/obj. What I'm doing wrong?
 
I read man but anyway I'm not fdisk expert. For me it's strange to see this stick always appeared as 2 identical entries: one entry is mountable another is not (file or directory doesn't exist)
Below is fdisk output identical for /dev/da0 and /dev/ufs/FBSDUSB and /dev/da0s1a:
Code:
# fdisk /dev/da0
******* Working on device /dev/da0 *******
parameters extracted from in-core disklabel are:
cylinders=487 heads=255 sectors/track=63 (16065 blks/cyl)

parameters to be used for BIOS calculations are:
cylinders=487 heads=255 sectors/track=63 (16065 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 63, size 7823592 (3820 Meg), flag 80 (active)
        beg: cyl 0/ head 1/ sector 1;
        end: cyl 486/ head 254/ sector 63
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>
#
However if use /dev/da0s1 the output is:
Code:
# fdisk /dev/da0s1
******* Working on device /dev/da0s1 *******
parameters extracted from in-core disklabel are:
cylinders=486 heads=255 sectors/track=63 (16065 blks/cyl)

parameters to be used for BIOS calculations are:
cylinders=486 heads=255 sectors/track=63 (16065 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
<UNUSED>
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 0, size 50000 (24 Meg), flag 80 (active)
        beg: cyl 0/ head 0/ sector 1;
        end: cyl 1023/ head 254/ sector 63
#
This is beyond my comprehension: why 4 partitions? Why upside down and wrong size? Finally and most important: can I delete 3 unused partitions and have then only 1 or 2 instead (1 or 2 offset partitions)? I also don't understand why those 3 unused partitions have no any size?
Before reinstalling I whipped out everthing and I had only 1 partition. I'd rather not to loose the installation: it works though I have to manually mount root on every boot. Is it possible to correct partition table without loosing all the data?
 
You are misunderstanding how a PC BIOS MBR works. There is no MBR in the first sector of a partition, so don't try run it on da0s1.

Not sure what you've done wrong. Looks like your fstab is broken. Is there a /dev/ufs/FBSDUSB? Can you mount it as such at the mountroot prompt? If so, check your fstab file for errors.
 
Thanks. Indeed in depth I don't understand BIOS and disk geometry and only I know is that MBR usually resides on first 64 sectors of HDD. That what I have with this flash:

Code:
Offset   Size(ST)    End    Name   PType    Desc  Subtype   Flags

  0        63         62     -      12      unused     0
 63     7823592    7823654  da0s1    8      freebsd  165     A
7823655   11993    7835647   -      12      unused     0
I understand that first 63 sectors are reserved for MBR. But whatever I tried the last UNUSED partition (or space) stays firm there having the same 11993 (big enough?) number of sectors as unused. Do you know what is that unused space for? Could be those just "bad sectors"? If yes why this flash is always mounted as 2 same name entries? Does this unused space matter?
Also this could be important:
Code:
bios_geom=487/255/63 = 7823655
So the "fake" partition (unused space) is located beyond legal bios space? Does this flash has invalid partition table that I cannot wipe away?

As to fstab I provided it in this thread and as you can see it's exactly the same as yours except label name that cannot be a reason of my troubles, is it?
I CANNOT mount the device at mountroot prompt as FBSDUSB, only as /dev/da0s1a. When it was just fat32 formated flash I mounted it under FreeBSD as /dev/da0s1 that's why I tried it again.
 
I'm not sure why sysinstall's partition tool is reporting that weird amount of unused space at the end. Usually it should be one cylinder's worth of unused space, but I'm not sure that old rule has to be followed any more, and it shouldn't appear to go past the end of the disk. It is not bad sectors that's for sure. You can ignore it I think as fdisk's idea of your partition table looks fine to me.

I CANNOT mount the device at mountroot prompt as FBSDUSB, only as /dev/da0s1a.
Then there is a problem with the file system's label or with glabel. Add this to loader.conf:

Code:
kern.geom.label.debug=1

And paste your subsequent boot dmesg.
 
Sorry for the delay.
I reinstalled everything again with the same result:(
Debug output:
Code:
mountroot> GEOM_LABEL [1]:MSDOSFS:da0: FAT12/16 volume not valid
GEOM_LABEL [1]:MSDOSFS:da0s1: FAT32 volume not valid
GEOM_LABEL [1]:UFS2 file system detected on da0s1a
GEOM_LABEL [1]:Lable for provider da0s1a is ufsid/4ac4ac0c82f9c462
GEOM_LABEL [1]:UFS2 file system detected on da0s1a
GEOM_LABEL [1]:Label for provider da0s1a is ufs/FBSDUSB
GEOM_LABEL [1]:MSDOSFS:da0s1a: no FAT signature found
My only choice was to type again as always : ufs:/dev/da0s1a and it boots with this:
Code:
GEOM_LABEL [1]:Label ufs/FBSDUSB removed
GEOM_LABEL [1]:Label ufsid/4ac4ac0c82f9c462  removed
Looks normal but...why 2 labels? Is that why the stick is mounted always as 2 partitions?

Next. I tried the stick on my another machine. Result:
Code:
Not ufs
Not ufs
No /boot/loader

FreeBSD/i386 boot
Default: 0:fd(0,a)boot/kernel/kernel
boot:
Not ufs
No /boot/kernel/kernel

FreeBSD/i386 boot
Default: 0:fd(0,a)boot/kernel/kernel
boot: 0:da(0,a)boot/kernel/kernel ## I typed this.
WARNING: loader(8) metadata is missing!
Then everything went normal up to mountroot> and then I COULD NOT mount with ufs:/dev/da0s1a (and anything else I tried). There is no da0 in the list of valid boot devices. So I had to abort. BTW there was no any debug output on this machine.

Notes about the HowTo:
This doesn't work for me:
Code:
# DESTDIR=/mnt ./install.sh
DESTDIR=: command not found
but this works:
Code:
# setenv DESTDIR /mnt
# ./install.sh
This doesn't work and no clue what enter instead:
Code:
# chroot /mnt /bin/sh
# mount_devfs devfs /dev
mount_devfs: command not found
Missing /mnt in first line:
Code:
# cat >> /etc/rc.conf << EOF
ifcofig_DEFAULT="DHCP"
must be:
# cat >> /mnt/etc/rc.conf << EOF

I also tried to install kde3.5.10 on the stick as suggested in the HowTo. + xorg-minimal. Result: tons of errors, missing libraries, even xorg won't start nothing to dream about kde. Perhaps /tmp is too small for such operations since I saw "cannot write to /tmp...filesystem is full" many times.
 
zeiz said:
Sorry for the delay.
I reinstalled everything again with the same result:(
Debug output:
My only choice was to type again as always : ufs:/dev/da0s1a and it boots with this:
Code:
GEOM_LABEL [1]:Label ufs/FBSDUSB removed
GEOM_LABEL [1]:Label ufsid/4ac4ac0c82f9c462  removed
No idea. All I can say is that it works perfectly here.

zeiz said:
Next. I tried the stick on my another machine. Result:
Code:
Not ufs
Not ufs
No /boot/loader

FreeBSD/i386 boot
Default: 0:fd(0,a)boot/kernel/kernel
boot:
Not ufs
No /boot/kernel/kernel

FreeBSD/i386 boot
Default: 0:fd(0,a)boot/kernel/kernel
boot: 0:da(0,a)boot/kernel/kernel ## I typed this.
WARNING: loader(8) metadata is missing!
Then everything went normal up to mountroot> and then I COULD NOT mount with ufs:/dev/da0s1a (and anything else I tried). There is no da0 in the list of valid boot devices. So I had to abort. BTW there was no any debug output on this machine.
The problem here is the BIOS. It is making the USB disk look like a floppy disk. Look around for the BIOS setting that makes USB boot devices look like hard drives.


zeiz said:
Notes about the HowTo:
This doesn't work for me:
Code:
# DESTDIR=/mnt ./install.sh
DESTDIR=: command not found
Yup, the howto uses a bourne type shell. You are using csh it seems.

zeiz said:
This doesn't work and no clue what enter instead:
Code:
# chroot /mnt /bin/sh
# mount_devfs devfs /dev
mount_devfs: command not found
Out of date information. Rather:
Code:
mount -t devfs devfs /dev
 
Finally: I cannot boot the stick on another machine and this makes me to give up at this time...
Anyway thank you very much!:)
 
Could it be the thing I always had to puzzle about with linux where the PC bios calls the partition from a different name. I've had many a struggle figuring out how to boot from external drive or flash changing grub/fstab. Sorry I can just tell you.
 
known bug? Making me better at freeBSD for sure. Running from 1 gig flash stick. Typing it what's advised at:

mountpoint>

works sometimes.
It may be (as said in first link and elsewhere) that typing ufs:/dev/da0 FIVE TIMES (failing each time of course)
THEN doing full string: ufs:/dev/da0s1a (or whatever your usb device is) - will work

I will try 5-times work-around now.


Here's links i found by searching google for:
"freebsd usb external boot drive ufs:/dev/da0s1a"

http://www.freebsd.org/cgi/query-pr.cgi?pr=138798
http://lists.freebsd.org/pipermail/freebsd-current/2009-April/006042.html
http://old.nabble.com/Re:-Can't-boot-Marvel-Sheevaplug-from-USB-td25977274.html
 
Back
Top