file command does not recognise xz archives

General support questions
Post Reply
Moray
Posts: 63
Joined: 2008/02/28 17:38:08
Location: England

file command does not recognise xz archives

Post by Moray » 2012/06/11 13:32:41

In CentOS 6.2 (minimal install, at least), file(1) does not recognise xz archives:

[code]# file initrd.img
initrd.img: data[/code]

Expected result: something along the lines of
[code]#file initrd.img
initrd.img: xz LZMA compressed archive[/code]

Is that a CentOS, Upstream Vendor, or Fedora bug?

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: file command does not recognise xz archives

Post by TrevorH » 2012/06/11 13:45:44

Works for me. My /boot/init* files are not in xz format however so I had to xz an existing file to test with and that came back and said

[code]
$ file modes.txt.xz
modes.txt.xz: xz compressed data
$ mv modes.txt.xz modes.txt.img
$ file modes.txt.img
modes.txt.img: xz compressed data
[/code]

Moray
Posts: 63
Joined: 2008/02/28 17:38:08
Location: England

Re: file command does not recognise xz archives

Post by Moray » 2012/06/11 14:16:10

Ah. Naturally.

[code]$ echo Hello | xz -c | file -
/dev/stdin: xz compressed data[/code]

but

[code]$ echo Hello | xz -c --format=lzma | file -
/dev/stdin: data[/code]

The specific format that [url=http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/6.2_Release_Notes/installation.html]they use[/url] is the very one that it can't identify.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: file command does not recognise xz archives

Post by TrevorH » 2012/06/11 15:34:26

Mine are still in gzip format

[code]
# file /boot/initramfs-2.6.32-220.*
/boot/initramfs-2.6.32-220.13.1.el6.x86_64.img: gzip compressed data, from Unix, last modified: Fri Apr 20 01:43:30 2012, max compression
/boot/initramfs-2.6.32-220.17.1.el6.x86_64.img: gzip compressed data, from Unix, last modified: Wed May 30 10:34:48 2012, max compression
/boot/initramfs-2.6.32-220.7.1.el6.x86_64.img: gzip compressed data, from Unix, last modified: Wed Mar 14 23:27:52 2012, max compression
[/code]

Moray
Posts: 63
Joined: 2008/02/28 17:38:08
Location: England

Re: file command does not recognise xz archives

Post by Moray » 2012/06/11 15:48:22

The initramfs files on the running system are, but the initrd file on the install CD isn't:

[code]# mount /dev/cdrom /mnt
# file /mnt/isolinux/initrd.img
/mnt/isolinux/initrd.img: data[/code]

Although according to [url=http://svn.python.org/projects/external/xz-5.0.3/doc/lzma-file-format.txt]The .lzma File Format[/url] it might be quite difficult to get file(1) to recognise the .lzma. There is no specific header sequence as there is for .xz, just a variable sequence of property data. That might make this a feature, not a bug.

Post Reply