[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#759406: debian-cd: Merge iso images into usb drive thanks to cat



Well, this works if you use mount command from util-linux package. busybox's mount does not implement offset feature, so it either ignores it or complains about it.

== Getting Debian images ==

I have downloaded
  * debian-7.6.0-i386-CD-1.iso
  * debian-7.6.0-i386-CD-2.iso
for doing my tests.

== Getting to know Debian CD 1 size ==

# fdisk -l debian-7.6.0-i386-CD-1.iso
GNU Fdisk 1.2.5

Copyright (C) 1998 - 2006 Free Software Foundation, Inc.
This program is free software, covered by the GNU General Public License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.


Disk /mnt/ssd/adrian_sata/conocimiento/distribuciones_isos/debian-installer/debian-7.6.0-i386-CD-1.iso: 679 MB, 679477248 bytes
64 heads, 32 sectors/track, 648 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes


Device Boot Start End Blocks Id System /mnt/ssd/adrian_sata/conocimiento/distribuciones_isos/debian-installer/debian-7.6.0-i386-CD-1.iso1 * 1 648 663536 17 Hidd HPFS/NTFS

So size, in bytes, is: 679477248 .

== Additional notes ==

Although I am booting from a cdrom, the same procedure can be replicated if you boot from a usb hard disk.

== Virtual machine description ==

Cdrom 1: Debian Live CD
Cdrom 2: Debian CD 1
Cdrom 3: Debian CD 2

Hard disk 1: 8 GB . Blank disk for a new Debian installation.
Hard disk 2: 4 GB . Blank disk. USB that has concatenated images.

== USB preparation ==

I boot the virtual machine from: Cdrom 1: Debian Live CD . Let's see how GNU/Linux detects the disks:

/dev/sr0: Cdrom 1: Debian Live CD
/dev/sr1: Cdrom 2: Debian CD 1
/dev/sr2: Cdrom 3: Debian CD 2

/dev/sda: Hard disk 1: 8 GB . Blank disk for a new Debian installation.
/dev/sdb: Hard disk 2: 4 GB . Blank disk. USB that has concatenated images.

Now we are going to concatenate the disks. Be aware that final user will not concatenate cdrom devices but iso files directly. I use cdrom device because, as I use Virtualbox, it makes it easier for me.

cat /dev/sr1 /dev/sr2 > /dev/sdb
sync

== Testing the idea ==

Now I change a bit cdroms so that I boot from Debian CD 1.
Cdrom 1: Debian CD 1
Cdrom 2: Debian CD 2

I boot the virtual machine from: Cdrom 1:Debian CD 1.

So, first of all install Debian (making sure that Standard tools from system are installed although I'm not sure if they are absolutely needed or not) into /dev/sda hard disk up to the point where you are asked if you want to install bootloader or not. Don't ask the question. Instead do: ALT+F2 .

This is going to open a shell where sda is mounted in /target and where, let's remember, sdb is: Hard disk 2: 4 GB . Blank disk. USB that has concatenated images.

mkdir /target/mnt/apt2
chroot /target /bin/mount /dev/sdb /mnt/apt2 -o offset=679477248 -t iso9660

Now if you run:

more /target/mnt/apt2/README.txt

you will see that you can read Debian CD 2 disk while it's have been concatenated to the USB !!!

== Target based Implementation ==

This is the implementation you have seen before. You need to have a basic installation of Debian into the hard disk. That's not problem because it is provided by Debian CD 1.

Once this basic installation (included the Grub installation to disk) has finished the user is prompted:

Do you want to search packages into appended images in your usb?

If the user answer yes, then the offset mount is tested, packages path is added to /etc/apt/sources.list (or whatever), apt-get update is run, and you somehow let the user add more packages in the installation if he wants to.

These packages are found in second cdrom.

== Busybox based Implementation ==

This implementation would involve hacking busybox's mount command so that it supports offset parametre.

Then asking for the user which packages to install would be done once, because the next Debian CDs would have been found at first stages of the installation.

== Using Disk 2 from USB everyday ==

Somehow a tool would be needed so that the user can mount its Debian CD 2 from its USB as easier as possible (Maybe a noauto entry in fstab). This way when running: apt-get update the files will be finally found in /mnt/apt2 (or whatever) .

== Special tool for making USBs in Windows ==

For Windows people it would be nice to have a GUI where you can select (always with CD 1 as the first one) all the cds you want and then concatenate them into a USB device.

== Padding when generating iso images ==

As you might suspect you need to know the iso size in advance so that this works in a reasonable way.

I think the idea is to embed the disk size in a file somewhere inside of each one of the disks.

How do you manage to know the final size before generating the disk? By padding it.

So, if you want your disk to be 900 MB you will build it to have 890 MB, then you will pad 10 MB at its end so that it is 900 MB. If the build happens to have: 892 MB, then you only need to add 8 MB. Of course, the padding needs to be done in bytes not in megabytes.

== Feedback from Debian-CD / Debian-Installer people ==

Do you think it's something that it's easy to implement ?
Will you need help even if it's easy to implement ?

I hope that this new hack (I think nobody has thought about using mount's offset option in a such a way) lets Debian shrink its Debian CD archive size.


El 27/08/14 03:08, Adrian Gibanel Lopez escribió:

I will try to make some tests in the next days to prove if the minimal
functionality needed actually works or if it would need hacks on how Gnu/Linux
kernel reads devices bigger than its partition table suggested size.

adrian15
--
Support free software. Donate to Super Grub Disk. Apoya el software libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/


Reply to: