# How to make memstick.img



## ericbsd (Feb 9, 2010)

I need info to make memstick.img for GhostBSD project.
If some one have an how to to make an memstick image.
Please reply.
thanks


----------



## MG (Feb 9, 2010)

```
# make 2GB image file:
  dd if=/dev/zero of=./memstick.img bs=1m count=2000

# load image as virtual disk device:
  mdconfig -a -t vnode -f ./memstick.img -u 0

  fdisk -iI /dev/md0
  bsdlabel -wB /dev/md0s1
  newfs /dev/md0s1a

  mount /dev/md0s1a /mnt
  cd /usr/src
  make installkernel installworld DESTDIR=/mnt
  umount /mnt

# insert memstick now, assuming it will be /dev/da0...
# raw copy virtual disk content to memstick.
  dd if=/dev/md0 of=/dev/da0 bs=1m
```

Don't forget to configure /etc/fstab to mount / from USB


----------



## Markand (Sep 20, 2010)

Don't forget to make DESTDIR=/mnt distribution too.


----------



## mix_room (Sep 22, 2010)

If you already have an image which will fit on the memory-stick you can try 


```
dd if=/dev/zero of=/dev/da0 bs=1k count=1

bsdlabel -Bw da0 auto

newfs -L FreeBSD /dev/da0a

mdconfig -a -t vnode -f X.Y-IMGFILE -u 0 && mount -r -t cd9660 /dev/md0 /mnt/iso

mount /dev/da0a /mnt/USB-Stick

copy all files from your mounted cd in to your USB-Stick, after that you need to create a fstab for your USB-Stick

vi /mnt/USB-Stick/etc/fstab and put following in:

/dev/ufs/FreeBSD / ufs ro 0 0
```

http://www.freebsdnews.net/2009/06/15/install-freebsd-80-usb-memory-stick/


----------



## lgfang (Nov 6, 2010)

It confused me for some time:
why "copying all files" will do the job.  Aren't we supposed to also install boot loader (or something alike) into the MBR of the img?


----------



## wblock@ (Nov 6, 2010)

lgfang said:
			
		

> It confused me for some time:
> why "copying all files" will do the job.  Aren't we supposed to also install boot loader (or something alike) into the MBR of the img?



The bsdlabel(8) command above does that.


----------



## lgfang (Nov 6, 2010)

*thanks*

thanks


----------

