Web lists-archives.com

Re: DD bs=4M option on USB mem-stick creates false format




Hi,

i wrote a small program which shall make a USB stick with isohybrid ISO
more digestible for partition editors by removing all partition tables
except MBR partitions.
It then creates a new partition in the first MBR partition slot which
is found with block count 0.

  usage: ./make_isombr_part file_path partition_end partition_type

         Creates a partition in a free slot of an isohybrid MBR in an ISO.
         Removes GPT and APM signatures if present.
         file_path must lead to a file or device with isohybrid ISO.
         partition_end tells the number of 512-byte blocks of device.
         partiton_end value "auto" means full number of device blocks.
         partition_type is a hex number in the range of 00 to ff.
         Type examples: 83 = Linux , 0c = FAT32 , 17 = Hidden NTFS

Binary compiled on Debian 8 (you may need to give it x-permission after
download):

  http://scdbackup.webframe.org/make_isombr_part

MD5: 4856af2c1b50a775325a3e6c09d7d9bc

Source code:
  http://scdbackup.webframe.org/make_isombr_part.c

The argument "auto" currently works only on Linux kernels.
On other systems one has to give the block number explicitely.

------------------------------------------------------------------------

See a test run with rescatux ISO on /dev/sdc (any current Debian i386
or amd64 ISO would be suitable, too).

Still less dangerous than manipulating /dev files as superuser is
to give the world temporary permission to the one stick in question:

  $ sudo chmod o+rw /dev/sdc

(The program is supposed to refuse if it does not find an isohybrid ISO.
 But better do not bet on those safety measures.)

Let the program remove APM and GPT and add a MBR partition:

  $ chmod u+x ./make_isombr_part

  $ ./make_isombr_part /dev/sdc auto 83
  Note: Storage capacity of '/dev/sdc' : 3915776 blocks
  Note: Wrote MBR partition slot 3, type 0x83, start 1374208, blocks 2541568
  Note: Removed APM signature
  Note: Removed GPT signature at block 1
  Note: Removed GPT signature at block 1374207

Afterwards, fdisk reports the new partiton table:

  $ /sbin/fdisk -l /dev/sdc
  Disk /dev/sdc: 1.9 GiB, 2004877312 bytes, 3915776 sectors
  ...
  Device     Boot   Start     End Sectors  Size Id Type
  /dev/sdc1  *         64 1374207 1374144  671M  0 Empty
  /dev/sdc2       1297212 1298619    1408  704K ef EFI (FAT-12/16/32)
  /dev/sdc3       1374208 3915775 2541568  1.2G 83 Linux

When done, exclude the world from directly reading and altering the stick
content:

  $ sudo chmod o-rw /dev/sdc

Best unplug the stick and put it in again, so that the operating system
takes notice of the new partition table situation.

------------------------------------------------------------------------

It would be interesting to see how various partition editors react on
this state of the USB stick. Can they reduce the size of partition 3 ?
Can they remove partition 3 and add on new one ?

------------------------------------------------------------------------

Have a nice day :)

Thomas