Unable to extract tar archive

I've just downloaded

https://downloads.openwrt.org/releases/21.02.0/targets/x86/64/openwrt-21.02.0-x86-64-rootfs.tar.gz

and am unable to extract various files from it. They show up using 'tar tf archive' but most of them won't extract.

Any ideas on what I can do?

$ LANG= wget https://downloads.openwrt.org/releases/21.02.0/targets/x86/64/openwrt-21.02.0-x86-64-rootfs.tar.gz
--2022-11-08 01:30:57--  https://downloads.openwrt.org/releases/21.02.0/targets/x86/64/openwrt-21.02.0-x86-64-rootfs.tar.gz
Resolving downloads.openwrt.org (downloads.openwrt.org)... 2a01:4f8:251:321::2, 168.119.138.211
Connecting to downloads.openwrt.org (downloads.openwrt.org)|2a01:4f8:251:321::2|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3972612 (3.8M) [application/octet-stream]
Saving to: 'openwrt-21.02.0-x86-64-rootfs.tar.gz'

openwrt-21.02.0-x86-64-ro 100%[==================================>]   3.79M  20.5MB/s    in 0.2s    

2022-11-08 01:30:57 (20.5 MB/s) - 'openwrt-21.02.0-x86-64-rootfs.tar.gz' saved [3972612/3972612]


$ sha256sum -b openwrt-21.02.0-x86-64-rootfs.tar.gz 
4b097e77a54c76e0e8c159e7658d09cee29fc016229a223b6a397d045a4dbda8 *openwrt-21.02.0-x86-64-rootfs.tar.gz

$ tar -xzf openwrt-21.02.0-x86-64-rootfs.tar.gz

$ echo $?
0

$ find . | wc -l
1196

$ LANG= dpkg -l tar gzip
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-========================================
ii  gzip           1.12-1       amd64        GNU compression utilities
ii  tar            1.34+dfsg-1  amd64        GNU version of the tar archiving utility
2 Likes

Thanks, but I wish I understood what you are telling me.

  1. download file from the server
  2. check sha256 checksum
  3. decompress downloaded tarball
  4. check for error codes (potentially) reported by tar (0 := success)
  5. count number of extracted directories/ files (plus the downloaded tarball itself)
  6. show versions of the used GNU tar, GNU gzip packages (current Debian/unstable)
  7. problems, zero - q.e.d.

Edit: 2) might be extended by also verifying the checksum:

$ wget -qO- https://downloads.openwrt.org/releases/21.02.0/targets/x86/64/sha256sums | grep 4b097e77a54c76e0e8c159e7658d09cee29fc016229a223b6a397d045a4dbda8
4b097e77a54c76e0e8c159e7658d09cee29fc016229a223b6a397d045a4dbda8 *openwrt-21.02.0-x86-64-rootfs.tar.gz

sha256 openwrt-21.02.0-x86-64-rootfs.tar.gz
SHA256 (openwrt-21.02.0-x86-64-rootfs.tar.gz) = 4b097e77a54c76e0e8c159e7658d09cee29fc016229a223b6a397d045a4dbda8

I'm using FreeBSD and am wondering if there is a problem with file permissions or uids/gids...

There's not 'just' GNU tar, BSD tar, star, etc. might show different behaviours in corner cases.

For actually using the to-be-decompressed rootfs, --numeric-owner, --selinux and --xattrs (as well as using uid=0 for 3.) might be worth considering as well.

1 Like

Perhaps you could explain how are you trying to extract it, and what errors are you receiving...

1 Like

I've tried GNU tar and BSD tar using tar zxf tarfile and they are both unable extract numerous files...

Using archivers/star I get:

star: Operation not supported. Cannot create symbolic link './usr/sbin/ntpd' to '../../bin/busybox'.
star: Operation not supported. Cannot create symbolic link './var' to 'tmp'.
star: Operation not supported. Cannot create symbolic link './www/cgi-bin/cgi-backup' to '../../usr/libexec/cgi-io'.
star: Operation not supported. Cannot create symbolic link './www/cgi-bin/cgi-download' to '../../usr/libexec/cgi-io'.
star: Operation not supported. Cannot create symbolic link './www/cgi-bin/cgi-exec' to '../../usr/libexec/cgi-io'.
star: Operation not supported. Cannot create symbolic link './www/cgi-bin/cgi-upload' to '../../usr/libexec/cgi-io'.
star: Operation not supported. Cannot create symbolic link './www/luci-static/bootstrap-dark' to 'bootstrap'.
star: Operation not supported. Cannot create symbolic link './www/luci-static/bootstrap-light' to 'bootstrap'.
star: 1047 blocks + 0 bytes (total of 10721280 bytes = 10470.00k).
star: The following problems occurred during archive processing:
star: Cannot: stat 0, open 192, read/write 0, chdir 0, iconv 0.
star: Size changed 0.
star: Missing links 0, Name too long 0, File too big 0, Not dumped 0.
star: Skipped for security reason: path name 0, link name 14.
star: See option -secure-links on why some links have been skipped.
star: Processed all possible files, despite earlier errors.

Any ideas on how to overcome this?

and why are you doing this, exactly ?

what FS are you using on the destination drive ?

the image is to be written as it is, not extracted.

zcat openwrt-21.02.0-x86-64-rootfs.tar.gz > /dev/sdX

1 Like

How about just use plain ol' application tar?

star is for a tape drive

Numerous files?

Yea, as others noted you're doing something wrong.

Is there a reason you're using/need this file that you haven't yet explained?

This is a GNU Makefile with a set of scripts and configuration files that generates a bootable ISO file with a working Linux distribution. This minimal distribution gets completely loaded into memory.

you already have that file on hand (premade, not in an ISO format though ...),
but it doesn't "only" load into memory, for that you'd need a different kind of image.

you have no problem with openwrt tar. you don't have problem with freebsd's tar (bsdtar).
you want to run mfslinux tool which fails for some reason. is this the real problem?

if so i don't see why you seek help here and not at mfslinux.

( by the way you do not seem to follow the building instructions: according to doc 4 things are required on freebsd, star is not one of them. bsdtar is needed. but doc is incorrect anyway because you'll need gmake too.)

On FreeBSD tar is bsdtar.

The problem is the extraction of the archive on FreeBSD. Don't know why this happens as no such problem occurs under Debian.

I guess I'd better report this to the developer of mfslinux.

generates a bootable ISO file with a working Linux distribution

FreeBSD != Linux

this isn't an openwrt problem, not even a Linux problem, but FreeBSD.
you're barking up the wrong tree.

sure, please do.

( hint: bsdtar seems to work, i am using the default bsdtar. but there is/are other problem(s) with the tool.

note: my bad. it does say requires root. pls ignore it requires root access which is weird but probably acceptable due to linux64 module is used with chroot yet not documented.
but as you can see the package list is not up-to-date either.

$ freebsd-version
13.1-RELEASE-p3

$ tar --version
bsdtar 3.6.0 - libarchive 3.6.0 zlib/1.2.12 liblzma/5.2.5 bz2lib/1.0.8 libzstd/1.4.8

$ sudo gmake VERBOSE=1
echo "Removing packages"
Removing packages
/bin/mkdir -p /tank/.etc/mfslinux/work/openwrt_root/tmp/lock
if [ -f "/tank/.etc/mfslinux/config/openwrt_packages_remove" ]; then \
  PACKAGES_REMOVE=`/bin/cat /tank/.etc/mfslinux/config/openwrt_packages_remove`; \
else \
  PACKAGES_REMOVE=`/bin/cat /tank/.etc/mfslinux/config/default/openwrt_packages_remove`; \
fi; \
 env PATH="/usr/sbin:/usr/bin:/sbin:/bin" /usr/local/bin/opkg-cl --chroot /tank/.etc/mfslinux/work/openwrt_root oarch:1 --add-arch x86_64:10 --conf /etc/opkg.conf \
        remove $PACKAGES_REMOVE
Removing package luci-ssl from root...
Removing package luci from root...
Removing package luci-theme-bootstrap from root...
Removing package luci-proto-ppp from root...
Removing package luci-proto-ipv6 from root...
Removing package luci-mod-admin-full from root...
Removing package luci-app-firewall from root...
Removing package luci-mod-system from root...
Removing package luci-mod-status from root...
Removing package luci-mod-network from root...
Removing package luci-base from root...
Failed to connect to ubus
Removing package luci-lib-base from root...
Removing package luci-lib-ip from root...
Removing package luci-lib-jsonc from root...
Removing package luci-lib-nixio from root...
Removing package dnsmasq from root...
Failed to connect to ubus
Removing package uhttpd-mod-ubus from root...
Removing package uhttpd from root...
Failed to connect to ubus
Removing package liblucihttp-lua from root...
Removing package libustream-wolfssl20201210 from root...
/usr/bin/touch /tank/.etc/mfslinux/work/.remove_packages_done
if [ -f "/tank/.etc/mfslinux/config/openwrt_target_packages_add" ]; then \
  PACKAGES_ADD=`/bin/cat /tank/.etc/mfslinux/config/openwrt_target_packages_add`; \
else \
  PACKAGES_ADD=`/bin/cat /tank/.etc/mfslinux/config/default/openwrt_target_packages_add`; \
fi; \
PACKAGES_ADD=`echo $PACKAGES_ADD | /usr/bin/sed -e \
  "s,%%KERNEL_VERSION%%,5.4.179,g"`; \
for PKG in $PACKAGES_ADD; do \
if [ ! -f /tank/.etc/mfslinux/download/${PKG} ]; then \
echo "Downloading: ${PKG}"; \
cd /tank/.etc/mfslinux/download && /usr/bin/fetch -q \
        https://downloads.openwrt.org/releases/21.02.2/targets/x86/64//packages/${PKG}; \
if [ "$?" != "0" ]; then rm -f  /tank/.etc/mfslinux/download/${PKG}; exit 1; fi; \
fi; \
done; \
if [ -f "/tank/.etc/mfslinux/config/openwrt_packages_add" ]; then \
  PACKAGES_ADD=`/bin/cat /tank/.etc/mfslinux/config/openwrt_packages_add`; \
else \
  PACKAGES_ADD=`/bin/cat /tank/.etc/mfslinux/config/default/openwrt_packages_add`; \
fi; \
for PKG in $PACKAGES_ADD; do \
PKGNAME=`basename $PKG`; \
if [ ! -f /tank/.etc/mfslinux/download/${PKGNAME} ]; then \
echo "Downloading: ${PKG}"; \
cd /tank/.etc/mfslinux/download && /usr/bin/fetch -q \
        http://downloads.openwrt.org/releases/21.02.2/packages/x86_64//${PKG}; \
if [ "$?" != "0" ]; then rm -f /tank/.etc/mfslinux/download/${PKGNAME}; exit 1; fi; \
fi; \
done
Downloading: kmod-crypto-hash_5.4.179-1_x86_64.ipk
Downloading: kmod-crypto-null_5.4.179-1_x86_64.ipk
[..]
Downloading: base/libreadline8_8.1-1_x86_64.ipk
Downloading: base/zlib_1.2.11-4_x86_64.ipk
fetch: http://downloads.openwrt.org/releases/21.02.2/packages/x86_64//base/zlib_1.2.11-4_x86_64.ipk: Not Found
gmake: *** [Makefile:162: download_packages] Error 1 )
1 Like

packages have been updated, there's a lot of files that have been replaced, with newer versions.

1 Like

yes, that's why i wrote :slight_smile:

but anyway, this is not openwrt issue for sure.

corrected package list, replace config/default/openwrt_packages_add

base/uclibcxx_0.2.5-3_x86_64.ipk
base/terminfo_6.2-3_x86_64.ipk
base/libncurses6_6.2-3_x86_64.ipk
base/libreadline8_8.1-1_x86_64.ipk
base/zlib_1.2.11-6_x86_64.ipk
base/ca-certificates_20210119-1_all.ipk
base/libopenssl1.1_1.1.1q-1_x86_64.ipk
base/libustream-openssl20201210_2022-01-16-868fd881-2_x86_64.ipk
base/libfdisk1_2.36.1-2_x86_64.ipk
base/libmount1_2.36.1-2_x86_64.ipk
base/fdisk_2.36.1-2_x86_64.ipk
base/cfdisk_2.36.1-2_x86_64.ipk
base/sfdisk_2.36.1-2_x86_64.ipk
base/libevent2-core7_2.1.12-1_x86_64.ipk
base/libevent2-7_2.1.12-1_x86_64.ipk
base/libpopt0_1.16-2_x86_64.ipk
base/libpcap1_1.9.1-3.1_x86_64.ipk
base/tcpdump_4.9.3-4_x86_64.ipk
base/libbz2-1.0_1.0.8-1_x86_64.ipk
base/bzip2_1.0.8-1_x86_64.ipk
base/uuidgen_2.36.1-2_x86_64.ipk
base/mdadm_4.1-2_x86_64.ipk
base/losetup_2.36.1-2_x86_64.ipk
base/lsblk_2.36.1-2_x86_64.ipk
base/lscpu_2.36.1-2_x86_64.ipk
base/ethtool_5.10-1_x86_64.ipk
base/e2fsprogs_1.45.6-2_x86_64.ipk
base/resize2fs_1.45.6-2_x86_64.ipk
packages/iftop_2018-10-03-77901c8c-2_x86_64.ipk
packages/xfs-mkfs_5.9.0-2_x86_64.ipk
packages/xfs-growfs_5.9.0-2_x86_64.ipk
packages/xfs-fsck_5.9.0-2_x86_64.ipk
packages/xfs-admin_5.9.0-2_x86_64.ipk
packages/atftp_0.7.4-1_x86_64.ipk
packages/dmidecode_3.2-1_x86_64.ipk
packages/less_563-1_x86_64.ipk
packages/libkmod_27-2_x86_64.ipk
packages/libpci_3.8.0-2_x86_64.ipk
packages/pciids_0.359-1_x86_64.ipk
packages/pciutils_3.8.0-2_x86_64.ipk
packages/smartmontools_7.2-1_x86_64.ipk
packages/rsync_3.2.3-3_x86_64.ipk
packages/tmux_3.1c-1_x86_64.ipk
packages/ipmitool_1.8.18-5_x86_64.ipk
packages/netcat_0.7.1-2_x86_64.ipk
packages/bash_5.1-2_x86_64.ipk
packages/libuv1_1.40.0-3_x86_64.ipk
packages/libnghttp2-14_1.43.0-1_x86_64.ipk
packages/bind-libs_9.18.7-1_x86_64.ipk
packages/bind-host_9.18.7-1_x86_64.ipk
packages/bind-dig_9.18.7-1_x86_64.ipk
packages/libdevmapper_2.03.16-1_x86_64.ipk
packages/libaio_0.3.112-2_x86_64.ipk
packages/lvm2_2.03.16-1_x86_64.ipk
packages/libwrap_7.6-4_x86_64.ipk
packages/libtirpc_1.3.2-1_x86_64.ipk
packages/libkeyutils1_1.6.3-1_x86_64.ipk
packages/nfs-utils_2.5.2-1_x86_64.ipk
packages/dosfstools_4.1-4_x86_64.ipk
packages/ntfs-3g_2017.3.23-6-fuseint_x86_64.ipk
packages/libgpg-error_1.45-1_x86_64.ipk
packages/libgcrypt_1.8.7-2_x86_64.ipk
packages/ntfs-3g-utils_2017.3.23-6-fuseint_x86_64.ipk
packages/ntpclient_2015_365-4_x86_64.ipk
packages/libnetsnmp_5.8-2_x86_64.ipk
packages/snmp-mibs_5.8-2_x86_64.ipk
packages/snmp-utils_5.8-2_x86_64.ipk
packages/ifstat_1.1-3_x86_64.ipk
packages/liblzma_5.2.5-3_x86_64.ipk
packages/xz-utils_5.2.5-3_x86_64.ipk
packages/xz_5.2.5-3_x86_64.ipk
packages/tar_1.32-3_x86_64.ipk
packages/nano_6.4-1_x86_64.ipk
packages/vim_8.2-3_x86_64.ipk
packages/gdisk_1.0.6-1_x86_64.ipk
packages/cgdisk_1.0.6-1_x86_64.ipk
packages/sgdisk_1.0.6-1_x86_64.ipk
packages/cryptsetup_2.5.0-1_x86_64.ipk

you're welcome @balanga.

took < 10 sec to build the image, once the files were DLed.