From owner-freebsd-questions@freebsd.org Fri Oct 2 21:31:00 2015 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0325EA0D1A2 for ; Fri, 2 Oct 2015 21:31:00 +0000 (UTC) (envelope-from milios@ccsys.com) Received: from cargobay.net (cargobay.net [198.178.123.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D75511916 for ; Fri, 2 Oct 2015 21:30:59 +0000 (UTC) (envelope-from milios@ccsys.com) Received: from [192.168.0.14] (cblmdm72-240-160-19.buckeyecom.net [72.240.160.19]) by cargobay.net (Postfix) with ESMTPSA id 94EA826C; Fri, 2 Oct 2015 21:30:57 +0000 (UTC) Subject: Re: Geom question To: "William A. Mahaffey III" References: <560EDE45.3040605@hiwaay.net> <3D81C7BC-1A31-4046-88B7-50F25EA3B952@ccsys.com> <560EF0CC.80805@hiwaay.net> Cc: FreeBSD Questions !!!! From: "Chad J. Milios" Message-ID: <560EF795.6020406@ccsys.com> Date: Fri, 2 Oct 2015 17:31:01 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <560EF0CC.80805@hiwaay.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Oct 2015 21:31:00 -0000 On 10/2/2015 5:00 PM, William A. Mahaffey III wrote: > On 10/02/15 15:31, Chad J. Milios wrote: >>> On Oct 2, 2015, at 3:41 PM, William A. Mahaffey III >>> wrote: >>> >>> I am prepping to provision 2 boxen w/ FreeBSD 9.3R, preferably from >>> a thumb drive. I would like to add a 'utils' directory w/ some >>> scripts I wrote to automate the partitioning/slicing of the HDD's >>> (2X on 1 box, 8X on the other), & also accumulate output from the >>> install process in case questions arise. To that end, I am planning >>> on partitioning/slicing a thumb drive, prepping it to be bootable >>> following examples on the gpart man page, & copying verbatim stuff >>> from the memstick.img for 9.3R that I downloaded a while back, as >>> well as adding my utils directory. Reading up on gpart & geom raises >>> 1 question: can I do all these preps on a disk image file I create >>> w/ dd, or do i do them in place on the target memstick, then dd the >>> results onto an on-disk image for safekeeping ? Put another way, can >>> a disk image created by dd be a 'geom' for gpart ? TIA & have a good >>> one. >>> >>> -- >>> >>> William A. Mahaffey III >> In a way, yes. `mdconfig -f filename` will make your file accessible >> as a virtual device. >> > > Thanks for the info. I proceeded w/ trying to setup /dev/md0 as a > bootable disk image as follows: > > [root@kabini1, /etc, 3:54:31pm] 758 % dd if=/dev/zero > of=/home/memstick.img count=3699 bs=1m > 3699+0 records in > 3699+0 records out > 3878682624 bytes transferred in 8.324621 secs (465929036 bytes/sec) FYI, check out `man truncate` next time to save some time/space. Most file systems support what are known as "sparse" files. That dd command works just fine for this though. > [root@kabini1, /etc, 3:55:23pm] 759 % cat > ~wam/FreeBSD/9.3/README.createBootableMBR-SD.txt > > MBR: Master Boot Record is used on PCs and removable media. > Requires > the GEOM_PART_MBR kernel option. The GEOM_PART_EBR option > adds > support for the Extended Boot Record (EBR), which is used to > define a logical partition. The GEOM_PART_EBR_COMPAT option > enables backward compatibility for partition names in the EBR > scheme. It also prevents any type of actions on such > partitions. > > Create an MBR scheme on ada0, then create a 30GB-sized FreeBSD > slice, mark it active and install the boot0 boot manager: > > /sbin/gpart create -s MBR ada0 > /sbin/gpart add -t freebsd -s 30G ada0 > /sbin/gpart set -a active -i 1 ada0 > /sbin/gpart bootcode -b /boot/boot0 ada0 > > Now create a BSD scheme (BSD label) with space for up to 20 > partitions: > > /sbin/gpart create -s BSD -n 20 ada0s1 > > Create a 1GB-sized UFS partition and a 4GB-sized swap partition: > > /sbin/gpart add -t freebsd-ufs -s 1G ada0s1 > /sbin/gpart add -t freebsd-swap -s 4G ada0s1 > > Install bootstrap code for the BSD label: > > /sbin/gpart bootcode -b /boot/boot ada0s1 > > [root@kabini1, /etc, 3:55:50pm] 760 % mdconfig -f /home/memstick.img > md0 > [root@kabini1, /etc, 3:56:26pm] 761 % /sbin/gpart create -s MBR md0 > md0 created > [root@kabini1, /etc, 3:58:45pm] 762 % /sbin/gpart add -t freebsd -s > 3698M md0 > md0s1 added If you leave off the -s $SIZE option gpart will simply use up every available byte for you > [root@kabini1, /etc, 3:59:14pm] 763 % /sbin/gpart set -a active -i 1 md0 > active set on md0s1 > [root@kabini1, /etc, 3:59:25pm] 764 % /sbin/gpart bootcode -b > /boot/boot0 md0 > bootcode written to md0 > [root@kabini1, /etc, 3:59:44pm] 765 % /sbin/gpart create -s BSD md0s1 > md0s1 created > [root@kabini1, /etc, 3:59:57pm] 766 % /sbin/gpart add -t freebsd-ufs > md0s1 > md0s1a added > [root@kabini1, /etc, DING!] 767 % /sbin/gpart bootcode -b /boot/boot > md0s1 > bootcode written to md0s1 > [root@kabini1, /etc, 4:00:25pm] 768 % lltr /dev/md0*; date > crw-r----- 1 root operator 0xd2 Oct 2 15:56 /dev/md0 > crw-r----- 1 root operator 0xd5 Oct 2 15:59 /dev/md0s1 > crw-r----- 1 root operator 0xd6 Oct 2 16:00 /dev/md0s1a > Fri Oct 2 16:00:44 MCDT 2015 > [root@kabini1, /etc, 4:00:44pm] 769 % mount /dev/md0s1 /media/sd/ > mount: /dev/md0s1: Invalid argument > [root@kabini1, /etc, 4:01:16pm] 770 % mount -t ufs /dev/md0s1 /media/sd/ > mount: /dev/md0s1: Invalid argument > [root@kabini1, /etc, 4:01:34pm] 771 % mount -t ufs /dev/md0s1a /media/sd/ > mount: /dev/md0s1a: Invalid argument > [root@kabini1, /etc, 4:01:41pm] 772 % > > & I appear to be stuck trying to mount the /dev/md0 device so I can > copy stuff to it :-/. Any clues appreciated. TIA & have a good one. you need to `newfs /dev/md0s1a` first before attempting to mount it, as `gpart add -t freebsd-ufs $GEOM` only marks the meta info in the outerlying structure (the front few blocks of /dev/md0s1 in your case) and doesn't actually do what you're expecting. `man newfs` to decide that you probably want the -U flag with that and might want the -J flag as well. Cheers, -Chad