FreeBSD on usb stick (Live USB)

Installing and upgrading FreeBSD.

FreeBSD on usb stick (Live USB)

Postby zeiz » 25 Sep 2009, 15:25

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: Select all
/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: Select all
# 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?
User avatar
zeiz
Member
 
Posts: 691
Joined: 19 Nov 2008, 18:36
Location: Canada

Postby aragon » 25 Sep 2009, 19:36

Working fine here. No swap, filesystems as suggested by the howto you linked to...
aragon
Giant Locked
 
Posts: 2031
Joined: 16 Nov 2008, 17:04
Location: Cape Town, South Africa

Postby zeiz » 25 Sep 2009, 21:14

...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.
User avatar
zeiz
Member
 
Posts: 691
Joined: 19 Nov 2008, 18:36
Location: Canada

Postby aragon » 25 Sep 2009, 21:28

Perhaps you're not building correctly?

I recommend using a release installation to set it up.
aragon
Giant Locked
 
Posts: 2031
Joined: 16 Nov 2008, 17:04
Location: Cape Town, South Africa

Postby zeiz » 25 Sep 2009, 22:34

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:)
User avatar
zeiz
Member
 
Posts: 691
Joined: 19 Nov 2008, 18:36
Location: Canada

Postby aragon » 26 Sep 2009, 01:34

This is my fstab:

Code: Select all
/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
aragon
Giant Locked
 
Posts: 2031
Joined: 16 Nov 2008, 17:04
Location: Cape Town, South Africa

Postby zeiz » 27 Sep 2009, 00:34

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?
User avatar
zeiz
Member
 
Posts: 691
Joined: 19 Nov 2008, 18:36
Location: Canada

Postby aragon » 27 Sep 2009, 01:50

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).

[man=8]fdisk[/man] will allow you to set the active partition.
aragon
Giant Locked
 
Posts: 2031
Joined: 16 Nov 2008, 17:04
Location: Cape Town, South Africa

Postby zeiz » 27 Sep 2009, 12:58

I reinstalled everything. Anyway I have to do the following at mountroot> prompt that appears every time.
Code: Select all
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: Select all
geom_label_load="YES"
and dmesg shows:
Code: Select all
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?
User avatar
zeiz
Member
 
Posts: 691
Joined: 19 Nov 2008, 18:36
Location: Canada

Postby zeiz » 27 Sep 2009, 17:08

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: Select all
# 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: Select all
# 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?
User avatar
zeiz
Member
 
Posts: 691
Joined: 19 Nov 2008, 18:36
Location: Canada

Postby aragon » 27 Sep 2009, 23:17

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.
aragon
Giant Locked
 
Posts: 2031
Joined: 16 Nov 2008, 17:04
Location: Cape Town, South Africa

Postby zeiz » 29 Sep 2009, 14:28

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: Select all
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: Select all
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.
User avatar
zeiz
Member
 
Posts: 691
Joined: 19 Nov 2008, 18:36
Location: Canada

Postby aragon » 29 Sep 2009, 16:27

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: Select all
kern.geom.label.debug=1


And paste your subsequent boot dmesg.
aragon
Giant Locked
 
Posts: 2031
Joined: 16 Nov 2008, 17:04
Location: Cape Town, South Africa

Postby zeiz » 01 Oct 2009, 17:15

Sorry for the delay.
I reinstalled everything again with the same result:(
Debug output:
Code: Select all
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: Select all
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: Select all
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: Select all
# DESTDIR=/mnt ./install.sh
DESTDIR=: command not found

but this works:
Code: Select all
# setenv DESTDIR /mnt
# ./install.sh

This doesn't work and no clue what enter instead:
Code: Select all
# chroot /mnt /bin/sh
# mount_devfs devfs /dev
mount_devfs: command not found

Missing /mnt in first line:
Code: Select all
# 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.
User avatar
zeiz
Member
 
Posts: 691
Joined: 19 Nov 2008, 18:36
Location: Canada

Postby aragon » 02 Oct 2009, 01:00

zeiz wrote: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: Select all
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 wrote:Next. I tried the stick on my another machine. Result:
Code: Select all
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 wrote:Notes about the HowTo:
This doesn't work for me:
Code: Select all
# DESTDIR=/mnt ./install.sh
DESTDIR=: command not found


Yup, the howto uses a bourne type shell. You are using csh it seems.

zeiz wrote:This doesn't work and no clue what enter instead:
Code: Select all
# chroot /mnt /bin/sh
# mount_devfs devfs /dev
mount_devfs: command not found


Out of date information. Rather:
Code: Select all
mount -t devfs devfs /dev
aragon
Giant Locked
 
Posts: 2031
Joined: 16 Nov 2008, 17:04
Location: Cape Town, South Africa

Postby zeiz » 02 Oct 2009, 20:40

Finally: I cannot boot the stick on another machine and this makes me to give up at this time...
Anyway thank you very much!:)
User avatar
zeiz
Member
 
Posts: 691
Joined: 19 Nov 2008, 18:36
Location: Canada

Postby aragon » 04 Oct 2009, 21:29

I recently spotted this:

http://lists.freebsd.org/pipermail/freebsd-current/2009-October/012361.html

That might address the problem you're having.
aragon
Giant Locked
 
Posts: 2031
Joined: 16 Nov 2008, 17:04
Location: Cape Town, South Africa

Postby yvonney » 19 Dec 2009, 20:25

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.
yvonney
Junior Member
 
Posts: 13
Joined: 03 Jun 2009, 00:10

Postby yvonney » 08 Jan 2010, 07:14

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%27t-boot-Marvel-Sheevaplug-from-USB-td25977274.html
yvonney
Junior Member
 
Posts: 13
Joined: 03 Jun 2009, 00:10

Postby fbsd1 » 01 Mar 2010, 10:49

FreeBSD Install Guide www.a1poweruser.com
fbsd1
Member
 
Posts: 213
Joined: 26 Feb 2010, 09:43
Location: Angeles City, Philippines


Return to Installing & Upgrading

Who is online

Users browsing this forum: Google [Bot] and 1 guest