Skip site navigation (1)Skip section navigation (2)
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>

next in thread | raw e-mail | index | archive | help
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: <vendor 0x13fe> at usbus0
  umass1: <vendor 0x13fe Patriot Memory, class 0/0, rev 2.00/1.00, addr 3> 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: <Intel 82801EB/R (ICH5) USB 2.0 controller> 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: <Intel> at usbus4
  uhub2: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> 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: <vendor 0x13fe> at usbus4
  umass0: <vendor 0x13fe Patriot Memory, class 0/0, rev 2.00/1.00, addr 2> 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<NO_6_BYTE>
  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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?566299bf.2z11XFWfUMRFyXGs%perryh>