TurnKey Linux Virtual Appliance Library

Converting a virtual disk image: VDI or VMDK to an ISO you can distribute

Why would anyone in their right mind want to convert a VM into an ISO?

Good question, the answer for Conor Fox (who was the inspiration for this post - thanks Conor!) was to distribute his customized TurnKey PostgreSQL image so others could use it.

Distributing an ISO as opposed to a VM image allows it to be installed on any virtualization platform, as well as on bare metal, with the added bonus of running live.

I suppose that's a good enough reason, so lets get to it.

Convert VM disk to raw image and mount it

First we need to get qemu-img, a tool bundled with qemu (KVM's virtualization backend) to convert the VM disk to a raw image, and TKLPatch, the TurnKey customization mechanism to package the ISO.

If you are not using a TurnKey installation, see the TKLPatch installation notes.

apt-get install qemu
apt-get install tklpatch

I'll show how to convert a VMWare VMDK image into raw disk format. If you are using a different virtualization platform such as Virtualbox, see this post on converting a VDI to a raw image.

qemu-img convert -f vmdk turnkey-core.vmdk -O raw turnkey-core.raw

Next, mount the raw disk as a loopback device.

mkdir turnkey-core.mount
mount -o loop turnkey-core.raw turnkey-core.mount

GOTCHA 1: If your VM has partitions, it's a little tricker. You'll need to setup the loop device, partition mappings and finally mount the rootfs partition. You will need kpartx to setup the mappings.

loopdev=$(losetup -s -f turnkey-core.raw)

apt-get install kpartx
kpartx -a $loopdev

# p1 refers to the first partition (rootfs)
mkdir turnkey-core.mount
mount /dev/mapper/$(basename $loopdev)p1 turnkey-core.mount

Extract root filesystem and tweak for ISO configuration

Now, make a copy of the root filesystem and unmount the loopback.

mkdir turnkey-core.rootfs
rsync -a -t -r -S -I turnkey-core.mount/ turnkey-core.rootfs

umount -d turnkey-core.mount

# If your VM had partitions (GOTCHA 1):
kpartx -d $loopdev
losetup -d $loopdev

Because the VM is an installed system as opposed to the ISO, the file system table needs to be updated.

aufs / aufs rw 0 0
tmpfs /tmp tmpfs nosuid,nodev 0 0

GOTCHA 2: If your VM uses a kernel optimized for virtualization (like the one included in the TurnKey VM builds), you need to replace it with a generic kernel, and also remove vmware-tools if installed.

tklpatch-chroot turnkey-core.rootfs

# inside the chroot
apt-get update
apt-get install linux-image-generic
dpkg --purge $(dpkg-query --showformat='${Package}\n' -W 'vmware-tools*')
dpkg --purge $(dpkg-query --showformat='${Package}\n' -W '*-virtual')


Generate the ISO

Finally, prepare the cdroot and generate the ISO.

tklpatch-prepare-cdroot turnkey-core.rootfs/
tklpatch-geniso turnkey-core.cdroot/

Thats it!

Bonus: By default the ISO will boot automatically. If you want to include the TurnKey bootsplash and bootmenu, extract the cdroot from a TurnKey ISO and tell tklpatch-prepare-cdroot to use it as a template.

tklpatch-extractiso turnkey-core.iso
tklpatch-prepare-cdroot turnkey-core.rootfs/ turnkey-core.cdroot/
tklpatch-geniso turnkey-core.cdroot/

Ever needed to package a VM as a distributable ISO? Post a comment!

You can get future posts delivered by email or good old-fashioned RSS.
TurnKey also has a presence on Google+, Twitter and Facebook.


Guest's picture


Thats excellent Alon, thanks a million!  It wasn't easy was it?!  I'm snowed under right now but I'm really looking forward to trying this out once I'm back in "iso mode".

TKL just keeps on impressing me more all the time.

Alon Swartz's picture

Every once in a while...

Every once in a while it's fun to tackle an issue like this, so thanks for the inspiration. The gotcha's got me, so I assume they got others as well, which makes this post that much more interesting and useful.

Looking forward to your feedback once you emerge from the snow...
Guest's picture

Converting vmdk to iso

I am having a time with trying to get this to work. I have installed the core system, and all the programs, and continue to get the message (qemu-img: Could not open '/vtserver.icanreach.com/vtserver.icanreach.com-flat.vmdk'). I need some help.


Jeremy Davis's picture

Check your file path

and remember that Linux is case sensitive. Eg /somefolder/somefile is different to /SomeFolder/SomeFile. Also makesure the machine is not running.

T. Miles's picture

Not Resolved Yet.

I made sure of the file and directory, and results are the same. I'm completely lost at what the problem is? 

Jeremy Davis's picture

I'm all out of ideas sorry

I don't know enough about this process to be of any more help to you.

Guest's picture

I'm in the midst of trying

I'm in the midst of trying this and I just now slavishly followed the "GOTCHA 2" suggestion of replacing the VM-optimal kernel with a standard kernel.  However if the ISO is going to be used exclusively for VMs, would it make sense to skip this step?

Alon Swartz's picture

Virtual kernel does not include squashfs

The virtual kernel does not include squashfs support, so the resulting ISO won't be able to unpack the root filesystem, and the boot will fail.

Also, an ISO can be installed to bare-metal, so it doesn't make much sense to include the optimized virtual kernel even if it was possible (to be complete, it is possible with a couple of workarounds but not worth the effort, and possible side-effects).
Guest's picture

Another scenario


Thanks so much for such interesting articles!

I propose another tipical scenario:

- You install a GNU/linux OS at secondary (non bootable) partition on your windows box.

- After try and setup a lot of things you decide to move your Linux instalation to a virtual machine....

The question is:

¿How to convert your secondary nonbootable linux partition to a virtual machine bootable disk???




Alon Swartz's picture

Process should be very similar

I suppose (without thinking about it too much) that the process should be very similar, minus the VM conversion.

In general it should go something like this:

  • Mount the secondary drive/partition, and copy out the root filesystem
  • Tweak as needed for ISO configuration
  • Generate the ISO

I would be interested to know if you try this, and what the outcome is. Keep us updated.
Guest's picture

I had partial success with

I had partial success with this -- I was able to create an ISO that worked perfectly as a "Live CD".  I was able to run my appliance directly off the ISO.  The configuration console magically included a new "Install to Disk" option.  However when I tried this it got pretty far into the installation -- including seemingly copying the rootfs to the disk -- but then failed while trying to set up grub.

But I'll leave that to another post -- I think even the creation of the "Live ISO" was a good start!


Heres another couple of "gotchas" I experienced:

(1) Alon mentioned that you may find you have multiple partitions on your source VMDK.  In fact its probable that you will -- I certainly did on the Turnkey/Postgres-based VM I started with.  However I was using another TKL-based VM as the "working machine" to run the commands on and I had trouble installing kpartx here.  I switched to a Fedora host and was able to install kpartx ("yum install kpartx" iirc) and complete the rest of the procedure here.

(2) When I chrooted to apply the generic kernel to the rootfs, I found that I had no DNS (so apt-get couldn't find repositories).  The same might happen to you depending on how your network is set up.  Assuming the machine you're working on has working DNS, doing the following before you chroot should fix this:

cp /etc/resolv.conf turnkey-core.rootfs/var/run

 (the desired destination of resolv.conf is likely different on a non-TKL-based rootfs).

Hope that helps!  Heres the script I'm running to get as far as the chroot (its more-or-less as per Alon's directions except I've hardcoded the name of the partition in the loop device):


echo Setting up loop device...
losetup /dev/loop0 turnkey-core.raw 

echo Adding a partition device for each partition in the loop device...
kpartx -av /dev/loop0

echo Mounting the first partition \(ie the rootfs\)
mount /dev/mapper/loop0p1 turnkey-core.mount/

echo Copying the rootfs from the mounted partition to the new \(development\) copy of the rootfs
rm -fr turnkey-core.rootfs/
mkdir turnkey-core.rootfs/
rsync -a -t -r -S -I turnkey-core.mount/ turnkey-core.rootfs

echo Cleaning up the mounts and loopback device...
umount -d turnkey-core.mount/
kpartx -d /dev/loop0
losetup -d /dev/loop0

#echo Setting up name resolution on new rootfs \(need this during chroot\)
#cp /etc/resolv.conf turnkey-core.rootfs/var/run



Guest's picture

mount -o loop

mount -o loop turnkey-core.raw turnkey-core.mount


mount: you must specify the filesystem type



Alon Swartz's picture

Raw image has partitions?

Is it possible you were hit by GOTCHA 1, VM has partitions?
Guest's picture

bootspash menu

This is the correct way to install the bootspash menu 

tklpatch-extract-iso turnkey-core-2009.10-hardy-x86.iso
tklpatch-prepare-cdroot turnkey-core.rootfs/ turnkey-core-2009.10-hardy-x86.cdroot/
tklpatch-geniso turnkey-core-2009.10-hardy-x86.cdroot/

Guest's picture


Just throwing this out there.  I used it on a server to create an ISO with all of the goodies I put on there.  Never tried it on a virtual machine.  Will try soon though. 

Guest's picture

I have never thought of it

This is a great idea, this way it much easier to be hypervisor independent. If you wanna go for VMware, Citrix XenServer, Hyper V, it doesn't matter. Thanks for sharing.

Guest's picture

Acronis for basic windows users

I stumbled across this when searching to convert my VM image to iso.


Then thought of an easier way for basiic users

Take a backup using acronis (VMware is to mount tib files directly)


Have not been able to convert a tib to iso yet.



Guest's picture

This process is quiet complex

This process is quiet complex and lengthy too. Is there any other easier method? I tried it and halfway through system got rebooted and lost all conversion I did. I had trouble mounting the secondary drive. And is there any preferable location to copy out the root file system. My operating system is windows 7 but the specification of my system is very low, running out of free space. Should I try again, is there any chance of crashing my system and losing all information?

Guest's picture

Well, this is useful! I'm

Well, this is useful! I'm downloading a Chrome OS image (in vmdk format) and I need it on a DVD.  'Cuz I like to boot things on a physical machine.  Not a virtual one.

Guest's picture

convert a windows machine

i guess this procedure doesnt work for windows vmdk? Do you know any way to perform this on such a vm?



Alon Swartz's picture

Not that I'm aware of

The procedure detailed in the post is for Linux based VMDK's, particularly TurnKey 2000.10 VMDKs. I'm not aware of a similar approach for windows based VMDK's.

Note for future reference, the procedure will need tweaking on 11.1 VMDK's (soon to be released) as they use grub2 and LVM.

Guest's picture

convert a windows machine

thx Alon for the clarification.

just for those who might google this page searching for the same solution as i am, there is a tool called "etboot" on the page reboot.pro.

this tool is able to convert a flat vmdk into iso (apparently no sparse vmdk).


Guest's picture

Converting BackTrack

I accidentally downloaded the VMWare version of BackTrack. VMWare doesn't let u access the wireless card, so bad for me. anyway, this step doesn't work for me.. I've tried evrything... PLZ HELP!!!


qemu-img convert -f vmdk turnkey-core.vmdk -O raw turnkey-core.raw

The result is :-


root@bt:/mnt/hgfs/Documents/BT4R2# qemu-img convert -f vmdk BT4R2.vmdk -O raw backtrack.raw
(VMDK) image open: flags=0x2 filename=BT4R2.vmdk
qemu-img: Could not open 'BT4R2.vmdk'

I think its partitioned :-


  • BT4R2-s001.vmdk
  • BT4R2-s002.vmdk
  • BT4R2-s003.vmdk
  • BT4R2-s004.vmdk
  • BT4R2-s005.vmdk
  • BT4R2-s006.vmdk
  • BT4R2-s007.vmdk
  • BT4R2-s008.vmdk
  • BT4R2-s009.vmdk
  • BT4R2-s010.vmdk
  • BT4R2-s011.vmdk
  • BT4R2.nvram
  • BT4R2.vmdk
  • BT4R2.vmdk.lck
  • BT4R2.vmsd
  • BT4R2.vmx
  • BT4R2.vmxf
  • tklpatch
  • vmware.log
  • vprintproxy.log
The contents of the BT4R2 folder. Also, this folder is being used through VMWare shared folders.
Overlord of destruction (atleast on RuneScape and TribalWars)
Alon Swartz's picture

Non-TurnKey VMDK's not tested.

The procedure detailed is known to work with TurnKey 2009.10 VMDKs. I'd recommend you either download the ISO or contact the folks at backtrack for help.

Guest's picture

Thanks for the excellent

Thanks for the excellent article.

I tried this to convert .vmdk to .iso using qemu-img. My vmdk file is 1.7 GB and the resulting .raw is whoping 20 GB. Why is the raw file so big?

Jeremy Davis's picture

I suspect because .raw is flat/static image

And the TKL .vmdk is a sparse image. In other words the original HDD image contains only data (but can be up to 20GB) but the .raw file includes the empty space as well. Once you mount it and extract the filesystem you should be back to ~1.7GB. 

Guest's picture

.vmdk to .raw conversion

Maybe the .raw is 20GB because the .vmdk was created with 20GB virtual disk?

I created a VM with 20GB virtual disk using VMware fusion with no splitting option and installed linux core and base. I see that .vmdk is ~1.7GB and the following command produced linux.raw file which is 20GB.

qemu-img convert -f vmdk linux.vmdk -O raw linux.raw

What I'm trying to achieve is to install my application and the dependencies in the VM and create an ISO image and distribue it to my customers. It's possible to distribute the virtual appliance in .vmdk itself but if I can distribute an ISO customer can install it on any hardware or any virtualization technologies.

Jeremy Davis's picture

And what is the problem?

You only use the .raw file as an intermediate step so the fact that is 20GB shouldn't matter.

In your useage scenario you may be better off using TKLPatch, to create a patch that you can apply to the default ISO (to recreate your custom appliance).

Guest's picture

Thanks. I have not explored

Thanks. I have not explored TKLPatch yet. Is it possible to convert my 20GB .raw file an .iso under 4GB?

Jeremy Davis's picture

As the tutorial says...

Once you have created the .raw file you then mount it (like you would an .iso) and copy out the contents (which should only be ~1.7GB - ie your original data size). Your resulting .iso should be around that size too. If not then I would assume there is something funny/wrong going on.

Guest's picture



Guest's picture

Version 11

It was mentioned that changes were required to do this with version 11 based appliances. What needs to be done to make this process work with those? Now that I have a working iFolder appliance I'd like to make a cd of it so I don't have to compile the packages again.

Jeremy Davis's picture

No sorry, got no idea.

Perhaps you could try RemasterSys in the meantime? Although TBH I haven't used it with a server (but it's been quite useful for desktop use).

PS Did you document your iFolder progress? It'd be great if you could share as I'd love to create an iFolder TKLPatch and then perhaps an official TKL iFolder appliance might be released.

Guest's picture


I posted a comment on the wiki page for the iFolder appliance about the steps i took to compile iFolder on version 11. If the compiled packages could be put in a repo somewhere then making a patch would be very easy. You would not have to wait for it to compile and you would not have to do all the cleanup (removing all the necessary packages, etc.).

Jeremy Davis's picture

Excellent, thanks.

I will investigate further. When I get a chance I will look at perhaps uploading it to a PPA. I'll post if/when I get to that.

Guest's picture

Half way through!

Hello am at half way exactly on 



but I get the followin



aufs / aufs rw 0 0
> tmpfs /tmp tmpfs nosuid,nodev 0 0
bash: turnkey-core.rootfs/etc/fstab: No such file or directory
Guest's picture

Simple method!

I found the this command:   VBoxManage filename.vdi newfile.iso --format RAW

Guest's picture

Simple method

The command VBoxManage filename.vdi newfile.iso --format RAW would not work for me.

I think that the command would be VBoxManage clonehd filename.vdi newfile.iso --format RAW

I have not been able to test the iso file that resulted yet.  The iso file is about 6 times the size of the vdi file.

Jeremy Davis's picture

The ISO file you created includes free space

That's why it's larger than your original VDI. And actually it's a RAW file (which is a raw harddrive image). If you follow the tutorial it is only halfway through the process. To complete it you need to mount the image you have created and copy out the files, then make an ISO of the files only (that doesn't include the free space). This should bring your ISO back down to a similar (or perhaps smaller) filesize as your original VDI.

Guest's picture

The ISO file you created includes free space

Thanks Jeremy.    I guess that just proves that when all else fails one should read the instructions.  I appreciate your reply

Guest's picture

basename: missing operand

Everything moves along swell up until the last command..


 tklpatch-prepare-cdroot Mikrotik/
# preparing cdroot
basename: missing operand
Try `basename --help' for more information.
cp: omitting directory `Mikrotik//boot/'



Jeremy Davis's picture

Try this:

Just guessing but try:

tklpatch-prepare-cdroot Mikrotik

(No trailing slash). The clue for me was the error message (unless it's just a typo):

cp: omitting directory `Mikrotik//boot/'

Although must admit that the tutorial does include the trailing slash so not sure if that's it.

Guest's picture

Nope, same problem.

Nope, the issue persists.

Do I have to prepare the image on a turn-key distrobution for this to work? I am trying to prepare the image from an Ubuntu 10.4 installation..

Guest's picture

I'm trying to convert a

I'm trying to convert a virtual machine created with MikroTik Router OS from here


Into a bootable ISO of the configured OS.

ISO --> Virtual Machine --> ISO of the VM

I've managed to properly mount all the partitions using some info gleaned from here: http://felinemenace.org/~andrewg/MikroTik_Router_Security_Analysis_Part1/

Basically have to mount the RAW image with and offset of 512 to id the filesystem (ext2) properly.



/sbin/fdisk -l -u mikrotik.raw

This will actually mount an image properly, so just modify it as the Gotcha above for partitions.

mount -o loop,offset=512 mikrotik.raw /mnt/mikro/


I'm just stuck now, I don't know how to properly add both partitions to the image nor will the script run on the rootfs gleaned from one of the partitions.

If anyone can help I would appreciate this.


Jeremy Davis's picture

Hmmm beyond me...

This tutorial works with TKL and I would imagine any Ubuntu or Ubuntu based distro. It may even also work on Debian - but perhaps not...

A quick scan of the second link you provided suggests that that particular version is a mishmash of 2 old versions of Debian but I couldn't quite work out what the go was with the new version. The fact that searching/scanning the website, forum and wiki resulted in no idea on what the OS is based on or what sort of licence it's under doesn't bode well (although perhaps I'm wrong). It seems quite closed and as such I'd suspect that the only way you will be able to do what you are hoping to is with the help and/or support of the makers/community. Have you posted on their forums?

But TBH unless there is a compelling reason, personally I'd be looking about for an opensource product that does the same thing thgat does support hacking etc. I haven't tested any but Wikipedia has a list of starters. No doubt there is probably more if you have a good google. My 2c anyway...

Andreas's picture

True regarding the opensource

True regarding the opensource firewalls distros.

Except I've been through ALL of THEM. :) Seriously, I'm running on Zentyal at my office at the moment, but I've been through Smoothwall, pfSense, ClarkConnect, IpCop, IPFire, etc etc etc.

//disclaimer - I am not affiliated with Mikrotik in any way whatsoever. In fact, they would probably look down on what I am trying to do by creating a LiveCD.

Mikrotik is absolutly the best of the best. Its a bit funky to get started with, ( I was actually planning on running pfSense before I read a single post from a random comment on the pfSense forums that said "Try Mikrotik, once you learn it, you will never go back." I spent last weekend learning it, and without a doubt, it frakking rocks.

Just to get started, a web interface and windows interface for the firewall.. Why would you need the windows interface? Well, for starters, it allows you to connect to the firewall to reconfigure it regardless of your machines IP settings. It connects via MAC address, TCP/IP4 or TCP/IP6 as well as autoscans the local network so a freshly installed firewall is accessible without even touching the console.

The 24 hour time limit on the demo is a bummer but you can backup your config, reformat , and reinstall your config to continue using it or learning it. As well as their licensing is confusing and a bit expensive for SOHO usage.. but considering you can buy some of the RouterBoards including the license for less than the licensing alone, I'm not sure where I stand on that.

I highly reccomend it if you do any networking at all, or if you just want something fun to play with. 

Jeremy Davis's picture

I don't think this is going to work for you

AFAIK unless the original distro supports running live then this will not work for you to create a live distro.

I'm sure creating a live version of the router OS is possible, but not without some serious hacking. The TKL devs have hacked the default Ubuntu Server OS so it can run live so unlike default Ubuntu Server TKL can run live already. I imagine you would need to do similar hacking first to allow this distro to run live. How you would actually go about that is well beyond me and may also be outside the terms of the Mikrotik licence.

As you've possibly guessed from my previous posts I'm a strong advocate of the open source model. But I also try to be respectful of the relevant licencing. If you like Mikrotik RouterOS that much I suggest you consult with them on what your options are and what it will cost you to do what you want.

Guest's picture

qemu taking a long time -- is it working?

I'm guessing that this conversion process could take a really long time. I'm waiting for the command "qemu-img convert -f vmdk Linux\ Mint.vmdk -O raw LinuxMint8Helena.raw" to finish executing. Should it really take so long?

Jeremy Davis's picture

obviously it depends on the size of the image

But if it's a big image, yes it will take a while. A good baseline timeframe to consider is how long would it take to copy the file? Then add a bit (depending on hardware). You can see if it's still doing something via a new terminal window. I don't remember the commands off the top of my head but if you google "check progress qemu-img convert commandline linux" or something similar. I haven't actually done it with qemu-img but I am assuming it would be similar to checking progress of dd.

Guest's picture

failed to run command `dpkg-divert'

Thanks for the post... Everything was fine until the chroot command. I get the below error

$ tklpatch-chroot mrs-meego-1.1.rootfs/
chroot: failed to run command `dpkg-divert': No such file or directory

Any idea what is wrong here?


Guest's picture


Can You Please Upload A Video For This

Guest's picture

issue with Android-2.3-RC1 vmdk

hi, im trying to mount a vmdk with installed Android-x86 distro.

my goal is to modify system dir.

tried this :

chmod 777 android23.vmdk

losetup -s -f android23.vmdk

kpartx -a dev/loop0 , cause there is a partition

mount /dev/mapper/loop0p1  mydisk

mount was correct, but not access in delete system or any other dir



Guest's picture

Gotcha #3?

mount -o loop turnkey-core.raw turnkey-core.mount

mount: you must specify the filesystem type

Neither 'msdos', 'fat32' or 'ntfs' seem to be recognized. (yes, I'm doing this with a windows 7 image).

Any suggestions? Thanks!

Jeremy Davis's picture

Don't think you'll have any joy with Win7

vfat should be a recognised format and depending on what distro you are using, you may need to instal ntfs drivers before it will recognise NTFS FS.

Regardless of that though, because of the nature of how Windows works, I don't think you'll have any joy using this method anyway. Even if you do manage to convert your VM to an ISO I imagine that you'll find that trying to run it on anything that doesn't closely resemble the virtual hardware of your VM will result in a BSOD.

I'm guessing you are trying to create a Win7 ISO with preinstalled apps and/or customised config? I don't know enough about Win7 to give you any really good suggestions, but if you are looking to create a preconfigured image then the MS tool sysprep is probably your best bet and then create an image of your syspreped system. If you hunt about online I'm sure you'll find tons of info detailing the best course of action.

Guest's picture

Thank you Jeremy

Yeah, I wasn't sure if this would work for Windows, but was having trouble getting anything else to work so thought I'd give it a shot. I'll give sysprep a try! Thanks again for your quick and helpful response!

Jeremy Davis's picture

No worries

Another afterthought may be vLite. AFAIK it is the successor to nLite which was a quite cool way of creating a customised XP install CD (vLite is for Vista & 7 IIRC).

I have successfully been using a combination of sysprep and a FOG server to create and deploy Win7 images to multiple machines. It may be overkill (or simply not suitable) for your purposes but it works really well for mine! Possibly worth a look...?

Guest's picture


Everything works up to this point:


tklpatch-prepare-cdroot turnkey-core.rootfs/

After this I get an error about syslinux not being found... Any suggestions? 

Guest's picture

I could generate the ISO but I could not boot it in VirtualBox

Try installing syslinux inside the system that is to say:

tklpatch-chroot turnkey-core.rootfs

....../#apt-get install syslinux

tklpatch-prepare-cdroot turnkey-core.rootfs/
tklpatch-geniso turnkey-core.cdroot/


I tried by this way and also I could generate the iso image with a problem just solved in this link


But when I loaded it to virtualbox, The system did not booted. I got a "kernel panic" message.


Does anybody know how to solve this problem?

Guest's picture

Is my first time on this site but I'm not the last time 100%

Just want to say that this blog contains what often we're looking for and can't find simply by ignorance of those who know and have NO desire to explain to these who learning. NOT In here !!

 SUPPERRRR and Thanks

Guest's picture

.vdi to .raw


VBoxManage clonehd -format RAW test.vdi test.raw

Guest's picture

I am getting stuck on the following

Hi Alon,

Not sure, if you received my last post. Could you assist in this matter ?






Guest's picture

Partitions and filesystem types


All goes well for me before mounting. The image I want created does contain partitions from a Fedora 16 VMWare Player VM. But for two of the partitions the type isn't even specified:
sudo mount /dev/mapper/$(basename $loopdev)p1 fedora-security.mount
mount: you must specify the filesystem type
ls /dev/mapper
control  loop0p1  loop0p2  loop0p3  vg_fedora1664bit-lv_home  vg_fedora1664bit-lv_root  vg_fedora1664bit-lv_swap
sudo fdisk -l fedora-security.raw
WARNING: GPT (GUID Partition Table) detected on 'fedora-security.raw'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk fedora-security.raw: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
              Device Boot      Start         End      Blocks   Id  System
fedora-security.raw1               1    41943039    20971519+  ee  GPT
sudo parted fedora-security.raw 
GNU Parted 3.0
Using /home/a.rubio/turnkey/turnkeylinux-tklpatch-cd6b779/fedora-security.raw
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model:  (file)
Disk /home/a.rubio/turnkey/turnkeylinux-tklpatch-cd6b779/fedora-security.raw: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2097kB  1049kB                     bios_grub
 2      2097kB  526MB   524MB   ext4         ext4  boot
 3      526MB   21.5GB  20.9GB                     lvm
Which matches perfectly what is reported by the  virtual machine itself, which additionally indicates it is virtual scsi:
ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3
sudo parted /dev/sda
GNU Parted 3.0
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2097kB  1049kB                     bios_grub
 2      2097kB  526MB   524MB   ext4         ext4  boot
 3      526MB   21.5GB  20.9GB                     lvm
So when I mount I do not know what type to specify. All types I have tried result in errors:
mount: wrong fs type, bad option, bad superblock on /dev/mapper/loop0p1,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so
And dmesg just shows how it tries all types without success.
Do you by chance know how to deal with this?
Guest's picture


Ah, noticed I have LVM. Getting close since I could now mount lv_swap and lv_root using listings 7 and 8 at: http://www.linuxjournal.com/article/8874?page=0,2

Guest's picture

Installer: How-To?

Is there a way to make this cd installable? as in install cd so when you go to the desktop in the live enviornment, and click an icon to install? OK if it is terminal-based...

Jeremy Davis's picture

If you are using TKL then it should be installable

And if not (but still something Linux) it should be possible, although to be honest I have no idea how you would go about that. I would suggest that you post on the forums/mailing list for whatever distro you're using and ask there. That way hopefully you will get some answers relevant to your scenario.

Guest's picture

Thank You!

I've been searching for days trying to figure out how to do this. This is the only walk-through that worked on the first try. Mad Propz!!

Guest's picture

The reason I'm trying to do this

We run a highly virtulized dynamic environment. Even our DNS servers are virtulized. When we have a catastrophic event and have to spin everything up from scratch our VM hosts cant find their back end storage because DNS is down becuase the VM Host cant find its back end storage ..... so I want a bootable ISO of our DNS server, even if I have to tweak some of the entries because they have changed Its still better than what I currently have to do which involves remounting storage devices as an IP bringing up DNS then bringing up a clone on another host and downing the first copy. Its quite time consuming and surprisingly we seem to have several catastrophic events a year.

Guest's picture




First thanks for the article,


I got the same problem as teabag, meaning when i get to the tklpatch-chroot i get :

chroot: failed to run command `dpkg-divert': No such file or directory


I think it means he can't find dpkg in the chroot environnment, but i got no idea how to fix this, if you have one i'd be glad to hear it.


Thanks a lot.




PS : I'm trying to convert the metasploitable vmdk to an iso.

Guest's picture

Live iso

I use a program called remastersys if your looking at creating bootable OS from working linux system. Allows live OS and install, and options to output config from services/applications so theres no mucking around after install. If was providing read only control on services I couldnt see why it wouldnt run all day live of a cd/dvd. Draw backs is I have only tested this with ubuntu (but most things linux can be tinkered and chaged to suit) and it wont like the iso if it is too big (but again I cant see why the size limitation cant be "forced" to ignore error).

Jeremy Davis's picture

That's definitely one way

Although I haven't tried it on a server OS. Also I didn't realise that it was back up and running (IIRC it died some time ago, but obviously got revived somewhere along the line) so thanks for that info.

Guest's picture

creating installble iso using remastersys

hello Jacob

i tried to create the an iso using remastersys, but i was not able to install from it. it was just a live cd. even the install option caused it to boot in live mode. cud u plz help what steps u had followed and which version of remastsys u had used ?


thanks in advance.



Guest's picture

Oracle VM, .vdi Clonezilla virtual to physical Help needed


Jeremy you seem to respond to posts so I've got a question/I need help with something.
I have Oracle VM, I have installed ubuntu server 12.10, xfce, other essentials, webmin, samda and basically got it at the stage I'd like to clone it.
The original reason I used VM was because I'm looking to covert and old laptop into a server. I'm waiting on an sdhc card and sd card reader in the post si I can install from usb.
I was originally looking at clonezilla but in oracle vm you can't seem to select a physical disc as a sata controller (only virtual). 
If I format the laptop with XP in it, how would i go about cloning my .vdi image onto the usb and then onto the laptop?
I can boot from clonezilla image, use my .vdi as a hard drive. Any suggestions? - Or is the above mentioned way how I should go about it. Does the above way create a live distro?, would I then use bash to unmount, then copy over from the sd? - Kind of confused. I know wmware have a 'physical drive option' in which case the guide @ ;-
would be fantastic.
I'm thinking by combing both of these excellent resources I'll manage to do this. *fingers crossed
Guest's picture



I decided to create a live cd. Install ubuntu server, use gpparted, then copy copy and mount ext4.
Took a few hours but I learned more in the process :)
Guest's picture


Thanks a lot for sharing your great and informative article.

Since I took part in a Workshop regarding to VMware, I work with it.

I made good experiences and hope to expand my knowledge in this case.


So thanks again and all the best!

Guest's picture

vmxnet nic driver causing kernel panic


I followed the steps, and got all the way to the iso, but it doesn't boot properly. In the boot process it gets to the step where it starts a vmxnet NIC driver, then kernel panics.

I suspect I somehow need to uninstall it at the .rootfs stage, and replace it with something else. I am not sure how I can do this, any ideas?


Guest's picture

Did you figure this out?

I got the same things I think.... Any help would be apprecaited


Guest's picture

Simplicity for Windows users?

Hi, I was reading through all of this and it all seems very complex to me how you guys are going about this all? Theres a couple of ways we could do this. Like using a FAT32 partition attached to another VM then boot into another live CD in the VM and manipulate it and output to the FAT32 partition. Exit the VM and use Folder2ISO to make your ISO image (obviously removing or adding what ever you want before hand ie. Kernel etc) and/or incorporating anything else that you may want from another ISO distro or what ever. Remember anything that is generated and output to FAT32 is visible and can be seen in Windows. So you can change things to how you like put it out to FAT32 and when your done use Folder2ISO. This will guarantee to make your ISO bootable. Second would be to use qemu binary directing in Windows instead of trying to add all this extra stuff and downloading add ons. It accepts the exact same arguments via the command line to make a RAW image from your VMDK. Edit anything you like from the generated img using a cool little GUI app I use called yaffey. https://code.google.com/p/yaffey This is perfect cause it maintains all the integrity of the img file and allows you to swap in or take out what ever you like. Lastly you could use LinuxReader and output your system img to Windows and then rebundle it using Folder2ISO. As my dad would say 'There's many ways to skin a cat' ;-) Jarmezrocks
Guest's picture

loop device ≠ 'loopback' device

Guest's picture

Error two partitions

Error , two partititions, /boot and /dev/mapper. 


Generate kernel panic 

Jeremy Davis's picture

This blog post is very old

I suspect the issue is that TKL now uses LVM by default. Unfortunately I am not sure on a workaround.

Guest's picture

minor issues faced in this process


thanks a lot for this solution. Just to add a small bug in the procedure, i was getting error while creating the iso stating that the file size was larger than 2Gb so some flag "-allow-limited-size" had to be added.

finally i create the iso and tried to install with it, but the it didnt work :( from the logs i cud just find that some kernel panic had happened and the whole thing just shut down.

had anyone faced a similar issue. please help !!

Guest's picture

Kernel Panic After Booting ISO

I got the below message after booting the ISO. I was able to follow the instructions and I encountered GOTCHA 1. I was not able to install the linux-image-generic after chroot 'ing so maybe that is my problem but if anyone experience this problem and fixed it then I would greatly appreciate the help!.


Guest's picture

Hello Thank you for this


Thank you for this tutorial.

Is the ISO image file created by this method installable or just bootable (live) ?


Guest's picture

Help! mount -o loop

mount -o loop turnkey-core.raw turnkey-core.mount

mount: you must specify the filesystem type


What type of file system do I have to use to mount the RAW image?

Guest's picture

mount failed

i have the error: mount: you must specify the filesystem type

in this stage :

mount -o loop turnkey-core.raw turnkey-core.mount


thanks :)

Guest's picture

mount failed

I suggest you do 

mount -o loop,offset=theNumberofBytesofYourRawFile turnkey-core.raw turnkey-core.mount
fdisk turnkey-core.raw

And you should be able to  sectors of 1 * 512 = 512 bytes or something similar

Also, you should see 

        Partition     Status         Type         Start   End   Length    %
    =========   ======    ========  =====   ===   ======   ===
        1              something       1             2048       12345     20

your offset number will be 2048*512 = 1048576, the place where the mount should begin!!

Good Luck!!

Guest's picture


Thanks for this article it is exactly what I need.  Everything is working fine until I get here...

#tklpatch-chroot silk.rootfs

I get this error...

chroot: failed to run command 'dpkg-divert' : No such file or directory

Jeremy Davis's picture

Is the OS Debian or a derivative (e.g. Ubuntu)?

If so then that would be the problem...

Otherwise that's really weird! According to Debian dpkg-divert is provided by the dpkg package. It is a fundamental part of Debian (and it's derivative's) package management system and should certainly be installed!

Guest's picture

cdroot too large

I've followed this process to the final step and have had success so far, however when I attempt to run tklpatch-geniso foo.cdroot I get: File foo.cdroot//casper/10root.squashfs is larger than 4GiB-1. -allow-limited-size was not specified. There is no way do represent this file size. Aborting. the cdroot directory is 22gig in size. I didn't see anything in this post that excludes large vms. Is there a work around to this?

Guest's picture

believe I found a fix

Did some digging and noticed that the tlkpatch-geniso utilizes the genisoimage command. That led me to this fix mkisofs -allow-limited-size -l -J -r -iso-level 3 -o <output.iso> foo.cdroot which should allow it to generate iso file larger then 4gb, running it now so heres hoping.

Guest's picture

it would be nice

In fairness... it would be nice, to leave thouse "once helpful" articles up to date, ore delete 'em ;)
We have too much confusion already, right ?
So how about this one ...
https://www.turnkeylinux.org/blog/convert-vm-iso ?
Since Remastersys does no DNS in the backup,
it would be really nice to have a working process
step by step
including /home/USER
Maybe you can help

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)