4

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
2
  • 2
    Why not put your commands into a script and run that?
    – Panki
    Jan 12 at 15:37
  • it would still require root to do the mount command, which i don't feel I should need to just access the contents of an iso file. I really like the 7z x my.iso not sure it can get any better than that.
    – ron
    Jan 12 at 16:32
8

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.

1
  • 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 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/

2
  • 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 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. Jan 12 at 17:09
0

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.