How to "losetup" in windows? (a tool for filesystem in a binary image file) - Page 1
Forum section: electronics / projects

author: Yansi
author_rank: Super Contributor
timestamp: October 21, 2015, 12:04:07 am
content: Hi guys,for simplification of embeded designs with filesystems, is there any tool for windows capable of creating/mounting a binary image of a filesystem in a single file (binary blob)?Let us consider I have some design including a NAND FLASH device, which I have a filesystem on. The design doesn't have any interface for bulk data transfers like SDcard, USB or so to copy the data from. The only means for moving the initial data into the NAND is by using an in-circuit programmer/debugger.It is quite easy to write a bunch of code as a "flashloader" for the NAND, so I am able to download a binary blob to the NAND with my JTAG programmer.So is there any software tool for windows (like "losetup" command in linux) which would help me to build the binary blob of the filesystem (including putting in the desired files) which I would later upload to the NAND?Maybe this question is too much specific or too much unspecific, so if I have not explained good enough, please tell me, I will try to fix it.I am sure such tool should be quite helpful also for other people, if you know about one, please share.Thank you for help.Yan

author: moffy
author_rank: Super Contributor
timestamp: October 21, 2015, 02:23:15 am
content: Maybe Winimage:http://www.winimage.com/winimage.htm?

author: amyk
author_rank: Super Contributor
timestamp: October 21, 2015, 02:33:48 am
content: What filesystem, specifically? Windows doesn't have "loopback" device support built into its driver model.

author: Jeroen3
author_rank: Super Contributor
timestamp: October 21, 2015, 05:25:22 am
content: You can probably binary dump a ramdisk.Or you binary copy an actual SD card or thumb drive with USBit.

author: Marco
author_rank: Super Contributor
timestamp: October 21, 2015, 06:07:12 am
content: There's RomFs for windows and FileDisk, the latter is more like losetup. RomFs is a virtualization layer and filesystem in one and a very simple one at that, which is probably what you want.http://www.acc.umu.se/~bosse/Embedded Lua might be interesting, it has RomFs build in.

author: newbrain
author_rank: Super Contributor
timestamp: October 21, 2015, 06:59:44 am
content: Windows, since W8 at least, has some directly accessible support for a loop device.This is limited to mounting .iso and .vhd(x).While the former is just a CD-ROM image, the latter can contain partitions with any supported filesystem (NTFS and the various flavors of FAT).As suggested by Jeroen3, you could also use a RAM disk (e.g.https://www.softperfect.com/products/ramdisk/).Any disk can then be dumped to a file using dd (http://www.chrysocome.net/dd).So, if you intend to use a Windows compatible FS (FATnn) you should be good to go with just a dd utility:- Create you RAM or virtual disk, format as (e.g.) FAT- Write your files- Dump the disk with ddIf, instead, you want to format the image with a different FS (and that might be the case for easier access from your device) I would really try to use a Linux VM (any time I tried installable FS in windows I had a bad experience...); W8 and later include Hyper-V, which works pretty well also with Linux, so no extra virtualization SW is needed.

author: Yansi
author_rank: Super Contributor
timestamp: October 25, 2015, 01:18:18 am
content: Hello,sorry for the late reply, I have been busy. I appreciate your suggestion, will look into them.I do not exactly need looped devices, just only the possibility to make a whole file system image stored in a file, which should be a binary image, so no vhd nor iso. Also I do not require the binary image file to be mounted in the OS, if there is just a win32 program that is capable of doing that on its own - that would be enough help!The losetup was only the example, because as far as I know this linux command has the functionality I need and I didn't know what better example I should choose.Thank you,Yan

author: nctnico
author_rank: Super Contributor
timestamp: October 25, 2015, 07:42:12 pm
content: There is a Windows tool for reading/writing SD card images. Google for something like that; I have used something like that several years ago but I cannot find it.

author: eas
author_rank: Frequent Contributor
timestamp: October 26, 2015, 06:02:27 pm
content: So I/we better understand your requirements and application, this is what I think you are saying:You'd like to streamline your Windows-hosted embedded development work.The embedded platform you are developing for has a (read only?) filesystem on a nand device.It is easy for you to make changes by writing an updated filesystem image to the nand by writing a binary blob.You are looking for an easier way to update the binary blob.To that end, you'd like to mount a file containing the binary blob as the windows equivalent of a block device.You'd like to mount that block device as a filesystem so you can read and write to it using standard windows filesystem tools/callsHave I got that all right? If so, and if the filesystem you are using is something that windows already supports (FAT,FAT32,VFAT,exFAT, NTFS), then really the key piece here is using a monolithic image file as its own block I/O device. I don't know, but I suspect that any tool that lets you read/write mount a disk image on Windows should do the job, provided it supports the simplest possible type of image file format, a monolithic file. I think .IMG files fit this criteria.

author: Yansi
author_rank: Super Contributor
timestamp: October 26, 2015, 09:32:57 pm
content: Yes, exactly right. But what tool can mount tha binary image? I don't know about any, thats why I am asking in the first placeIf you know about one, please tell us!ThanksYan

author: eas
author_rank: Frequent Contributor
timestamp: October 27, 2015, 02:49:39 am
content: Google for "windows mount disk img" turned up a bunch of options, including this one, which claims to read and write IMG files:http://www.osforensics.com/tools/mount-disk-images.htmlI've never used it, so I can't vouch for it.

author: Yansi
author_rank: Super Contributor
timestamp: October 27, 2015, 05:05:03 pm
content: Seems definitely interesting, worth a try maybe, but not sure if I can create images with it. The tool seems only to be able to read existing and investigate them.

author: Marco
author_rank: Super Contributor
timestamp: October 27, 2015, 05:28:41 pm
content: Filedisk and the ramdisk approach will do what you want for FAT32, cygwin has genromfs I think (for if you don't want to implement fat32 on the micro).

author: eas
author_rank: Frequent Contributor
timestamp: October 27, 2015, 06:33:49 pm
content: Quote from: Yansi on October 27, 2015, 05:05:03 pmAn image is just a binary file, so you just need a file with the proper size. Once you have the file, mount it, then create a partition table, then format it with your file system and zero it out.If you already have an image from linux or some other source, copy it over to windows, add the .IMG file extension, and try mounting it. If you don't, one option is to install this port of dd. Then use it to copy from its built in emulation of /dev/zero to a new file. Use the count= option to limit to the size you need (note that it interprets the value you set as blocks, not bytes), otherwise it will keep going until it has filled the disk.