Author Topic: Editing the contents of a PCLinuxOS ISO  (Read 593 times)

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 11057
  • MLUs Forever!
Editing the contents of a PCLinuxOS ISO
« on: January 18, 2013, 02:15:17 PM »




Edit an Existing ISO and Create your own ISO image of PCLinuxOS

Sometimes it is desirable to be able to add a few files to an ISO image to distribute to family and friends.
These files could be simple family videos or pictures or specific information which you feel should be available to them when they run the liveCD.

Most often we simply install the OS, make our changes, and then use “mylivecd” to create an ISO for us.

The following method, although requiring some terminal use, avoids the necessity of installing and remastering.

An overview:

Break out the ISO so you have access to the files and directories it contains.
Add files or edit existing files as you require.
Rebuild the ISO again incorporating your changes.

I have done this in my home partition which has plenty space to accommodate the expanded ISO.
You will probably need space for 5 x ISO size to be comfortable.
Please ensure you are not in danger of running out of space. Change the working directories if necessary.

As an example, the Full Monty ISO is approx 4GB. So this needs storage space somewhere ...  not necessarily on the working partition.
For editing FM you would need about 18.5GBs space on the working partition plus the space for your added files and space for your new ISO (another 4GBs plus added files).

It took approx an hour to build the FM squash file on this 4 core machine. (I hope it was one hour and not two  :D)


Procedure:  For this example I will use the pclinuxos-kde-minime-2012.12.iso
                   I will describe how I did it in KDE, so substitute other apps as appropriate.

Extract the ISO using Ark (or similar application) to a directory you create for the purpose .....  lets call it “mymini” under  /home/<my user name>/ .....  referred to from here on as   ~/mymini

In the commands below please substitute your actual /home/<your user name>/ for the ~/ to ensure the commands work correctly.

Open Dolphin and navigate to ~/mymini.
You should see  ...   boot and isolinux directories and a livecd.sqfs file.
That file contains the operating system files which you wish to access.
So we must in turn expand that file to get access.

Still in Dolphin, press F4 to bring up a terminal attached to the bottom of Dolphin.
'su' to root and confirm with password.
Ensure the terminal is located in the mymini directory .....  it should show 'mymini' as part of the prompt.
Issue the following command

unsquashfs -d unsquash livecd.sqfs

When the command finishes you will see a new directory in Dolphin, called “unsquash”

Make whatever changes you wish within this directory.

When ready, rename the livecd.sqfs file to original-livecd.sqfs

Then issue the following command

mksquashfs  unsquash  livecd.sqfs  -comp xz -Xbcj x86 -b 1048576

Due to using XZ compression this stage can take a while to complete.
If you choose to use no compression option when using mksquashfs the default gzip compression will be used.
You can omit all compression by using individual options such as -noI, -noD, -noF, -noX (see the man page), which will produce a loop image the same size as the unsquash directory and do so much more quickly.
This might be desirable when testing before producing your final ISO.

When this completes you will have a new livecd.sqfs file showing in Dolphin. You should now have
boot directory
isolinux directory
unsquash directory
original-livecd.sqfs file
livecd.sqfs file

Next you need to remove the original-livecd.sqfs and the unsquash directory, so at the terminal do

rm  -rf  unsquash original-livecd.sqfs


At this stage you are left with
boot
isolinux
livecd.sqfs

So you are ready to create your new ISO.
To do so issue the following command

mkisofs -l -R -J -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table  -hide-rr-moved -cache-inodes -no-bak -pad -v -v   -o  ~/my-iso.iso   ~/mymini/

Your new ISO will be created in your home directory and will be called  “my-iso.iso
If you do not substitute your user path for ~/, the ISO will be stored under /root/

Test the ISO to ensure all went well and your edits are present.

I have tested it in VBox only, so there might be some oddities I have not allowed for ....  please report if you find any, thanks.

That is it ...... except for cleaning up ......  so remove the ~/mymini  directory and its contents ....  

rm -rf   /home/<your user name>/mymini


******

The command options above might need adjusting, so if someone who is familiar with those options sees an error please post so I can correct it, thank you.

An explanation of some of the command options for mkiso:
(see man genisoimage)

-l    allow 31-character filenames
-R    Generate SUSP and RR records using the Rock Ridge protocol to further describe the files on the ISO9660 filesystem.
-J    Generate Joliet directory records in addition to regular ISO9660 filenames for Windows
-b    Specifies the path and filename of the boot image to be used when making an El Torito bootable CD for x86 PCs. (isolinux/isolinux.bin in PCLOS)

-hide-rr-moved  If genisoimage  is creating a filesystem image with Rock Ridge attributes and the directory nesting level of the source directory tree is too much for ISO9660, genisoimage  will do deep directory relocation. This results in a directory called RR_MOVED  in the root directory of the CD. You cannot avoid this directory. Using this option the directory can be hidden from view.

-no-emul-boot  If the boot image is not an image of a floppy, you need to add either -hard-disk-boot or -no-emul-boot.

-boot-load-size 4  Specifies the number of "virtual" (512-byte) sectors to load in no-emulation mode. The default is to load the entire boot file. Some BIOSes may have problems if this is not a multiple of 4.

-boot-info-table   Specifies that a 56-byte table with information of the CD-ROM layout will be patched in at offset 8 in the boot file.

-sort  Sort file locations on the media. Sorting is controlled by a file that contains pairs of filenames and sorting offset weighting. This option does not  sort the order of the filenames that appear in the ISO9660 directory. It sorts the order in which the file data is written to the CD image, which is useful in order to optimize the data layout on a CD. {this is used when making the original ISO}

-cache-inodes  Enable caching inode and device numbers to find hard links to files. If genisoimage finds a hard link (a file with multiple names), the file will also be hard-linked on the CD, so the file contents only appear once.

-pad   Pad the end of the whole image by 150 sectors (300 kB). This option is enabled by default.

-no-bak  Exclude backup files files on the ISO9660 filesystem; that is, filenames that contain the characters `~' or `#' or end in .bak. These are typically backup files for Unix text editors.

-o   Specify the output file for the the ISO9660 filesystem image. This can be a disk file, a tape drive, or it can correspond directly to the device name of an optical disc writer.
« Last Edit: January 31, 2013, 02:49:45 PM by Just17 »
MLUs rule the roost!

Linux XPS 3.4.48-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline Bald Brick

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6470
  • I'm going South
Re: Editing the contents of a PCLinuxOS ISO
« Reply #1 on: January 18, 2013, 02:31:42 PM »
That was a useful tip indeed.

 Thanks! :)
Feed the trolls!
They need it!

AMD Athlon 7450 Dual-Core Processor, 7.80 GiB RAM, Nvidia GeForce GT 120/PCIe/SSE2, OpenGL/ES-version: 3.3 0 NVIDIA 295.40, SBx00 Azalia (Intel HDA) soundcard, ‎Logitech B500 webcam, SAA7146 DVB card, HDDs: Seagate 250824AS, Western Digital WD10EAVS-00D

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 11057
  • MLUs Forever!
Re: Editing the contents of a PCLinuxOS ISO
« Reply #2 on: January 18, 2013, 02:35:22 PM »
That was a useful tip indeed.

 Thanks! :)

If you get a chance to try it please report back any errors.

Thanks  ;)
MLUs rule the roost!

Linux XPS 3.4.48-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 11057
  • MLUs Forever!
Re: Editing the contents of a PCLinuxOS ISO
« Reply #3 on: January 19, 2013, 06:58:39 AM »
Just a note to say that I have added options to the commands where I thought needed, and hope that now an ISO that is very close to the official spec ISO is produced.

It is likely I have forgotten something .....  hopefully someone will spot it and post  ;)

MLUs rule the roost!

Linux XPS 3.4.48-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline sling-shot

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1758
  • Satyameva Jayate | Truth Alone Triumphs.
Re: Editing the contents of a PCLinuxOS ISO
« Reply #4 on: January 19, 2013, 07:35:59 AM »
Bookmarked.

