From owner-freebsd-questions@FreeBSD.ORG Sun Jul 8 15:06:48 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9AED1106566C for ; Sun, 8 Jul 2012 15:06:48 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from sola.nimnet.asn.au (paqi.nimnet.asn.au [115.70.110.159]) by mx1.freebsd.org (Postfix) with ESMTP id F2AD18FC16 for ; Sun, 8 Jul 2012 15:06:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by sola.nimnet.asn.au (8.14.2/8.14.2) with ESMTP id q68F6dpl040832; Mon, 9 Jul 2012 01:06:40 +1000 (EST) (envelope-from smithi@nimnet.asn.au) Date: Mon, 9 Jul 2012 01:06:39 +1000 (EST) From: Ian Smith To: Carmel In-Reply-To: <20120708120028.85CA7106568C@hub.freebsd.org> Message-ID: <20120708233300.J42038@sola.nimnet.asn.au> References: <20120708120028.85CA7106568C@hub.freebsd.org> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-94130394-1341759999=:42038" Cc: freebsd-questions@freebsd.org Subject: Re: Format a USB flash drive using gpart X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 15:06:48 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-94130394-1341759999=:42038 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT In freebsd-questions Digest, Vol 422, Issue 10, Message: 29 On Sun, 8 Jul 2012 07:41:59 -0400 Carmel wrote: > On Sat, 7 Jul 2012 20:36:36 -0600 (MDT) > Warren Block articulated: > > > On Sat, 7 Jul 2012, Carmel wrote: > > > > > This is probably a dumb question, but does gpart even work on a USB > > > flash drive? I have not been able to figure out how to do it. I > > > want to erase the entire drive and format it for a FreeBSD UFS2 > > > file system. > > > > Yes, gpart will work with pretty much any storage device. > > > > If you want the drive to be bootable, it needs boot blocks. This is > > easier with GPT than MBR. For an 8G drive: > > > > # gpart create -s gpt da0 > > # gpart add -t freebsd-boot -s 512k da0 > > # gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 da0 > > # gpart add -t freebsd-ufs -b 1M -s 7G da0 > > # gpart add -t freebsd-swap da0 > > # newfs -U /dev/da0p2 > > Thanks Warren, you win the prize for the most detailed answer. > Polytropon gave me the easiest answer if I just want to use the drive > as a simple storage device; however, if at some point I actually want > to go beyond that your answer is what I would require. > > Interestingly enough, I searched through the man pages and FreeBSD help > but never came across anything that specifically addressed flash drive. > Perhaps I was just not looking hard enough. In general they're not distinct in usage from any other type of disk. > Perhaps, and I know that this will offend some purists, but a nice GUI > that would do what your instructions detail above would be helpful. > There is no way that I am going to remember all of those instructions in > six months time. Just my 2ยข. Well one of the reasons I'm replying to this is to keep a copy of Warren's recipe handy :) Another is to point out that rumours of the death of MBR partitioning, especially on small disks, are premature. I know your question specified gpart, but the easiest way I know of to put UFS filesystems on flash drives is to use sade(8), incorporating the fdisk & bsdlabel & newfs functions from sysinstall .. it still works as well as ever, however "old-fashioned" or "deprecated" some may call it. sade's GUI at the curses level :) and does all the heavy maths for you, both for slicing the disk and partitioning the slice(s). As mentioned in boot0cfg(8), you have to set # sysctl kern.geom.debugflags=16 before sade (or anything) can write to any GEOM disk's boot sectors. Remember to reset it to 0 later. You might even like to put a small msdosfs slice first, so you can use some of that stick to transfer files between UFS and DOS systems. And yes you can multiboot from a memstick if you (or sade) put boot0 on it, assuming your computer supports booting from USB drives. I don't know what the gpart equivalent of boot0 is, if there is one yet? Last I heard, seemed you had to use Linux tools to multiboot GPT disks. There was some muttering about updating sade to handle GPT too .. that would be very welcome, maybe restoring some of the lost functionality from sysinstall/sade back into bsdinstall, both for GPT and MBR systems. cheers, Ian --0-94130394-1341759999=:42038--