From owner-freebsd-questions@freebsd.org Sat Dec 5 14:18:40 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 7AA7FA419FC for ; Sat, 5 Dec 2015 14:18:40 +0000 (UTC) (envelope-from perryh@pluto.rain.com) Received: from agora.rdrop.com (agora.rdrop.com [IPv6:2607:f678:1010::34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 65A8A1A85 for ; Sat, 5 Dec 2015 14:18:40 +0000 (UTC) (envelope-from perryh@pluto.rain.com) Received: from agora.rdrop.com (66@localhost [127.0.0.1]) by agora.rdrop.com (8.13.1/8.12.7) with ESMTP id tB5EDiJP065962 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sat, 5 Dec 2015 06:13:46 -0800 (PST) (envelope-from perryh@pluto.rain.com) Received: (from uucp@localhost) by agora.rdrop.com (8.13.1/8.14.2/Submit) with UUCP id tB5EDhcP065961 for freebsd-questions@freebsd.org; Sat, 5 Dec 2015 06:13:43 -0800 (PST) (envelope-from perryh@pluto.rain.com) Received: from fbsd81 by pluto.rain.com (4.1/SMI-4.1-pluto-M2060407) id AA26963; Sat, 5 Dec 15 00:01:04 PST Date: Sat, 05 Dec 2015 00:01:03 -0800 From: perryh@pluto.rain.com (Perry Hutchison) To: freebsd-questions@freebsd.org Subject: resizing a memstick image Message-Id: <566299bf.2z11XFWfUMRFyXGs%perryh@pluto.rain.com> User-Agent: nail 11.25 7/29/05 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: Sat, 05 Dec 2015 14:18:40 -0000 Having downloaded the 10.2 memstick image, I see that it is configured as a 657MB GPT: # mdconfig -a -t vnode -u 0 -f /path/to/FreeBSD-10.2-RELEASE-i386-memstick.img # ls -l /dev/md* crw-r----- 1 root operator 0, 175 Nov 30 01:46 /dev/md0 crw-r----- 1 root operator 0, 176 Nov 30 01:46 /dev/md0p1 crw-r----- 1 root operator 0, 178 Nov 30 01:46 /dev/md0p2 crw-r----- 1 root operator 0, 179 Nov 30 01:46 /dev/md0p3 crw------- 1 root wheel 0, 74 Aug 29 12:17 /dev/mdctl # gpart show md0 => 3 1346448 md0 GPT (657M) 3 32 1 freebsd-boot (16K) 35 1344368 2 freebsd-ufs (656M) 1344403 2048 3 freebsd-swap (1.0M) After I write this onto a 4GB flash drive, how would I go about resizing the GPT and/or protective MBR to reflect the actual size of the drive, so as to make the remaining 3GB or so available for an additional partition and eliminate the geom warnings that the secondary GPT is either corrupted or not in the last LBA? Relevant parts of dmesg -- When connecting the flash drive before writing to it (on FreeBSD 8): ugen0.3: at usbus0 umass1: on usbus0 umass1: SCSI over Bulk-Only; quirks = 0x0000 umass1:3:1:-1: Attached to scbus3 (probe0:umass-sim1:1:0:0): TEST UNIT READY. CDB: 0 0 0 0 0 0 (probe0:umass-sim1:1:0:0): CAM status: SCSI Status Error (probe0:umass-sim1:1:0:0): SCSI status: Check Condition (probe0:umass-sim1:1:0:0): SCSI sense: UNIT ATTENTION asc:28,0 (Not ready to ready change, medium may have changed) da2 at umass-sim1 bus 1 scbus3 target 0 lun 0 da2: < Patriot Memory PMAP> Removable Direct Access SCSI-4 device da2: 1.000MB/s transfers da2: 3814MB (7811072 512 byte sectors: 255H 63S/T 486C) After writing the .img file to the flash drive (on FreeBSD 8): GEOM: da2: partition 1 does not end on a track boundary. GEOM: da2: the secondary GPT table is corrupt or invalid. GEOM: da2: using the primary only -- recovery suggested. When booting 10.2-RELEASE from that flash drive: ehci0: mem 0xffa80800-0xffa80bff irq 23 at device 29.7 on pci0 usbus4: EHCI version 1.0 usbus4 on ehci0 usbus4: 480Mbps High Speed USB v2.0 ugen4.1: at usbus4 uhub2: on usbus4 Root mount waiting for: usbus4 Root mount waiting for: usbus4 uhub2: 8 ports with 8 removable, self powered Root mount waiting for: usbus4 Root mount waiting for: usbus4 ugen4.2: at usbus4 umass0: on usbus4 umass0: SCSI over Bulk-Only; quirks = 0xc100 umass0:4:0:-1: Attached to scbus4 Trying to mount root from ufs:/dev/ufs/FreeBSD_Install [ro,noatime]... mountroot: waiting for device /dev/ufs/FreeBSD_Install ... pass2 at umass-sim0 bus 0 scbus4 target 0 lun 0 pass2: < Patriot Memory PMAP> Removable Direct Access SPC-2 SCSI device pass2: Serial Number ################ pass2: 40.000MB/s transfers GEOM: new disk da0 da0 at umass-sim0 bus 0 scbus4 target 0 lun 0 da0: < Patriot Memory PMAP> Removable Direct Access SPC-2 SCSI device da0: Serial Number ################ da0: 40.000MB/s transfers da0: 3814MB (7811072 512 byte sectors: 255H 63S/T 486C) da0: quirks=0x2 GEOM: da0: the secondary GPT header is not in the last LBA. GEOM: diskid/DISK-################: the secondary GPT header is not in the last LBA. GEOM: diskid/DISK-################: the secondary GPT header is not in the last LBA. GEOM: diskid/DISK-################: the secondary GPT header is not in the last LBA.