From Mageia wiki
Jump to: navigation, search


Please note!
This is a copy of an old document from former wiki It still refers to Mandriva, but in general it still applies and makes it possible to extract and change a Mageia Live Iso and recreate a bootable image from it again (commonly referred to as remastering). It definitely needs adapting, but should mostly work as described.

HowTo Customize Your Own Mandriva One

An implementation of an older article by MIB (Mandriva International Backports), (Updated and improved by tigger-gg and wobo for Mandriva Linux 2010 Spring)

This howto shows how you can change the contents of a Mandriva One 2010.1 and customize it to your own needs. It consists of several steps which should be carried out in the same order as they are written in the howto:

  • Create the infrastructure: Create a working directory where you do everything from start to finish.
  • Download and install: Download the original ISO image and install the required software
  • Unpacking and chroot: Unpack the original ISO image, save files which are needed later, and make the unpacked system your working system
  • Tasks in the chroot environment: Configure and customize the new system to your liking, it will become the resulting ISO image of this howto.
  • Post-production and Clean-up: Leave the new system and clean-up
  • Create the new ISO image: Pack the new system into an ISO image and make it hybrid to be burned to a CD/DVD or transferred to a USB key

Let's start!

0. Requirements and paths used in this HowTo

  • ISO image file of one of the Mandriva One editions (in this howto we used 2010 Spring ONE-KDE)
  • At least 5GB free space in the /home partition on your harddisk to build the new ISO image

The working directory will be created below the user's home directory. If your user is called wobo then your working directory is /home/user/wobo/isowork. Everything in this howto is happening in this directory and below. Of course you can go your own way but make sure that you will adopt your own directory structure to the howto then.

1. Creating the infrastructure and downloading the original ONE

Open a terminal window. The following commands will create your work folder, download the ISO image and install the tools we need:

mkdir isowork
cd isowork
wget -c
 [give root password when prompted]
urpmi isomaster squashfs-tools squashfs3-tools syslinux

You can use another mirror, and another Live image.

2. Unpacking the image and chroot

Now start isomaster from the terminal window (you are still root!):

isomaster &

In the upper section use the „Back“ button to navigate to the new folder isowork/ (navigation works as in the usual file selection GUIs). Doubleclick on the image file mandriva-linux-one-2010-spring-KDE4-europe1-americas-cdrom-i586.iso. This will show the contents of the image file in the lower section of isomaster. In the lower section doubleclick on loopbacks, mark the file distrib-lzma.sqfs and click on the „Unpack“ button in the menue. This may take a while. After this has been done change into your terminal window but leave isomaster open.

Now we unpack the squashfs file, it contains the complete operating system.

unsquashfs distrib-lzma.sqfs

Now before we go into the unpacked system we will save some files of the original ISO image for later use:

mkdir file_save
mkdir file_save/etc
mkdir file_save/etc/shorewall
mkdir file_save/etc/sysconfig
cp -r squashfs-root/var/lib/shorewall file_save/
cp squashfs-root/etc/hosts file_save/etc/hosts
cp squashfs-root/etc/modprobe.conf file_save/etc/modprobe.conf
cp squashfs-root/etc/modprobe.preload file_save/etc/modprobe.preload
cp squashfs-root/etc/wpa_supplicant.conf file_save/etc/wpa_supplicant.conf
cp squashfs-root/etc/shorewall/interfaces file_save/etc/shorewall/interfaces
cp squashfs-root/etc/sysconfig/network file_save/etc/sysconfig/network

As last step before you change into the subdirectory of the unpacked system you want to cut an existing network connection of your running system. This is essential if you want to use a network connection while customizing your new system. Then you change into the subdirectory and make it your root system (aka chroot).

service network stop  
cd squashfs-root
mount -o bind /dev ./dev
mount -o bind /proc ./proc
mount -o bind /sys ./sys
chroot /complete/path/to/isowork/squashfs-root /bin/bash

Explanation "chroot" in Wikipedia

Explanation of "SquashFS" in Wikipedia

3. Configuring and Customizing

Now you are logged in as root to you virtual installation of Mageia KDE, you are already working inside this system. First you may want to configure and start your network connection. Use the Mageia Control Center to do this




You see the text version of the MCC in your terminal window - use the arrow keys to navigate to Network & Internet, then push the TAB key to go to OK and hit the Enter key. Then select the kind of connection and go on from that.

After your network connection is up and running you can set the package media as you would do after a normal installation. Use a webtool like SmartUrpmi or the standard mirrorlist. To set up the complete set you only need these command line:

urpmi.addmedia --distrib --mirrorlist 

Now you are set to go: roll your own flavor of Mageia Linux! Install and remove what you need and what you don't want. A good way to start is removing all the language packages you will never need plus a few applications you know you never use. In my case this are all languages except German and English (as fallback), Firefox, Amarok and some more.

urpme -a locales-el locales-es locales-it locales-fr locales-nl locales-pl locales-pt locales-ru locales-tr firefox amarok compiz metisse ekiga evolution kopete ktorrent kmail kontact totem isdn4k slmodem kppp tvtime lancelot
urpmi task-kde4 --no-suggests

Certainly your mileage may vary and to each his own and all those sayings apply. The only restriction is the size of the resulting ISO image. If you want to burn it to a CD you have to keep the 700MB mark in mind.

4. Leaving chroot

When you are done and before you leave the chroot environment you have to stop the internet connection. Then you unmount the system links and - being back in your real system you want to restart your networking.

service network stop
umount ./dev
umount ./proc
umount ./sys
service network start

5. Postproduction, Clean-up

There are some files which have to removed from the new system. If you have a wifi connection, in the directory squashfs-root remove all files in the directory etc/sysconfig/network-scripts/wireless.d

rm etc/sysconfig/network-scripts/wireless.d/*

Then remove the following files in the directory squashfs-root:

rm etc/sysconfig/network-scripts/ifcfg-wlan0
rm root/bash_history
rm var/run/
rm var/lock/subsys/shorewall
rm var/lib/rpm/installed-through-deps.list.old
rm var/lib/dhcp/dhclient-wlan0.leases
rm var/lib/shorewall/firewall

Now we will copy the original files we saved to the directory file_save and overwrite the files in squashfs-root/:

cp -r ../file_save/shorewall var/lib/
cp ../file_save/etc/hosts etc/hosts
cp ../file_save/etc/modprobe.conf etc/modprobe.conf
cp ../file_save/etc/modprobe.preload etc/modprobe.preload
cp ../file_save/etc/wpa_supplicant.conf etc/wpa_supplicant.conf
cp ../file_save/etc/shorewall/interfaces etc/shorewall/interfaces
cp ../file_save/etc/sysconfig/network etc/sysconfig/network


6. Creating the new Image

At last we pack the new system to a SquashFS file which can take some time. Make sure that you are in the correct directory:

cd /home/user/isowork/squashfs-root
mksquashfs * distrib-lzma.sqfs -comp xz -noappend -no-progress -info -b 1048576

Now go to the still open isomaster. In the lower section and remove the old file distrib-lzma.sqfs by clicking on „Remove“ in the menue. In the upper section navigate into /isowork/squashfs-root and select the new distrib-lzma.sqfs and click on „Add“. When this is done open the „File“ menue and select Save under…. Chose a place to store the new ISO image and give a meaningful name. Click on OK and you're done!

But the resulting .iso file still belongs to root. Change this with

chown user:user name.iso

where user:user is your username and the group of your user and name.iso is the ISO image.

If you want to use your ISO image from a USB key you have to make it hybrid. As user change to where the file was stored and write the command:

isohybrid -o 1 NAME_OF_THE_ISO_FILE.iso

Now you can burn the file to a CD or DVD or transfer it to a USB key. The latter is done by root:

dd if=NAME_OF_THE_ISO_FILE.iso of=/dev/sdX

where sdX stands for the device name of your USB key which you can find out with

fdisk -l

Now we have arrived at the most important step: Test and Enjoy!

Note: Option -o 1 added to isohybrid command, to avoid triggering bug 5036