With your permission, once completely debugged, looks like a good candidate for a wiki article?
Packaging well will cure headaches of many :) But learning to package will cause headaches in many :(

AMD AthlonX2 3600+/ASUS M2NPV-VM/ATi HD4670/Onboard sound/3.5GB DDR2-533 RAM/SEAGATE 160+320GB HDD/DELL S2240L FullHD/Creative SBS370 2.1/PCLinuxOS2013/KDE4
Samsung NP305U1-A06IN | Nokia E6

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 11057
  • MLUs Forever!
Re: Editing the contents of a PCLinuxOS ISO
« Reply #5 on: January 19, 2013, 08:11:36 AM »
I need some feedback from a few who try it as well as from any of the devs who might wish to correct any errors.

From my tests it seems to work as is now .....  I added XZ compression to the command to bring it in line with the official ISOs.

MLUs rule the roost!

Linux XPS 3.4.48-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline gseaman

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3881
Re: Editing the contents of a PCLinuxOS ISO
« Reply #6 on: January 19, 2013, 11:48:23 AM »
Thank you. This is a valuable tip!

Galen

Offline wedgetail

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2469
  • Any Bugs in site?
Re: Editing the contents of a PCLinuxOS ISO
« Reply #7 on: January 21, 2013, 05:44:19 PM »
Using the options in line below, I have tested with success:
 
Quote
mkisofs -l -R -J -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table  -hide-rr-moved -cache-inodes -no-bak -pad -v -v   -o  ~/my-iso.iso   ~/mymini/

I did set up my own directory structure for "production run" which just made it easier to run off a series of ISO's. The test included 3 different versions and they all went through liveHDD generation, Installing to HDD from those, booting from HDD install fully update an quick use.

The ISO based on above options was further written to a CD-RW, booted and tested, this one accidentally fully updated forgetting that I did not have persistence selected, oh well.

This ISO was also transferred to make a bootable USB stick (would not fit a 2GB) of 4 GB size, tested on a Toshiba Tecra laptop which has easy boot selection on startop. The KDE32 worked really well, I was mildly surprised how quick it seemed to get up and running.  Why I make this comment is because I had live USB with KDE32-mini as well and to my surprise this seemed to take longer, but of course this worked too. The mini was on a Toshiba 2 GB stick.

Looking good  :)


 
« Last Edit: January 21, 2013, 05:57:22 PM by wedgetail »
32 bit: KDE (older) & various KDE-mini, ASUSTek P5P41D Rev X.0x, BIOS AMI0207 07/21/2009, "Pentium(R) Dual-Core CPU E5300 @ 2.60GHz", nVidia GeForce 9600 GT, 2x1GB Seagate Technology 1000528AS HDD
TV CompuPro VideoMate Vista E700 (not working in Linux), Acer X243HD LCD Screen

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 11057
  • MLUs Forever!
Re: Editing the contents of a PCLinuxOS ISO
« Reply #8 on: January 21, 2013, 06:05:46 PM »
Using the options in line below, I have tested with success:
 
Quote
mkisofs -l -R -J -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table  -hide-rr-moved -cache-inodes -no-bak -pad -v -v   -o  ~/my-iso.iso   ~/mymini/

I did set up my own directory structure for "production run" which just made it easier to run off a series of ISO's. The test included 3 different versions and they all went through liveHDD generation, Installing to HDD from those, booting from HDD install fully update an quick use.

The ISO based on above options was further written to a CD-RW, booted and tested, this one accidentally fully updated forgetting that I did not have persistence selected, oh well.

This ISO was also transferred to make a bootable USB stick (would not fit a 2GB) of 4 GB size, tested on a Toshiba Tecra laptop which has easy boot selection on startop. The KDE32 worked really well, I was mildly surprised how quick it seemed to get up and running.  Why I make this comment is because I had live USB with KDE32-mini as well and to my surprise this seemed to take longer, but of course this worked too. The mini was on a Toshiba 2 GB stick.

Looking good  :)


 

Thanks for the feedback .....   appreciated  ;)

Happy to know it has survived the various type of install/burning  :D

regards.
MLUs rule the roost!

Linux XPS 3.4.48-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 11057
  • MLUs Forever!
Re: Editing the contents of a PCLinuxOS ISO
« Reply #9 on: January 31, 2013, 02:49:00 PM »
As I believe this 'tip' is now complete I will lock this topic.

If some error is discovered please PM me or a mod to have the error corrected.

Thank you.

MLUs rule the roost!

Linux XPS 3.4.48-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT