Re: USB key and lost space

2018-02-19 Thread Thomas Schmitt
Hi,

Rodary Jacques wrote:
> dd if=/dev/zero bs=2048 seek=16 count=4 conv=notrunc of=/dev/sde
> dd: impossible d'ouvrir '/dev/sde': Système de fichiers accessible en
> lecture seulement

Please show the outcome of

  ls -l /dev/sdc
  getfacl /dev/sdc

My french suffices to decode the statement and to assume that this
was originally EROFS "Read-only filesystem" before it fell victim
to i18n.

But if i have no write permission when attempting to write by dd, i get
  dd: failed to open ‘/dev/sdc’: Permission denied
which is EPERM, not EROFS.
So aside from the i18n ambiguity, i cannot really reproduce the situation.
But i only have USB sticks, no memory cards.

Can it be that a read-only switch is activated at the card or the
device where you put it in ?


Have a nice day :)

Thomas



Re: USB key and lost space

2018-02-19 Thread David Wright
On Tue 20 Feb 2018 at 01:23:01 (+0100), Rodary Jacques wrote:
> "To erase the ISO 9660 superblock of debian-9.3.0-amd64-netinst.iso do
> 
>   umount /dev/sde1
>   dd if=/dev/zero bs=2048 seek=16 count=4 conv=notrunc of=/dev/sde
> 
> But first make sure that /dev/sde is indeed the medium you want to erase."
>  I did that before the result is :
> 
> dd if=/dev/zero bs=2048 seek=16 count=4 conv=notrunc of=/dev/sde 
> 
>  Same answer with fdisk cfdisk ...
> Sorry

You might consider checking out your mail client. What you see above is the
[text/plain, 7bit, iso-8859-1, 0.4K]
version which, I think you'll agree, doesn't make a lot of sense as
the most important line is missing. I could read that only from the
[text/html, quoted, iso-8859-1, 2.7K]
version.

I don't know the type of card reader(s) you're using. My tiny ?µSD cards
either fit in a USB2 device that's not much larger, or into hollow SD-size
cards. All of the latter have a readonly slider. Is each µSD in its own
adaptor, or are you using the same one for all?

Cheers,
David.



Re: Re: USB key and lost space

2018-02-19 Thread Rodary Jacques
"To erase the ISO 9660 superblock of debian-9.3.0-amd64-netinst.iso do

  umount /dev/sde1
  dd if=/dev/zero bs=2048 seek=16 count=4 conv=notrunc of=/dev/sde

But first make sure that /dev/sde is indeed the medium you want to erase."
 I did that before the result is :

dd if=/dev/zero bs=2048 seek=16 count=4 conv=notrunc of=/dev/sde 

 Same answer with fdisk cfdisk ...
Sorry


Re: USB key and lost space

2018-02-18 Thread Thomas Schmitt
Hi,

Rodary Jacques wrote:
> I don't quite know how, but with fdisk, cfdisk, parted, partx and partprobe
> I now have a brand new key with 16 GB (or GiB), the original size, without
> the iso file,
> [...]
> But the one with netinst iso (with the two partitions) seem to be much
> harder.
> [...]
> 'wipefs /dev/sde' continue to read:
> [...]
> 0x8001   iso9660   [filesystem]
> LABEL: Debian 9.3.0 amd64 n

Originally you asked:
> > On  several USB keys used for installation (or try of) I copied iso files of
> > more or less  MB, and the remaining space (of 15 or 31MB is inaccessible

This is a different job than removing an installation ISO from a USB stick
or memory card.

To erase the ISO 9660 superblock of debian-9.3.0-amd64-netinst.iso do

  umount /dev/sde1
  dd if=/dev/zero bs=2048 seek=16 count=4 conv=notrunc of=/dev/sde

But first make sure that /dev/sde is indeed the medium you want to erase.
Device names can change on unplug and replug.


I really wonder what the regular use case of wipefs is. Its man page
looks confusing:

   wipefs can erase filesystem , raid or partition-table signatures (magic
   strings) from the specified device to make the signatures invisible for
   libblkid.
   wipefs does not erase the filesystem itself [...]

Removing "signatures" quite surely damages the mountability. It looks like
this tool is intended to create confusion about disk content.


> mount says "/dev/sde1 on /media/jr/NIKON D7100
> type vfat (ro, etc..." which is correct except for the ro!

So partition 1 now marks a block range with a FAT filesystem.

What does a partition editor (not wipefs) say about partitions ?


> How can I force the kernel to forget this 'read only' on the disk?

First you will have to find the reason.

It could be over-smartness because of the ISO 9660 superblock which
is now iprobably valid only if read from the base device.

It could be lack of rw-permission on /dev/sde1.


In worst case you will have to overwrite the first MB and the last MB of
/dev/sde and then partition it again. All filesystem content will become
inaccessible then.

But for now, try to get rid of ISO 9660, unplug, replug, and see what
happens. Especially look at permissions of overall device file
(e.g. /dev/sde) and partition device files (e.g. /dev/sde1).


Have a nice day :)

Thomas



Re: USB key and lost space

2018-02-18 Thread Rodary Jacques
Le vendredi 16 février 2018, 12:03:56 CET Thomas Schmitt a écrit :
> Hi,
> 
> Rodary Jacques wrote:
> > I did subscribe  in april 2016,
> 
> The mail header X-Spam-Status in your mail to the list does not contain
> the test "LDOSUBSCRIBER". So currently your address roda...@free.fr is
> not subscribed.
> 
> Consider to subscribe again and also to Cc: the debian-user list with
> your replies.
> 
> 
> > Where am I supposed to find firmware.tar.gz. It may be a very stupid
> > question, I was used with .iso  image disks only.
> 
> Other people on debian-user probably have more experience with that.
> I have to google.
> For the current Debian release 9 "stretch" it is probably on
>   
> https://cdimage.debian.org/cdimage/unofficial/non-free/firmware/stretch/current/
> 
> 
> I wrote:
> > > So use /sbin/fdisk to create partition 3.
> 
> > I used fdisk, cfdisk and partitionprobe and it seems my Key is  quite
> > useless now
> 
> Which ISO image did you put onto the USB stick ?
> 
> Let's give current netinst a try:
> 
>   $ dd if=debian-9.3.0-amd64-netinst.iso of=/dev/sdc bs=1M
>   ...
>   $ /sbin/fdisk /dev/sdc
>   ...
>   Command (m for help): p
>   ...
>   Device Boot StartEnd Sectors  Size Id Type
>   /dev/sdc1  *0 593919  593920  290M  0 Empty
>   /dev/sdc23760   4591 832  416K ef EFI (FAT-12/16/32)
> 
>   Command (m for help): n
>   Partition type
>  p   primary (2 primary, 0 extended, 2 free)
>  e   extended (container for logical partitions)
>   Select (default p): p
>   Partition number (3,4, default 3): 3
>   First sector (593920-7864318, default 593920): 
>   Last sector, +sectors or +size{K,M,G,T,P} (593920-7864318, default 
> 7864318): 
> 
>   Created a new partition 3 of type 'Linux' and of size 3.5 GiB.
> 
>   Command (m for help): p
>   Disk /dev/sdc: 3.8 GiB, 4026531328 bytes, 7864319 sectors
>   Units: sectors of 1 * 512 = 512 bytes
>   Sector size (logical/physical): 512 bytes / 512 bytes
>   I/O size (minimum/optimal): 512 bytes / 512 bytes
>   Disklabel type: dos
>   Disk identifier: 0x0347fd41
> 
>   Device Boot  Start End Sectors  Size Id Type
>   /dev/sdc1  * 0  593919  593920  290M  0 Empty
>   /dev/sdc2 37604591 832  416K ef EFI (FAT-12/16/32)
>   /dev/sdc3   593920 7864318 7270399  3.5G 83 Linux
> 
> 
>   Command (m for help): w
>   The partition table has been altered.
>   Calling ioctl() to re-read partition table.
>   Re-reading the partition table failed.: Permission denied
> 
> The final error message comes because i did this as normal user, just
> having rw-permission to /dev/sdc.
> I unplug and replug the USB stick to let the kernel assess the new
> partitioning:
> 
>   $ ls /dev/sdc*
>   /dev/sdc  /dev/sdc1  /dev/sdc2  /dev/sdc3
> 
> 
> > I will try dd, very carefully. to erase this new partition I finally
> > created, and perhaps come back to you afterwards.
> 
> I would just copy the ISO again onto the USB stick base device 
> and then run fdisk.
> 
> 
> Have a nice day :)
> 
> Thomas
Saturday:
I don't quite know how, but with fdisk, cfdisk, parted,  partx and 
partprobe I now have a brand new key with 16 GB (or GiB),  the original size, 
without the iso file, type vfat (rw, nosuid, nodev, relatime, uid=1000, 
gid=1000, fmask=0022, dmask=0022, codepage=437, iocharset=ascii, 
shortname=mixed, showexec, utf8, flush,errors=remount-ro, uhelper=udisks2. I 
have three oher microSDHC to save!
Sunday:  That was yesterday! Two of the microSDHC cards didn't resist to my 
assaults. But the one with netinst iso (with the two partitions)  seem to be 
much harder. 
Tired of trying (fdisk cfdisk sfdisk parted failed with "read only 
disk"), I put the card in my camera to format it, successfully. 
On a Mac, it is now known as "NIKON D7100" and is read-write, as on the 
camera. But on my Debian and Fedora boxes, if it recognized as such also, it 
stays read only: 'wipefs /dev/sde' continue to read:
offset   type 

which was the old  situation, mount says "/dev/sde1 on /media/jr/NIKON D7100 
type vfat (ro, etc..." which is correct except for the ro! Same with the other 
tools.
How can I force the kernel to forget this 'read only' on the disk? 
Could it be because of the external card reader I use?
It is not really important, since I can use this card with my mac and 
to scan documents, but I like to understand.
Jacques







Re: USB key and lost space

2018-02-16 Thread Thomas Schmitt
Hi,

Rodary Jacques wrote:
> I did subscribe  in april 2016,

The mail header X-Spam-Status in your mail to the list does not contain
the test "LDOSUBSCRIBER". So currently your address roda...@free.fr is
not subscribed.

Consider to subscribe again and also to Cc: the debian-user list with
your replies.


> Where am I supposed to find firmware.tar.gz. It may be a very stupid
> question, I was used with .iso  image disks only.

Other people on debian-user probably have more experience with that.
I have to google.
For the current Debian release 9 "stretch" it is probably on
  
https://cdimage.debian.org/cdimage/unofficial/non-free/firmware/stretch/current/


I wrote:
> > So use /sbin/fdisk to create partition 3.

> I used fdisk, cfdisk and partitionprobe and it seems my Key is  quite
> useless now

Which ISO image did you put onto the USB stick ?

Let's give current netinst a try:

  $ dd if=debian-9.3.0-amd64-netinst.iso of=/dev/sdc bs=1M
  ...
  $ /sbin/fdisk /dev/sdc
  ...
  Command (m for help): p
  ...
  Device Boot StartEnd Sectors  Size Id Type
  /dev/sdc1  *0 593919  593920  290M  0 Empty
  /dev/sdc23760   4591 832  416K ef EFI (FAT-12/16/32)

  Command (m for help): n
  Partition type
 p   primary (2 primary, 0 extended, 2 free)
 e   extended (container for logical partitions)
  Select (default p): p
  Partition number (3,4, default 3): 3
  First sector (593920-7864318, default 593920): 
  Last sector, +sectors or +size{K,M,G,T,P} (593920-7864318, default 7864318): 

  Created a new partition 3 of type 'Linux' and of size 3.5 GiB.

  Command (m for help): p
  Disk /dev/sdc: 3.8 GiB, 4026531328 bytes, 7864319 sectors
  Units: sectors of 1 * 512 = 512 bytes
  Sector size (logical/physical): 512 bytes / 512 bytes
  I/O size (minimum/optimal): 512 bytes / 512 bytes
  Disklabel type: dos
  Disk identifier: 0x0347fd41

  Device Boot  Start End Sectors  Size Id Type
  /dev/sdc1  * 0  593919  593920  290M  0 Empty
  /dev/sdc2 37604591 832  416K ef EFI (FAT-12/16/32)
  /dev/sdc3   593920 7864318 7270399  3.5G 83 Linux


  Command (m for help): w
  The partition table has been altered.
  Calling ioctl() to re-read partition table.
  Re-reading the partition table failed.: Permission denied

The final error message comes because i did this as normal user, just
having rw-permission to /dev/sdc.
I unplug and replug the USB stick to let the kernel assess the new
partitioning:

  $ ls /dev/sdc*
  /dev/sdc  /dev/sdc1  /dev/sdc2  /dev/sdc3


> I will try dd, very carefully. to erase this new partition I finally
> created, and perhaps come back to you afterwards.

I would just copy the ISO again onto the USB stick base device 
and then run fdisk.


Have a nice day :)

Thomas



Re: USB key and lost space

2018-02-15 Thread Thomas Schmitt
Hi,

Pascal Hambourg wrote:
> I did not have trouble with the Apple partition table except when using
> libparted-based partition editors, but could you explain how you remove it ?

By dd-ing the first 32 bytes from file "isohdpfx.bin" of package "isolinux"
onto the first 32 bytes of the ISO image (as data file with conv=notrunc
or as USB stick).

debian-9.3.0-amd64-netinst.iso has in its MBR the APM signature and a
fake block count which happen to be x86 machine code without undesirable
side effects:

 :45  52  08  00  00  00  90  90  00  00  00  00  00  00  00  00
0010 :00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00

The first 432 bytes of amd64 and i386 isohybrid ISOs stem from
  /usr/lib/ISOLINUX/isohdpfx.bin
which has x86 code that is similarly harmless but does not indicate APM:

 :33  ed  90  90  90  90  90  90  90  90  90  90  90  90  90  90
0010 :90  90  90  90  90  90  90  90  90  90  90  90  90  90  90  90

This jackalope was invented by Matthew J. Garrett.
  https://mjg59.dreamwidth.org/11285.html

Of course one may use own useless x86 code to deface APM. Some machine code
knowledge would be precondition, though. Assembler source of isohdpfx.bin
is at
  https://github.com/geneC/syslinux/blob/master/mbr/isohdpfx.S


> (Strangely enough, wipefs does not find the GPT)

The GPT in mjg's layout is not valid, because the partition table of the
MBR does not consist of a single partition of type 0xee which starts at
LBA 1.

I meanwhile doubt that it is of any use. The history of mjg's development
indicates that he first started with valid GPT and then ihad to add a MBR
partition of type 0xef for marking the EFI System Partition / Boot Image,
because some machines did not work with the GPT marked EFI partition.

Partition editors like gparted or gdisk detect the presence of the GPT
header block at LBA 1 and then complain about the wrong MBR partition table.
This can be silenced by zeroing bytes 512 to 1023 of the ISO.


A valid GPT can be found in grub-mkrescue ISOs which were produced
while GRUB binary packages for 32-bit EFI and/or 64-bit EFI were installed.


Have a nice day :)

Thomas



Re: USB key and lost space

2018-02-15 Thread Pascal Hambourg

Le 15/02/2018 à 08:06, Thomas Schmitt a écrit :


Additional difficulty is the presence of Apple Partition Map and of
an invalid GPT.
To my experience only the partition editor fdisk is willing to ignore
these extra partition tables. So use /sbin/fdisk to create partition 3.

If the resulting partitioning makes trouble, you could deface APM and GPT
by help of dd runs. (Ask me for instructions if really needed.)


I did not have trouble with the Apple partition table except when using 
libparted-based partition editors, but could you explain how you remove 
it ? According to wipefs :


# wipefs debian-9.3.0-amd64-i386-netinst.iso
offset   type

0x0  mac   [partition table]

0x1fedos   [partition table]

0x8001   iso9660   [filesystem]
 LABEL: Debian 9.3.0 M-A 1
 UUID:  2017-12-09-13-52-51-00

the Apple partition table signature is located at offset 0 in the MBR, 
in the same area as the BIOS boot code. So I would not just wipe it and 
expect the installer to still boot properly.


(Strangely enough, wipefs does not find the GPT)



Re: USB key and lost space

2018-02-14 Thread Thomas Schmitt
Hi,

Rodary Jacques wrote:
> https://www.debian.org/releases/stable/amd64/ch04s03.html.fr
> Pour cela, vous devez créer une deuxième partition FAT,

https://www.debian.org/releases/stable/amd64/ch04s03.html
"Create a second, FAT partition on the stick"

Well, the "second" is a bit outdated. Meanwhile we have two partitions in
the ISOs for amd64 and i386. So the new partition will be the third one.

Additional difficulty is the presence of Apple Partition Map and of
an invalid GPT.
To my experience only the partition editor fdisk is willing to ignore
these extra partition tables. So use /sbin/fdisk to create partition 3.

If the resulting partitioning makes trouble, you could deface APM and GPT
by help of dd runs. (Ask me for instructions if really needed.)

Then probably program mkfs.vfat can be used to create a new FAT filesystem
in the new partition 3. (Others here probably have more experience with
that task.)


> monter la partition et y copier et décompresser le microprogramme.
  "mount the partition and copy or unpack the firmware onto it."
> # mount /dev/sdX2 /mnt

The placeholder "/dev/sdX2" would become "/dev/sdX3".
I'd mount at "/mnt/fat" rather than "/mnt". But that's oldfashioned too.


Have a nice day :)

Thomas