LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-01-2014, 10:53 AM   #16
impact0r
LQ Newbie
 
Registered: Jun 2010
Posts: 24

Original Poster
Rep: Reputation: 0

Well, it worked for someone else so I would like to try it.
Which one would that be in schneidz's code line?
 
Old 02-01-2014, 11:01 AM   #17
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 912

Rep: Reputation: 174Reputation: 174
In schneidz's example, you would change the x'48' in the second byte (byte 1 indexed from 0) to x'49', that is, b'01001000' to b'01001001'

But I am pretty sure that is not going to work for you. The bit would need to be turned on in the response data that is returned for the SCSI Inquiry command, and that almost certainly comes from the USB internal firmware, which you can't edit, not from data that is stored on the device itself. I could be wrong, but that's what I think.


EDIT: Read this: http://www.prime-expert.com/articles...ge-devices.php

Last edited by Z038; 02-01-2014 at 11:03 AM.
 
Old 02-01-2014, 11:05 AM   #18
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326

Rep: Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920
Code:
byte#:0         1         2
      EB        48        90
      11101011  01001000  10010000 
bit #:76543210  76543210  76543210
...
not sure... my interpretation based on the microsoft website it should be x48 -> xc8.
 
Old 02-01-2014, 11:10 AM   #19
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 912

Rep: Reputation: 174Reputation: 174
Well, if you count the bits from the right, then you are correct, schneidz. I am a big-endian mainframe guy, so bits and bytes are numbered from the left (lower address to higher address). In other words, I would number this way:

Code:
byte#:0         1         2
      EB        48        90
      11101011  01001000  10010000 
bit #:01234567  01234567  01234567
...
Which would make it x'49'.
 
1 members found this post helpful.
Old 02-01-2014, 11:18 AM   #20
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326

Rep: Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920
Quote:
Originally Posted by Z038 View Post
Well, if you count the bits from the right, then you are correct, schneidz. I am a big-endian mainframe guy, so bits and bytes are numbered from the left (lower address to higher address).

Which would make it x'49'.
Code:
byte#:1         2         3
      EB        48        90
      11101011  01001000  10010000 
bit #:12345678  12345678  12345678
...

but if microsoft is considering byte-1 to be the first byte then xeb would remain the same in my example.
 
Old 02-01-2014, 11:19 AM   #21
impact0r
LQ Newbie
 
Registered: Jun 2010
Posts: 24

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Z038 View Post
Well, if you count the bits from the right, then you are correct, schneidz. I am a big-endian mainframe guy, so bits and bytes are numbered from the left (lower address to higher address). In other words, I would number this way:

Code:
byte#:0         1         2
      EB        48        90
      11101011  01001000  10010000 
bit #:01234567  01234567  01234567
...
Which would make it x'49'.
I still don't get it.
Quote:
00000000 FA B8 00 10 8E D0 BC 00 B0 B8 00 00 8E D8 8E C0 FB BE 00 7C ...................|
00000014 BF 00 06 B9 00 02 F3 A4 EA 21 06 00 00 BE BE 07 38 04 75 0B .........!......8.u.
00000028 83 C6 10 81 FE FE 07 75 F3 EB 16 B4 02 B0 01 BB 00 7C B2 80 .......u.........|..
0000003C 8A 74 01 8B 4C 02 CD 13 EA 00 7C 00 00 EB FE 00 00 00 00 00 .t..L.....|.........
The red one is 0x49. Is it really that far from the beginning? If I read your table right, then this is Byte 19, bit 2 and 3.

Last edited by impact0r; 02-01-2014 at 11:20 AM.
 
Old 02-01-2014, 11:29 AM   #22
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,196

Rep: Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044Reputation: 1044
In scheidz' /dev/sda the first byte is 0x48. So it is in mine. But it does not have to be that way on your device. He was using the 0x48 as an example.

Still, nowhere in the description of the MBR (and that really is the first bytes on your device) there is any reference to something which has to have a certain value on byte 1.
http://en.wikipedia.org/wiki/Master_boot_record

jlinkels
 
Old 02-01-2014, 11:44 AM   #23
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 912

Rep: Reputation: 174Reputation: 174
Quote:
Originally Posted by schneidz View Post
Code:
byte#:1         2         3
      EB        48        90
      11101011  01001000  10010000 
bit #:12345678  12345678  12345678
...

but if microsoft is considering byte-1 to be the first byte then xeb would remain the same in my example.

They are counting from 0, not from 1. They say "Bit 7 of byte 1 (indexed from 0) is the Removable Media Bit (RMB)."

With respect to bit and byte order on big versus little-endian systems, I found this article Byte and Bit Order Dissection from Linux Journal that says this:

Quote:
Bit order usually follows the same endianness as the byte order for a given computer system. That is, in a big endian system the most significant bit is stored at the lowest bit address; in a little endian system, the least significant bit is stored at the lowest bit address.
and gives this example:

Code:
Write Integer for Big Endian System

byte  addr       0         1       2        3
bit  offset  01234567 01234567 01234567 01234567
     binary  00001010 00001011 00001100 00001101
        hex     0a       0b      0c        0d

Write Integer for Little Endian System

byte  addr      3         2       1        0
bit  offset  76543210 76543210 76543210 76543210
     binary  00001010 00001011 00001100 00001101
        hex     0a       0b      0c        0d
I notice in your example that your bit and byte order are opposite from each other. To be honest, I am really only comfortable with big-endian ordering. In a little-endian context, I understand how integers are stored in memory, as in the example above, but I'm never really sure what is meant when someone gives an offset from a particular address on a little-endian system.

All this is academic. I don't believe the OP can flip the removable media bit by writing to the first two bytes of the device.

---------- Post added 02-01-14 at 11:45 AM ----------

Quote:
Originally Posted by impact0r View Post
I still don't get it.

The red one is 0x49. Is it really that far from the beginning? If I read your table right, then this is Byte 19, bit 2 and 3.
No, I was referring to the value of the second byte (byte 1), not the offset.

Last edited by Z038; 02-01-2014 at 11:48 AM.
 
1 members found this post helpful.
Old 02-01-2014, 11:54 AM   #24
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326

Rep: Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920
the shotgun approach would be to make the first few bytes of device xff's (but i am not sure what harm that would do).

also i was using calculator to convert hex -> bin and it shows the 0-bit on the rite.
Attached Thumbnails
Click image for larger version

Name:	Screenshot-Calculator.png
Views:	18
Size:	28.9 KB
ID:	14657  

Last edited by schneidz; 02-01-2014 at 12:02 PM.
 
Old 02-01-2014, 12:02 PM   #25
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 912

Rep: Reputation: 174Reputation: 174
Quote:
Originally Posted by schneidz View Post
the shotgun approach would be to make the first few bytes of device xff's (but i am not sure what harm that would do).
That would overwrite the first few bytes of the MBR. It will not accomplish the OP's goal.
 
Old 02-01-2014, 12:07 PM   #26
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326

Rep: Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920
Quote:
Originally Posted by Z038 View Post
That would overwrite the first few bytes of the MBR. It will not accomplish the OP's goal.
then lets overwrite the whole drive with xff's (<@)

to op: what microsoft probably intended was make sure this bit is equal to '1':
Code:
byte#:0         1         2
      EB        48        90
      11101011  01001000  10010000 
bit #:01234567  01234567  01234567
...
this is what my drive has as the first few bytes (yours will probably be different).

Last edited by schneidz; 02-01-2014 at 01:19 PM.
 
Old 02-01-2014, 12:12 PM   #27
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 912

Rep: Reputation: 174Reputation: 174
Quote:
Originally Posted by impact0r View Post
I need to write a zero on Bit 7 of byte 1 (indexed from 0) of my USB stick.

This is so that windows systems can see multiple partitions on it.

I have been trying to figure out a dd command to do that, but I can't make this out.

Any suggestions?

The removable media bit is not in a data area that you can access with the dd command or a hex editor. Some drive manufacturers provide a utility for flipping the bit, and some don't. See this link, as an example: http://superuser.com/questions/39117...ives-to-bootit



.
 
1 members found this post helpful.
Old 02-01-2014, 01:23 PM   #28
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326

Rep: Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920
Quote:
Originally Posted by impact0r View Post
I still don't get it.
Code:
00000000 FA B8 00 10 8E D0 BC 00 B0 B8 00 00 8E D8 8E C0 FB BE 00 7C ...................|
00000014 BF 00 06 B9 00 02 F3 A4 EA 21 06 00 00 BE BE 07 38 04 75 0B .........!......8.u.
00000028 83 C6 10 81 FE FE 07 75 F3 EB 16 B4 02 B0 01 BB 00 7C B2 80 .......u.........|..
0000003C 8A 74 01 8B 4C 02 CD 13 EA 00 7C 00 00 EB FE 00 00 00 00 00 .t..L.....|.........
The red one is 0x49. Is it really that far from the beginning? If I read your table right, then this is Byte 19, bit 2 and 3.
i see that the 0th byte of your drive is equal to xfa... maybe change it to xfb ?
 
Old 02-01-2014, 01:32 PM   #29
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326

Rep: Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920Reputation: 920
Quote:
Originally Posted by Z038 View Post
The removable media bit is not in a data area that you can access with the dd command or a hex editor. Some drive manufacturers provide a utility for flipping the bit, and some don't. See this link, as an example: http://superuser.com/questions/39117...ives-to-bootit



.
good point if this register is part of the microcontroller or eeprom of the device then it is not accessible by our means. we would need something similar to what the manufacturer uses to program that particular register.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration