Bootable usb-stick, need help, sos

I would probably set all my rubber points here to get some real help for creating a boot device on a usb-stick. There is no CD-drive on this machine, thats why I need to use a usb-stick. And scrumming in a CD-drive to fuddle around in the fstab or something like that is out of reach.
My wisdom so far told me to type the following code to shovel the iso to the usb-stick, but under bsd it does not.

dd if=/your/path/to/distro.iso of=/dev/sdX bs=16k

the bsd root terminal tells me

dd: /dev/sdx: Operation not supported

no matter if upper or lower case the x, no other explanation naming the device sdc1, sdb1.
Another commandline like

cp /path/to/distro.iso /dev/sdc1 

gives me no result either. The usb-stick is formatted, but even typing in the root terminal

mkfs.ext3 -I /dev/sdc1 

it tells me

command not found

I am using ghostbsd.
Any hints are highly appreciated. Thanks in advance. to correct my error I typed

fdisk -BI /dev/da0

to make it work on a non-BSD system I would furthermore type

newfs_msdosfs /dev/da0s1

but I get the message

fdisk: Failed to write MBR. Try to use gpart(8)

Doing so,

gpart -BI /dev/da0

I spend the weekend and more time reading and testing all ways to format that usb-stick, so may there is someone who can give me a clue and to get the iso on that same usb-drive. The only information about the usb-drive with Gsmartcontrol about the usb-drive and gpart in the root terminal I can get is the following, one shows me the entire 8GB, command line tells the following

 gpart show da0 =>     64  8292651  da0  GPT  (7.5G) [CORRUPT]        64     1268    1  ms-basic-data  (634K)      1332     5760    2  efi  (2.8M)      7092  8285620    3  ms-basic-data  (4.0G)   8292712        3       - free -  (1.5K) 

some other attempts to wipe out the partition or slice

gpart destroy da0  Device busy  

May someone can help, thanks in advance.

There's quite of lot of knowledge needed to create a bootable USB stick manually from the command line. I've forgotten more than I can remember about that because nowadays I always cheat.

Do you want to know how to do this manually as a learning exercise or do you just want to get it done anyway you can?

Do you have a Windows machine available to you?

I see the media you are starting with is an iso and you can't just dd an iso image to a USB stick and expect it to boot.

My preference would be to put the iso file on a Windows platform and then download (free) a copy of Rufus. Tell Rufus that it's an iso file as input and it will do the whole thing for you.

If you don't have a Windows box take a look at Unetbootin. That will do the same thing on unix/Linux.

Of course, the bios of your machine that you want to boot from USB must support that and have that function enabled but I guess you already know that.

It depends what you want/need to learn about this but, as I say, I just cheat. Other members on here might be able to tell you how to do it manually but I can't remember all the details.

1 Like

I will have to do it the hard way, no windows or linux at reach. Format a usb-stick, make it bootable, put on the iso just to set up a linux without a CD-drive but UEFI, my true honey.

Okay, if you've have no Windows box and no Linux box I think you'd better tell us all what platform you are using to write to the USB stick.

You're trying to create a bootable USB stick for GhostBSD?

I am working on both, two machines, one with GhostBSD, the second (today) PCBSD. So I tried a lot with the command line gpart(8) like this.
The following steps had to be done, with some success just to get a simple usb-stick to be seen and formatted.
It is about to create a bootable usb-stick with a linux iso for an UEFI machine, to be created on that very one BSD machines.

gpart destroy -F da0
da0 destroyed
newfs_msdos /dev/da0
newfs_msdos: trim 16 sectors to adjust to a multiple of 32
/dev/da0: 2001440 sectors in 62545 FAT16 clusters (16384 bytes/cluster)
BytesPerSec=512 SecPerClust=32 ResSectors=1 FATs=2 RootDirEnts=512 Media=0xf0 FATsecs=245 SecPerTrack=32 Heads=64 HiddenSecs=0 HugeSectors=2001984

I tried

newfs_ext2 /dev/da0

with no success.

This one shows at least what has been done so far

diskinfo -v da0

But any further gpart command results in

gpart add -t pclinuxos64-mate-2016.03-boot -l gpboot -b 40 -s 512K da0
gpart: Invalid number of arguments.

gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 da0
gpart: No such geom: da0.

It is an iso of about 795MB, nothing special.

Once again creating the drive (I guess not the slice on it)

 gpart create -s gpt da0
da0 created 

Make it e UEFI memory stick of a certain size (I took 820MB)

gpart add -t efi -s 820MB da0
da0p1 added

gpart bootcode -b /boot/mbr da0
bootcode written to da0

What comes now is not what I want to!!!! But it is part of that instruction.......
THIS IS WHAT I DON'T WANT FOR SURE, I AM AIMING FOR THAT DISTRO MENTIONED ABOVE!

# gpart add -t freebsd da0
# gpart set -a active -i 1 da0

So should I type like this????

gpart add -t pclinuxos64-mate-2016.03
gpart set -a active -i 1 da0

Here comes a sample how to create a boot.iso (note: I am trying to copy an .iso)
This is taken from Disk Setup On FreeBSD

I did not yet dare to haul it all over, thats why I am asking here.

dd if=/dev/zero of=efiboot.img bs=4K count=100
mdconfig -a -t vnode -f efiboot.img
newfs_msdos -F 12 -m 0xf8 /dev/md0
mount -t msdosfs /dev/md0  /mnt
mkdir -p /mnt/efi/boot
cp loader.efi /mnt/efi/bootx64.efi
umount /mnt
mdconfig -d -u 0

and finally making the ISO image.

makefs -t cd9660 -o bootimage='i386;efiboot.img' -o
no-emul-boot -o rockridge -o lable="UEFItest" -o publisher="test" uefi-test.iso image

I will get me another coffee, later on I will try again the part. This machine does not offer a CD-drive, so it has to be done the hard way. Or I will go to burn a DVD or CD in a netcafe. And last but not least, I want to erase a usb-stick that is already a bootable-usb-drive, but this doesn't work at all with gpart(8).

after a while I came across not only the man pages but some other explanation, that should help, but it doesn't
First create a partition

gpart create -s gpt da0

then having a look

gpart show da0
=>

slicing and dicing a partition

gpart add -t mbr da0
gpart: geom 'da0': Operation not permitted

gpart add -t mbr da0s1
gpart: No such geom: da0s1.

newfs /dev/da0s1
newfs: /dev/da0s1: could not find special device

newfs /dev/da0
newfs: /dev/da0: failed to open disk for writing

This is all I get from the device

gpart list da0
Geom name: da0
modified: false
state: OK
fwheads: 255
fwsectors: 63
last: 15794142
first: 34
entries: 128
scheme: GPT
Consumers:
1. Name: da0
   Mediasize: 8086618112 (7.5G)
   Sectorsize: 512
   Mode: r0w0e0

After reading that one first delete the slice and then destroy it, even the GEOM label, I did not succeed doing so at all.

and plugging in that very specific usb-stick again and typing

dmesg
umass0: <USBest Technology USB Mass Storage Device, class 0/0, rev 2.00/1.00, addr 3> on usbus7
umass0:  SCSI over Bulk-Only; quirks = 0x8100
umass0:5:0:-1: Attached to scbus5
da0 at umass-sim0 bus 0 scbus5 target 0 lun 0
da0: <  0.00> Removable Direct Access SCSI-2 device
da0: Serial Number 09022453564397
da0: 40.000MB/s transfers
da0: 7712MB (15794176 512 byte sectors: 255H 63S/T 983C)
da0: quirks=0x2<NO_6_BYTE>

but fdisk and gpart(8) are not the solution.

later on
unmounting the drive, as usually done in gui of Gpart I typed (note I am on the root terminal command line)

newfs /dev/da0
/dev/da0: 7712.0MB (15794176 sectors) block size 32768, fragment size 4096
    using 13 cylinder groups of 626.09MB, 20035 blks, 80256 inodes.
super-block backups (for fsck_ffs -b #) at:
 192, 1282432, 2564672, 3846912, 5129152, 6411392, 7693632, 8975872, 10258112,
 11540352, 12822592, 14104832, 15387072

great, but it does not accept

newfs_msdos -F32 gpt da0
newfs_msdos: /dev/gpt: No such file or directory

doing this (as mentioned above)

dd if=/dev/zero of=efiboot.img bs=4K count=100
mdconfig -a -t vnode -f efiboot.img
newfs_msdos -F 12 -m 0xf8 /dev/md0
mount -t msdosfs /dev/md0  /mnt
mkdir -p /mnt/efi/boot
cp loader.efi /mnt/efi/bootx64.efi
umount /mnt
mdconfig -d -u 0

getting this

mount -t msdosfs /dev/md0  /mnt

mkdir -p /mnt/efi/boot

cp loader.efi /mnt/efi/bootx64.efi
cp: loader.efi: No such file or directory
umount /mntmdconfig -d -u 0

This remains unsolved, on the list to be done the hard way, just learned that I first delete a slice and afterwards I destroy it. Another laptop and a DVD saved my day. If I find a way to create a bootable usb-stick from a BSD machine to set up a linux image, I put it here.

Well it took me sometime until I discovered on distrowatch.com a kind of new distro. So I loaded it down an here it comes, it is the good old unetbootin (unetbootin-source-625.tar.gz) that handles my task just the way it should, creating a bootable usb-drive.

Going one step further I could do so as well with bleachbit, but I see what is left after the cleaning, I hang on to my command line

For debian iso, for instance, a simple dd on whole device (not partition) should create usb bootable disk.

As i see online, it should work for PCBSD as well, if whole device is used not partition.

This will, of course leave no space, but you can resize carefully after (with parted or similar tool, dunno in BSD really) and create additional partition and filesystem from remaining space.

My suggestion is, if machine supports PXE and has network, use it.
It's much easier to handle, supporting all kinds of goodies.

okay, so I hang on to my version of antix (that offers unetbootin) making a bootable usb-stick, because gpart is dragging me down. And just adding this, I coud go for the commandline like

dd if=/your/path/distro.iso of=/dev/sdb1 bs=64K

.
That is putting fun back into your distro.
Sure, unetbootin uses all of the media. But thanks, anyway.

It's been more than eight years I have been using CD or DVD media at all, and since I took off the CD-Drive I am really lazy to put it back, just to burn once in a while a CD.

I may should say this topic can be set as solved under the condition that it works for me.
It is about a usb-stick with an iso-image on it, Made on a linux machine putting a linux-distro on in, bootable device, to test the distro. I did not like it, disarded it, went back to gparted, formatting it as msdos fat32. This worked well, linux tells me, full space available.
The point is, this device goes from a linux to a BSD and rarely to a Windows machine. That is why I needed the msdos fat32 format. While linux says that everything is okay, BSD mumbles correctly, that there still is a boot partition on the drive.

Once again it works for me this way, not claiming the solution for encrypted partitions or slicing and dicing. So this is a particular solution, but probably helpful for others, who are not using encrypted slices or something just made for ufs. Although there is a slice1.

# clean the whole partition
gpart destroy -F da0

# set a mbr on the same
gpart create -s mbr da0

# fill the partition
gpart add -t \!12 da0

# format ins msdos style (fat32)
newfs_msdos -F32 /dev/da0s1

Resuming, some things take time. Damn thing.

This would or could work for make it bootable for ufs or BSD, I did not try yet

# clean it all
gpart destroy -F da0

# set a blank BSD partition 
gpart create -s bsd da0

# set the whole partition for usage of FFS(2)
gpart add -t freebsd-ufs da0

# format it (ffs(2))
newfs -U /dev/da0p1

This is an approach for flash drives

# Think twice about the name of your device
# clearing the MBR
dd if=/dev/zero of=/dev/da0 bs=2m count=0

# formatting it
newfs /dev/da0

# test test test
mount -t ufs /dev/da0 /mnt

# note da0 may, or may NOT be the correct device - check messages

You've managed to make something that is really quite simple very complicated.

To format a USB stick into FAT:

dd if=/dev/zero of=/dev/da0 bs=2m count=1
fdisk -BI /dev/da0
newfs_msdos /dev/da0s1

It's a good idea to do this any time you buy a new flash drive.

To create a bootable USB stick first CD into the directory the .img file you want to work with is in. (I have also used this method to make a bootable USB stick from a Kali and a Debian .iso file.)

Now use the following command:

dd if=./distro.img of=/dev/da0 bs=512k

That's all there is to it. You almost had it the first time but were not using BSD naming scheme on your GhostBSD box.

I realize this is an older thread but wanted to clear that up.