Linux bin image file

How to view a binary file?

From what I understand, a compiler makes a binary file that consists of 1’s and 0’s that a CPU can read. I have a binary file but how do I open it to see the 1’s and 0’s that are there? A text editor says it can’t open it. P.S. I have an assembly compiled binary that should be plain binary code of 1’s and 0’s?

no — OP specified «assembly compiled binary». That does not address the question. For instance, it’s not a music file, and it has structure. Without OP providing additional information, an unstructured tool is the place to start.

See my answer. And be warned that the term binary is used in two ways totally different in practice : «A binary file» means a file whose context is not pure ASCII-text. «A binary number» means a number written using its binary form.

You’re not going to get what you’re asking for. On a hard drive, the file is represented by magnetic changes. When the file is read, it’s turned into electrical pulses, which in turn are turned into binary by the processor. Binary itself is only a representation of a number as stated in the answers below. These numbers are then interpreted by the individual programs as the format expected by them, whether this is text or images or something different. You won’t see 1s and 0s by opening a binary file in nano.

11 Answers 11

unless you want to edit it of course. Most Linux distros have hexdump by default (but obviously not all).

Update

xxd does both binary and hexadecimal

For bin :

Various people have answered some aspects of the query, but not all.

All files on computers are stored as 1’s and 0’s. Images, text files, music, executable applications, object files, etc.

They are all 0’s and 1’s. The only difference is that they are interpreted differently depending upon what opens them.

When you view a text file using cat , the executable ( cat in this case) reads all the 1’s and 0’s and it presents them to you by converting them into characters from your relevant alphabet or language.

When you view a file using an image viewer, it takes all the 1’s and 0’s and turns them into an image, depending on the format of the file and some logic to work it all out.

Читайте также:  Alpine linux настройка wifi

Compiled binary files are no different, they are stored as 1’s and 0’s.

arzyfex’s answer gives you the tools to view those files in different ways, but reading a file as binary works for any file on a computer, as does viewing it as octal, or hex, or indeed ASCII, it just might not make sense in each of those formats.

If you want to understand what an executable binary file does, you need to view it in a way which shows you the assembler language (as a start), which you can do using,

which is a disassembler, it takes the binary content and converts it back into assembler (which is a very low level programming language). objdump is not always installed by default, so may need to be installed depending on your Linux environment.

NB: as @Wildcard points out, it’s important to note the files don’t contain the characters 1 and 0 (as you see them on the screen), they contain actual numeric data, individual bits of information which are either on (1) or off (0). Even that description is only an approximation of the truth. They key point is that if you do find a viewer which shows you the 1’s and 0’s, even that is still interpreting the data from the file and then showing you the ASCII characters for 0 and 1. The data is stored in a binary format (see the Binary number link above). Pierre-Olivier’s community wiki entry covers this in more detail.

Источник

Extract a .bin disk image file under GNU/Linux

Binary image files (.bin) are a type of disk image format similar to the more common .iso format. They’re a type of container file that when extracted or mounted will provide access to their content.

If you search online for how to manage these files under Linux you’ll see a lot of articles stating that you can simply execute the file thus ./filename.bin . This is because .bin files are commonly executable files on the *nix platform. However, in the case of .bin disk image files this will not work.

Here’s how we crack open these files from the terminal. It’s a straightforward process that involves converting the bin file to an ISO file and then mounting the ISO.

  1. Create a .cue file if you don’t have one.
  2. Install bchunk
  3. Convert the .bin to .iso using bchunk.
  4. Mount the .iso file.
  5. View the iso content.
  6. Unmount the iso when complete.

The code below assumes all files are in your home directory. Make sure you have space in your home directory for both the bin file and the converted iso file.

Step 1: You’re going to need the associated .cue file but you may only have the .bin file. No guarantee this will work but you can try creating a cue file with the content below (make sure you change the FILENAME placeholder). Save this file alongside your .bin file with the same name i.e my-file.cue and my-file.bin .

FILE "FILENAME.bin" BINARY TRACK 01 MODE1/2352 INDEX 01 00:00:00
sudo apt-get install bchunk

Step 3: Convert the .bin to .iso. Make sure you get the arguments in the correct order.

bchunk ~/your-file.bin ~/your-file.cue ~/your-file.iso

Step 4: Create a mount point and mount the iso image.

sudo mkdir /mnt/iso sudo mount -o loop ~/your-file.iso /mnt/iso

Step 5: Browse the content of your original bin.

Читайте также:  Remove files linux command line

Step 6: Once you’ve finished with the iso just unmount it

Extract a .bin disk image file under GNU/Linux was published on February 05, 2017 .

You might also enjoy (View all posts)

Источник

How to create USB flash «.bin» image in Linux without physical drive

I have some files in Linux, which I have to copy to multiple SD-cards in Windows periodically (not bootable, but with file permissions, filesystem ext3 ). Now the procedure is: I copy files to one flash drive under Linux, then create a .bin image from this drive and clone this .bin to other USB-drives under Windows. Files sometimes change, so I need to create .bin file again. The idea is to create .bin files without actually using physical drive. Is there a solution to create USB-drive images virtually? Or is there a tool to burn ext3 USB-flash drives from tag.bz2 file under Windows?

1 Answer 1

The obvious solution is to mount the image directly in Linux and make the changes but there is a small problem. These media are partitioned a similar way as a hard drive. The solution is to mount the right partition from the image.

Check that the image is indeed partitioned:

$ file -k OpenELEC-RPi.arm-4.95.1.img OpenELEC-RPi.arm-4.95.1.img: x86 boot sector; partition 1: active, starthead 32, startsector 2048, 262145 sectors; partition 2: starthead 146, startsector 266240, 65537 sectors 

Working with the image

Map the partitions from the image to loop devices:

$ sudo kpartx -av OpenELEC-RPi.arm-4.95.1.img add map loop0p1 (252:3): 0 262145 linear /dev/loop0 2048 add map loop0p2 (252:4): 0 65537 linear /dev/loop0 266240 

On Ubuntu kpartx is not installed by default. Do sudo apt-get install kpartx .

$ sudo mount /dev/mapper/loop0p1 /mnt/tmp1 

Now make your changes in the /mnt/tmp1 directory.

Umount the partition and delete the mapping:

$ sudo umount /dev/mapper/loop0p1 $ sudo kpartx -dv OpenELEC-RPi.arm-4.95.1.img del devmap : loop0p2 del devmap : loop0p1 loop deleted : /dev/loop0 

Other options

If kpartx is not available you can determine the partition offset using for example fdisk (It works on images too so you can create the image without having a physical drive at all.) and map them using losetup or mount -o loop,offset=x or even the new version of losetup (from util-linux 2.21) can map the partitions directly using the option —partscan .

Читайте также:  Linux open source applications

There are descriptions in other questions:

Источник

How to mount a .bin image file in linux

According to file -k , you have a disk image (may be it is splitted into two volumes); the disk image has partition table of one 2TB (39G sectors of 512 = 2TB) and of type FAT32 (0x0b).

Do a cat to concatenate both images into one

OR (carefull! this will modify first file)

Run a kpartx to read partition table over image.iso via loop1 device (now you will need a root; replace image.iso with image*0000* if you did a second way of cat ting)

losetup /dev/loop1 image.iso; kpartx -av /dev/loop1; 

Output will be like add map loop1p1 .

Then find the loop1p1 in /dev/mapper

ls -l /dev/mapper file -sk /dev/mapper/* # finally check that it is a FAT32 
mount -o ro -t auto /dev/mapper/loop1p1 /where/to/mount 

Work with fs; umount it; run a kpartx -d -v /dev/loop1; ; unmap loop1 with losetup

Solution 2

Try to mount it with the -o loop option.

Solution 3

Convert the file to an ISO and work with it from there. I’ve used iat (Iso9660 Analyzer Tool) with success.

Install it (under Ubuntu where I live — YMMV):

iat inputFile.bin > newShiny.iso 

Solution 4

How to install .bin file in linux/ubuntu

How to mount / umount an ISO file in Linux Ubuntu using terminal (100 % Working)

How To Mount An Image File in Linux

How to mount iso in linux

DevOps & SysAdmins: How to mount a .bin image file in linux? (4 Solutions!!)

UltimateBrent

UltimateBrent

Updated on September 18, 2022

Comments

UltimateBrent

I used the AWS import service to import a large (2TB) drive, and they dropped two .bin files in my S3 account. Their instructions say to stripe together to EBS volumes to make a drive large enough to hold the image and then to just use that. Well I’ve got everything striped and whatnot, but I don’t know what to do with this .bin image. Doesn’t seem to work with mount , or at least, not without any options, and I don’t know what options to put.

>file -k image-NPX7P-0000.bin image-NPX7P-0000.bin: x86 boot sector; partition 1: starthead 1, startsector 63, 3907024821 sectors, extended partition table (last)\011, code offset 0x0 >file -k image-NPX7P-0001.bin image-NPX7P-0001.bin: data 

EDIT: I appended the file info, and from the looks of it, I’d assume the reason I can’t mount just 0000 is because 0001 is an extension of it (which tracks with how I assume they did this). But how would I merge the two and mount that? EDIT2: Using osgx’s answer, I was able to get the two bin files catted together, and used kpartx to read the partition table.

> file-sk: /dev/dm-2: x86 boot sector, code offset 0x58, OEM-ID "BSD 4.4", sectors/cluster 64, heads 255, sectors 3907024821 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 476816, reserved3 0x1000000, reserved 0x1, serial number 0x5cb415f7, label: "SOURCE-PSE " DOS executable (COM), boot code – 

Источник

Оцените статью
Adblock
detector