익명 07:06

How to create a new partition inside a .bin file with Bash?

How to create a new partition inside a .bin file with Bash?

I'm trying to create a new partition inside a .bin file via a Bash script, but I have no clue what I'm doing.

For starters, I want to preface this by saying that I am not a Linux person. I have very limited knowledge on Linux stuff.

If it matters, the .bin file I'm trying to edit is specifically a Chrome OS RMA shim for the Zork board.

It contains of 12 partitions already, a bunch of different types of files, etc.

Anyways, in my research I believe I should be using sfdisk (as I want this to be automatically performed without user input), but I cannot find a clear and concise guide on how I would actually accomplish this.

Any guides, whether for sfdisk or something else entirely I should be using instead, would be greatly appreciated.



Top Answer/Comment:

If it matters, the .bin file I'm trying to edit is specifically a Chrome OS RMA shim

Yes, that matters.
Apparently that .bin file is the image of a storage drive (aka "disk" image). That means that the first 512-byte block must contain an MBR sector.

In order to manipulate such a drive image and modify its partition table, you could treat this file as if it were the device node for a storage drive (e.g. /dev/sda). So a command such as parted /dev/sda can be replaced with parted <my drive image file>.

BTW referring to this drive image file as just a .bin is confusing because more often a .bin refers to an executable file or simply an unspecified non-text file.

I'm trying to create a new partition inside a .bin file ...

the root directory already has all the shim stuff in it

Avoid conflating the concepts of partition and filesystem; they are actually two distinct concepts, and implemented/handled by different layers in the kernel.
The typical OS uses a partition as a container for a filesystem, e.g. ext4 or NTFS. A partition without an installed filesystem is not very useful.

상단 광고의 [X] 버튼을 누르면 내용이 보입니다