5

Is there a way to extract the contents of an ISO image file to a folder in one step?

I have been doing this and want to do less typing, and not to have to do the mount -o loop as well as the need to be root to do the mount command to access the ISO image contents:

cp rhel-server-7.6-x86_64-dvd.iso /home/ron/
mkdir /home/ron/temp
mount -o loop /root/rhel-server-7.6-x86_64-dvd.iso /home/ron/temp
mkdir /home/ron/rhel7.6dvd
mv /home/ron/temp/* /home/ron/rhel7.6dvd
rmdir /home/ron/temp
ron
  • 6,575

3 Answers3

9

There's multiple programs that can just treat an ISO-9660 file as an archive. 7z is a popular one: 7z x yourfile.iso works.

If this is a modern Linux with a user session manager running, udisksctl loop-setup -f yourfile.iso is a way to get your file into a loop device, and consequently automounted.

Also:

mv /home/ron/temp/* /home/ron/rhel7.6dvd

that line must be throwing a lot of errors: a mounted ISO image is read-only, so you can't move things away from it. cp instead.

  • 3
    note: for anyone doing the 7z x my.iso it explodes the contents into the current folder, which can be problematic. So make an empty subfolder first and then execute 7z from within that empty subfolder. No different than doing a tar -xf for example. – ron Jan 12 '22 at 16:34
5

osirrox -indev rhel-server-7.6-x86_64-dvd.iso -extract / /home/ron/rhel7.6dvd

osirrox is a special invocation of the xorriso tool.

https://www.gnu.org/software/xorriso/

virullius
  • 1,146
  • 2
  • 10
  • 19
  • 1
    this works. but gonna mark the 7z x my.iso one as correct since it was the least amount of typing. I was able to yum install xorriso on RHEL 7.9 with having the EPEL repository available. Thanks for the suggestion, always nice to find a new linux tool. – ron Jan 12 '22 at 16:24
  • seconding that, even have xorriso installed, but for the love of it couldn't remember how to find it ^^". Have a very well-deserved upvote. – Marcus Müller Jan 12 '22 at 17:09
2

Users running FreeBSD can:

mkdir /home/ron/rhel7.6dvd
tar xpf rhel-server-7.6-x86_64-dvd.iso -C /home/ron/rhel7.6dvd

Other BSDs might support this as well, but I'm not sure.

Jim L.
  • 7,997
  • 1
  • 13
  • 27