LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-06-2012, 03:58 PM   #1
deckoff
LQ Newbie
 
Registered: Jan 2012
Location: Sofia
Distribution: Ubuntu 11.10
Posts: 13

Rep: Reputation: Disabled
How to edit initrd to fit your liveUSB - liveUSB preparation (openSUSE and others)


I am interested in the process of creating live linux USBs so I spent 2 hours playing with "multisystem usb creator" and two USBs to prepare a working openSUSE live USB. I prepared two USBs using the same input OenSUSE.iso and the same "tool" so I can have two "identical" USBs. If the content of USB1 is copied over onto USB2, USB2 will not boot, even though the USBs were supposed to be "identical"
I swapped files between the two USBs, until testing proved, that initrds were USB-specific, and if the original initrd is used, the USB will boot. Most of the other files were really identical, anyway.
That is why I came to the conclusion, that every initrd prepared with a live USB creator is specific for the pendrive.
Please, confirm
If initrd is vital for the USB booting, please, tell me how to unpack, which files to edit and repack initrd files, so the usb will boot( how the initrd is edited during live USB preparation.

Last edited by deckoff; 01-06-2012 at 04:11 PM.
 
Old 01-06-2012, 04:48 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Doesn't sound right to me. Did you copy the contents of the device as opposed to just a partition? You should be able to make an image on disk, and write that image to any USB that is large enough to hold it. Each of them should boot (or at least do what the original did). I do this routinely with SD flash cards that are use to boot embedded ARM CPUs.

--- rod.
 
Old 01-06-2012, 05:16 PM   #3
deckoff
LQ Newbie
 
Registered: Jan 2012
Location: Sofia
Distribution: Ubuntu 11.10
Posts: 13

Original Poster
Rep: Reputation: Disabled
It seems I am not clear enough. I am talking about simple copy/paste of files, MBRs and PBRs are created automatically.
I prepare two USBs. Both boot OK. I use the same iso file namely: OpenSUSE-KDE-x86.iso. I use this tool LiveUSB Multiboot here(I will explain why this one later in the post).
Lets call the two USBs USB1 and USB2. Both USBs have their own, unique initrd. If I replace initrd of USB1 (initrd1) with initrd of USB2 (initrd2), USB1 ( with initrd2) will boot, but will fire an error during the load process that RW system was not found.
Why do I do this - I want to finally install OpenSUSE to a logical partition on a USB. Ubuntu and Fedora will install correctly with with tools, provided by the distros, Unetbootin or LiVEUSB install. OpenSUSE will not. The tool provided will simply execute dd if=/open/suse/iso of=/dev/sdb. This is the way to install in under linux proposed by the developers.
If I dd the iso to a partition (of=/dev/sdb1) the partition will be corrupted.
So I decided to experiment - first find a tool that will create really bootable OpenSUSE. LiveUSB Multiboot is the only one that really worked without dd command. I got a USB with syslinux MBR and syslinux PBR which chainloads to GRUB2 and GRUB2 is used to boot the iso (openSUSE in that case).
After lots of tests I came to the conclusion that initrd is modified in the process of USB preparing (dumping the OpenSUSE.iso to the USB), and the resulting initrd is USB-specific.
I want to know how to reproduce the initrd preparing process so I can locate the OpenSUSE to a logical parition
 
Old 01-06-2012, 05:40 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Okay, one thing quickly jumps out at me:
Code:
dd if=/open/suse/iso of=/dev/sdb
This command will write an entire device (MBR, partition table, and all partitions) to the USB device. While you seem to call it an ISO image, it cannot be, as an ISO image contains only the ISO-9660 filesystem for a single partition. And this is consistent with the behavior you see when trying to write that to a partition.

You say 'OpenSUSE will not. The tool provided will simply execute dd if=/open/suse/iso of=/dev/sdb.' but don't say in what way this fails. In principle, I see nothing wrong with this approach. What about that does not work?

Your conclusion that initrd is 'modified' as part of an install process is probably close to correct. An initrd is simply a RAM disk image. It is likely that the files installed in the RAM disk image are specific to the distro, and the methods it uses to bootstrap itself. It may be composed in some way that reflects your hardware, in order to minimize its size or optimize it in other ways.

You can unroll the initrd, using cpio and gunzip, and poke around in its files. Doing this will allow you to compare the contents of each, even modifying them if required.

It is likely that the bootloader plays a role in the process, or that there is a kernel commandline built into the kernel that requires some accordant makeup of the initrd. It is not surprising that an initrd for one distro will fail when used with a kernel from another distro.

It sounds like what you need to do is use kparted to extract the components of the OpenSUSE image. That will give you access to its partitions, which you can then write to partitions of the USB drive.

--- rod.

Last edited by theNbomr; 01-06-2012 at 05:55 PM.
 
Old 01-07-2012, 04:18 AM   #5
deckoff
LQ Newbie
 
Registered: Jan 2012
Location: Sofia
Distribution: Ubuntu 11.10
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by theNbomr View Post
Okay, one thing quickly jumps out at me:
Code:
dd if=/open/suse/iso of=/dev/sdb
This command will write an entire device (MBR, partition table, and all partitions) to the USB device. While you seem to call it an ISO image, it cannot be, as an ISO image contains only the ISO-9660 filesystem for a single partition. And this is consistent with the behavior you see when trying to write that to a partition.
When I prepare the USB that way and run boot-info-script, the script reports that the USB:
MBR
Code:
 => ISOhybrid (Syslinux 4.04 and higher) is installed in the MBR of /dev/sdb.
PBR
Code:
sdb1: __________________________________________________________________________

    File system:       
    Boot sector type:  Unknown
    Boot sector info:  
    Operating System:  
    Boot files:
I meant the extension is .iso, obviously this is not a CD-image( as far as I get it)
Quote:
Originally Posted by theNbomr View Post
You say 'OpenSUSE will not. The tool provided will simply execute dd if=/open/suse/iso of=/dev/sdb.' but don't say in what way this fails. In principle, I see nothing wrong with this approach. What about that does not work?
I want to make a multi-boot multi-partition USB with various Linux distros, and place every disto into its own partition. dd will obviously destroy anything on the USB I want to place the distro on its own extended partition, but dd will only create MBR where PBR should be, and will destroy the partition. I even tried it, and, of course, it did not work.
Quote:
Originally Posted by theNbomr View Post
Your conclusion that initrd is 'modified' as part of an install process is probably close to correct. An initrd is simply a RAM disk image. It is likely that the files installed in the RAM disk image are specific to the distro, and the methods it uses to bootstrap itself. It may be composed in some way that reflects your hardware, in order to minimize its size or optimize it in other ways.
The USB is meant to boot on every PC. I assume changes are made so the correct path to a file is specified. Since the only different thing is the USBs, I assume a reference to the UUID of the USB is made.( a HUGE assumption by me) This assumption I need to be confirmed ( or rejected) , and the location( the file into the initrd modified) to be specified.
Quote:
Originally Posted by theNbomr View Post
You can unroll the initrd, using cpio and gunzip, and poke around in its files. Doing this will allow you to compare the contents of each, even modifying them if required.
This whole compare thing I wanted to escape. This way I found that initrd are the only difference. Anyway, a good compare software with GUI ( gtk is better, Ubuntu 11.10) could be recommended I tried UltraCompare (commercial) but it hanged
Quote:
Originally Posted by theNbomr View Post
It is likely that the bootloader plays a role in the process, or that there is a kernel commandline built into the kernel that requires some accordant makeup of the initrd. It is not surprising that an initrd for one distro will fail when used with a kernel from another distro.
It is the same distro , deployed on the USBs the same way, only the USB-s are different.
Thank you for your help
 
Old 01-07-2012, 07:18 AM   #6
deckoff
LQ Newbie
 
Registered: Jan 2012
Location: Sofia
Distribution: Ubuntu 11.10
Posts: 13

Original Poster
Rep: Reputation: Disabled
It turns I am right - the only difference between the to initrd files appears to be a gingle line of code, the uuid of the 2 different USBs. here is the output of the diff command between the two unpacked initrd-s
Code:
deckoff@deckoff-OEM:~/Desktop/initdr-original$ diff '/home/deckoff/Desktop/initdr-original' '/home/deckoff/Desktop/initdr-other' 
Common subdirectories: /home/deckoff/Desktop/initdr-original/bin and /home/deckoff/Desktop/initdr-other/bin
Common subdirectories: /home/deckoff/Desktop/initdr-original/boot and /home/deckoff/Desktop/initdr-other/boot
Common subdirectories: /home/deckoff/Desktop/initdr-original/dev and /home/deckoff/Desktop/initdr-other/dev
Common subdirectories: /home/deckoff/Desktop/initdr-original/etc and /home/deckoff/Desktop/initdr-other/etc
Common subdirectories: /home/deckoff/Desktop/initdr-original/image and /home/deckoff/Desktop/initdr-other/image
diff /home/deckoff/Desktop/initdr-original/include /home/deckoff/Desktop/initdr-other/include
3315c3315
< 	cddev="/dev/disk/by-uuid/69B7-F293"
---
> 	cddev="/dev/disk/by-uuid/A2C1-AEB1"
Binary files /home/deckoff/Desktop/initdr-original/initrd and /home/deckoff/Desktop/initdr-other/initrd differ
Common subdirectories: /home/deckoff/Desktop/initdr-original/lib and /home/deckoff/Desktop/initdr-other/lib
Common subdirectories: /home/deckoff/Desktop/initdr-original/mnt and /home/deckoff/Desktop/initdr-other/mnt
Common subdirectories: /home/deckoff/Desktop/initdr-original/proc and /home/deckoff/Desktop/initdr-other/proc
Common subdirectories: /home/deckoff/Desktop/initdr-original/run and /home/deckoff/Desktop/initdr-other/run
Common subdirectories: /home/deckoff/Desktop/initdr-original/sbin and /home/deckoff/Desktop/initdr-other/sbin
Common subdirectories: /home/deckoff/Desktop/initdr-original/selinux and /home/deckoff/Desktop/initdr-other/selinux
Common subdirectories: /home/deckoff/Desktop/initdr-original/sys and /home/deckoff/Desktop/initdr-other/sys
Common subdirectories: /home/deckoff/Desktop/initdr-original/tmp and /home/deckoff/Desktop/initdr-other/tmp
Common subdirectories: /home/deckoff/Desktop/initdr-original/usr and /home/deckoff/Desktop/initdr-other/usr
Common subdirectories: /home/deckoff/Desktop/initdr-original/var and /home/deckoff/Desktop/initdr-other/var
deckoff@deckoff-OEM:~/Desktop/initdr-original$ ^C
deckoff@deckoff-OEM:~/Desktop/initdr-original$ sudo blkid
/dev/sda1: UUID="44CE13D2CE13BADE" TYPE="ntfs" 
/dev/sda2: UUID="90241DA9241D92F8" TYPE="ntfs" 
/dev/sdb1: LABEL="Downloads" UUID="CA74D06374D053B3" TYPE="ntfs" 
/dev/sdb5: UUID="537f15cc-5570-4c80-8712-4749230b9e13" TYPE="ext4" 
/dev/sdb6: UUID="44ac51d4-b2c1-4a1d-9fd1-a16a45f7624c" TYPE="swap" 
/dev/sdg1: LABEL="121" UUID="69B7-F293" TYPE="vfat"
I will have to find way to correctly pack the damn thing, and if anything successful comes out of this, I will report.
 
Old 01-07-2012, 04:49 PM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
Originally Posted by deckoff View Post
When I prepare the USB that way and run boot-info-script, the script reports that the USB:
MBR
Code:
 => ISOhybrid (Syslinux 4.04 and higher) is installed in the MBR of /dev/sdb.
PBR
Code:
sdb1: __________________________________________________________________________

    File system:       
    Boot sector type:  Unknown
    Boot sector info:  
    Operating System:  
    Boot files:
I meant the extension is .iso, obviously this is not a CD-image( as far as I get it)
Well, regardless of the filename extension, it IS a 'CD' image. It contains more than just a filesystem; it also has the partition table, MBR, and at least one partition with a filesystem.
Quote:
dd will obviously destroy anything on the USB I want to place the distro on its own extended partition, but dd will only create MBR where PBR should be, and will destroy the partition. I even tried it, and, of course, it did not work.
You cannot write an image file containing a complete device image to a single partition. It isn't dd that is destroying anything. Storage devices are not interchangeable with partitions. The image that was created was not intended to be installed on a single partition.
Quote:
The USB is meant to boot on every PC. I assume changes are made so the correct path to a file is specified. Since the only different thing is the USBs, I assume a reference to the UUID of the USB is made.( a HUGE assumption by me) This assumption I need to be confirmed ( or rejected) , and the location( the file into the initrd modified) to be specified.
I guess it depends whether the UUID of each USB device is defined somewhere on the USB device before or during the installation process. If the installer uses a UUID it finds already installed, then you can never transfer the image to another USB drive. If the the UUID of the USB disk is created by the installer, then you should be able to transfer the image. Otherwise, the image is tied to a specific USB device. The latter aproach seems broken, to me.

Quote:
This whole compare thing I wanted to escape. This way I found that initrd are the only difference. Anyway, a good compare software with GUI ( gtk is better, Ubuntu 11.10) could be recommended I tried UltraCompare (commercial) but it hanged

It is the same distro , deployed on the USBs the same way, only the USB-s are different.
Thank you for your help
Seems improbable that any GUI exists to do all of these highly esoteric things. You need to unroll the initrd, modify the file containing the USD device's UUID reference, and roll the whole thing back up. Since the image contains the contents of a device, you will need to extract the filesystem components, and mount them on loop devices. You can do a little bit of disk image gymnastics with fdisk for help, or use kpartx. It might be possible to modify the initrd so that it is not tied to the UUID of the USB device. In order to tell, I think you will need to extract the file, and see how the reference is being used.
It may also be possible to modify the UUID of the USB device, so that it matches the UUID embedded in the initrd. That would seem to defeat the purpose of the UUID, but perhaps it doesn't matter.

--- rod.
 
Old 01-08-2012, 02:58 AM   #8
deckoff
LQ Newbie
 
Registered: Jan 2012
Location: Sofia
Distribution: Ubuntu 11.10
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by theNbomr View Post
Well, regardless of the filename extension, it IS a 'CD' image. It contains more than just a filesystem; it also has the partition table, MBR, and at least one partition with a filesystem.
I dont know anything on the topic of what is inside a (bootble) CD. Thank you.
Quote:
Originally Posted by theNbomr View Post
You cannot write an image file containing a complete device image to a single partition. It isn't dd that is destroying anything. Storage devices are not interchangeable with partitions. The image that was created was not intended to be installed on a single partition.
I mean the same thing. Probably I could not express myself clearly.
Quote:
Originally Posted by theNbomr View Post
I guess it depends whether the UUID of each USB device is defined somewhere on the USB device before or during the installation process. If the installer uses a UUID it finds already installed, then you can never transfer the image to another USB drive. If the the UUID of the USB disk is created by the installer, then you should be able to transfer the image. Otherwise, the image is tied to a specific USB device. The latter aproach seems broken, to me.
The original initrd was never bound to a specific USB partition by a UUID. The original code into initrd is

...........

It is the "third-party" solution LiveUSB MultiBoot that modifies the initrd, and changes file /include(root of initrd) at line 3315:

Code:
	searchImageHybridMedia
	if [ ! -z "$cddev" ];then
		setupHybridPersistent
		kiwiMount "$cddev" "/cdrom" "-o ro" 1>&2
		return
ORIGINAL initrd

to

Code:
	cddev="/dev/disk/by-uuid/D4C8-ED4C"
	cdopt="-t vfat"
	if [ ! -z "$cddev" ];then
		setupHybridPersistent
		kiwiMount "$cddev" "/cdrom" "-o ro" 1>&2
		return
	fi
Changes are bold. This changes obviously provides that the correct media is searched.
Quote:
Originally Posted by theNbomr View Post
Seems improbable that any GUI exists to do all of these highly esoteric things. You need to unroll the initrd, modify the file containing the USD device's UUID reference, and roll the whole thing back up. Since the image contains the contents of a device, you will need to extract the filesystem components, and mount them on loop devices. You can do a little bit of disk image gymnastics with fdisk for help, or use kpartx. It might be possible to modify the initrd so that it is not tied to the UUID of the USB device. In order to tell, I think you will need to extract the file, and see how the reference is being used.
It may also be possible to modify the UUID of the USB device, so that it matches the UUID embedded in the initrd. That would seem to defeat the purpose of the UUID, but perhaps it doesn't matter.

--- rod.
It might be improbable, but it seems that LiveUSB MultiBoot does this exactly: it unpacks the initrd, edits some code so the initrd is USB bound. You see the changes the installer makes to initrd (/include).

I managed to solve my problem, though. This is what I did. The aim was to create a OpenSUSE bootable media, placed on a extended partition of a multi-boot , multi-partition USB, with every distro on its own partition
1. I used LiveUSB installer( under WIndows) to create a Live USB. This Live USB will not boot, though, since the intrd seaches for hybrid media, but this just an "ordinary" USB. I chose this installer, cos it keeps the original menu of the OpenSUSE media. You might not want to use the MultiUSB, but another one.
2. Choose a partition you want, on an USB you want and install syslinux on the partition. Extended partition is OK:
Code:
syslinux /dev/sdb11
3. Copy all of the content of the of the dummyUSB to the partition of the MultiUSB. /dev/sdb11 in my case.
4 Get the partition UUID of the USB with
Code:
sudo blkid
5. Unpack the initrd you have. One gets a dir full of text files. There is include file in the root dir. Line 3315 should be changed as described above. Use the UUID you got as a result for the partition you use for OpenSUSE.
6. Re-pack the initrd and replace the original one.
7. Use whatever method you like to chainload to this partition, I use Grub4DOS.
This method worked for me I hope this post helps someone
 
  


Reply

Tags
initrd, liveusb


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] openSUSE LiveUSB boot problem wishingstar Suse/Novell 9 11-25-2011 11:34 PM
LiveUSB Setarkos Linux - Newbie 4 06-04-2011 04:01 AM
liveusb multiboot vdemuth Slackware 6 04-27-2011 05:38 AM
LiveUSB failure tonguebuster Solaris / OpenSolaris 2 12-16-2010 07:58 AM
4bak liveUSB alisou Linux - Distributions 8 03-12-2009 05:58 PM


All times are GMT -5. The time now is 03:23 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration