Create DAT file

 
SOLVED
Go to solution
'chris'
Super Advisor

Create DAT file

hi

Howto compress files to *.dat file?

For example, I can decompress files from a ramdisk.dat using 7-Zip, but howto compress back to *.dat after changes?
16 REPLIES 16
Matti_Kurkela
Honored Contributor
Solution

Re: Create DAT file

".dat" is a very generic file extension, meaning something like "some special data, only the appropriate tools are expected to make sense of this". So it would be kind of important to know more about the context: where exactly did you get this file from?

Since you placed this question into Linux section of this forum, I assume this might be something Linux-related. In this case, the name "ramdisk.dat" suggests this might be a Linux boot-time initrd or initramfs (INITial Ram Disk/ RAM File System), or something else.

Initrd and initramfs are similar in purpose, but very different in structure. Initrd is a GZIP compressed disk image that contains a filesystem of some type: the type must match what's available in the kernel that is going to use it.

Depending on the type of the filesystem, you might be able to uncompress the file with gunzip and then mount it as a disk image in Linux: that would allow making changes to the disk image, sort of like if it was an USB stick or other removable media.

Some special-purpose (high-compression) filesystems won't allow write access: these filesystems must be "built" using a special tool, similar to creating .ISO images with the mkisofs/genisoimage command.

So if it's an initrd-style file, it will be necessary to identify the filesystem type, or find some documentation that lists the correct type.

Initramfs, on the other hand, is simply a GZIP compressed "cpio" archive. One reason for its design was to avoid the complexity of initrd.

The Linux kernel documentation includes the procedures for extracting initramfs files and creating new ones:
http://www.mjmwired.net/kernel/Documentation/filesystems/ramfs-rootfs-initramfs.txt

Googling for "ramdisk.dat" finds various targets, like Acronis TrueImage or Ultimate Boot CD. If your question is related to customizing one of these for your environment, please say so: we can neither read your mind nor take a peek into your system to find out what you're doing.

MK
MK
dirk dierickx
Honored Contributor

Re: Create DAT file

if you use the command 'file ' it will tell you what the actual format of that file is, so you can then recreate the file using the same compression method as the 'file' command told you it was.
'chris'
Super Advisor

Re: Create DAT file

# file -s ramdisk.dat
ramdisk.dat: gzip compressed data, was "ramdisk.dat.initrd", from FAT filesystem (MS-DOS, OS/2, NT), last modified: Mon Nov 10 02:00:20 2008

# file -i ramdisk.dat
ramdisk.dat: application/x-gzip

I've tried first to uncompress under linux using gzip, but it doesn't work:

# gzip -d ramdisk.dat
gzip: ramdisk.dat: unknown suffix -- ignored
Steven Schweda
Honored Contributor

Re: Create DAT file

> # gzip -d ramdisk.dat
> gzip: ramdisk.dat: unknown suffix -- ignored

man gzip

You could rename the file, or you could feed
it in from stdin.

gzip -dc < ramdisk.dat > ramdisk2.dat
'chris'
Super Advisor

Re: Create DAT file

Thx, but howto decompress files from ramdisk2.dat or mount it?
Steven Schweda
Honored Contributor

Re: Create DAT file

> Thx, but howto decompress files from
> ramdisk2.dat or mount it?

How did you make the thing? How should we
know more about what's in it than you do?

"mount -o loop [...]"?
'chris'
Super Advisor

Re: Create DAT file

I've done what u suggested:

# gzip -dc < ramdisk.dat > ramdisk2.dat

and I'd like to get (mount) all files from ramdisk2.dat.
Matti_Kurkela
Honored Contributor

Re: Create DAT file

Please run "file ramdisk2.dat" to try and identify the content inside the compression.

If it says just "data", that means the "file" command cannot identify it. If it says something like "cpio archive", it's most likely an initramfs: it cannot be mounted, but you can use the "cpio" command to extract (and later re-package) it: see my previous answer for a link to instructions.

If your Linux distribution has "fstyp" or "fsstat" available, you can try these commands too:

fstyp ramdisk2.dat
fsstat -t ramdisk2.dat

If the ramdisk2.dat is a filesystem image, either of these commands might be able to identify the filesystem type used in the image. That would help a lot in selecting the proper tools for modifying/rebuilding the file.

If it is a filesystem image, it can be mounted like this if the filesystem type is supported by your current Linux kernel:

mkdir -p /mnt/ramdisk
mount -o loop,rw ramdisk2.dat /mnt/ramdisk

If the filesystem won't support read-write access (cramfs, squashfs or similar), the mount command may fail. You may have to mount it read-only instead:

mount -o loop,ro ramdisk2.dat /mnt/ramdisk

If the mount command is successful, then you can view /proc/mounts to identify the filesystem type.

MK
MK
'chris'
Super Advisor

Re: Create DAT file

thx,

# fstyp ramdisk2.dat
#

# fstat ramdisk2.dat
USER CMD PID FD MOUNT INUM MODE SZ|DV R/W NAME

# mkdir -p /mnt/ramdisk
# mount -o loop,rw ramdisk2.dat /mnt/ramdisk
mount: you must specify the filesystem type

# mount -o loop,ro ramdisk2.dat /mnt/ramdisk
mount: you must specify the filesystem type