Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 413039 - run Gentoo LiveDVD 12.1 on a usb without ruining data
Summary: run Gentoo LiveDVD 12.1 on a usb without ruining data
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Team Anniversary
URL: http://forums.gentoo.org/viewtopic-t-...
Whiteboard:
Keywords:
Depends on:
Blocks: 378027
  Show dependency tree
 
Reported: 2012-04-22 04:26 UTC by r01
Modified: 2013-10-06 15:33 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description r01 2012-04-22 04:26:28 UTC
the official way to make a Gentoo LiveDVD USB

http://www.gentoo.org/news/20120401-livedvd.xml 
http://www.gentoo.org/proj/en/pr/releases/12.1/faq.xml 

Code:
Code Listing 2.3: Copy the image 
# dd if=image.iso of=/dev/sdb

has two major problems: 
1) existing data on the usb will be ruined; 
2) the remaining space of a larger usb cannot be utilized; 


for larger usb stick the remaining space should be usable during the live session

for which I already have a fix:
http://forums.gentoo.org/viewtopic-t-920934.html

Reproducible: Always
Comment 1 Fernando (likewhoa) 2012-04-26 17:11:25 UTC
point #2 is invalid since once you run 'dd' on the usb you are able to create additional partitions to utilize the remaining space on the usb device. The problem with running dd on an existing usb device is that all data currently on that usb device will be destroyed.

Please attach any patches so that we can test and evaluate your propose change. Thanks for contributing!

likewhoa
Comment 2 r01 2012-05-01 09:44:46 UTC
my patch was posted on the original link already:

http://forums.gentoo.org/viewtopic-t-920934.html


Please extract the gentoo.igz file, apply the patch in the 2nd code snippet in above link: it mainly changed these two script of the initrfamfs:

+++ gentoo-initramfs/init   2012-04-20 03:53:50.150985224 +0000
+++ gentoo-initramfs/etc/initrd.scripts   2012-04-20 03:53:49.710985233 +0000

After applied, re-make the gentoo.igz by

$ (cd gentoo12-initramfs/; find |cpio --owner=0:0 -H newc -o) |gzip -v9 >gentoo12.igz

the 1st code changes in the link is technically not required since syslinux boot menu give you a chance to change it during runtime:


So, with the above gentoo.igz, the steps to make a bootable usb is:
   assume it's sdb1 mounted somewhere (I have only vfat usb, don't want to try reformat, but I think both vfat, ntfs, or extX series most linux file system would be supported );
1) create a named "gentoo" folder in the usb;
2) copy Gentoo LiveDVD 2012.1 iso into this "gentoo" dir;
3) extract "boot" and "isolinux" from iso into this "gentoo" dir;
4) rename all "isolinux" to "syslinux", isolinux.bin to syslinux.bin, isolinux.cfg to syslinux.cfg;
5) # syslinux -d /gentoo/syslinux /dev/sdb1

Then for this usb, any other contents outside "/gentoo/" never be touched but becomes bootable now: you can try boot with it, but if you didn't change syslinux.cfg, you need to change parameters on runtime, for syslinux running, Press 'Tab' to change it:

it's default like this:

> /boot/gentoo root=/dev/ram0 init=/linuxrc dokeymap aufs looptype=squashfs loop=/image.squashfs cdroot initrd=/boot/gentoo.igz vga=791 splash=silent,theme:livecd-12.0 console=tty1 quiet


You can change it to

> ../boot/gentoo aufs_mem=2G cdroot=LABEL=PENDRIVE isoboot=gentoo/gentoo12.iso initrd=../boot/gentoo12.xz vga=791 splash=silent,theme:livecd-12.0 console=tty1 quiet doload=ehci-hcd,usb-storage

This is what I tested running well, but not all required:
1) ../boot/gentoo is required because this kernel file is not put in the
   root of the usb, you can use the absolute name "/gentoo/boot/gentoo" ok,
   or this style of relative path, syslinux is reading that according
   where syslinux.cfg exists, "/gentoo/syslinux/syslinux.cfg" is where
   I saved it, so this relative path "../boot/gentoo" works for me;
2) "root=/dev/ram0 init=/linuxrc" is not required at all,
   it's no use but no harm;
3) aufs_mem=2G, adjust according how much memory do you have on your machine;
4) cdroot=LABEL=PENDRIVE, PLEASE change to your actual usb device name,
   you may use like "cdroot=/dev/sdc1", but it may be different for each time
   so you may want to use your file system label, like I'm using
   "PENDRIVE" as vfat label for my /dev/sdc1;
5) isoboot=gentoo/gentoo12.iso, when I copied the iso, I just renamed it to
   this shorter name, please change it to your actual iso name,
   this is relative to root of the usb; because it's read by linux init scripts
6) initrd=../boot/gentoo12.xz, same as above "../boot/gentoo" change;
7) doload=ehci-hcd,usb-storage, to make sure usb-storage kernel module load,
   since I was using "nodetect" to save time booting;

After this boot and user login, the usb content is available in Nautilus or other similar file manager, mounted at "/mnt/iso" by init scripts, this is kind of confusing, but I was trying to keep above changes to init scripts as minimum,

And "/mnt/iso" is default by init scripts mounted as read-only, the user could sudo "mount -o remount,rw /mnt/iso" to make it read-write; and I have another change to make it default read-write;

The "/mnt/iso" is not umount-able since the actual gentoo12.iso is loop mounted from there, and layered with a tmpfs to the runtime root;


Thanks!
Comment 3 r01 2012-05-25 22:50:11 UTC
(In reply to comment #1)
> point #2 is invalid since once you run 'dd' on the usb you are able to
> create additional partitions to utilize the remaining space on the usb
> device. The problem with running dd on an existing usb device is that all
> data currently on that usb device will be destroyed.
> 
> Please attach any patches so that we can test and evaluate your propose
> change. Thanks for contributing!
> 
> likewhoa

I don't agree #2 is invalid since after dd'ed, you can't simply calculate the exact cylinders used by the dd'ing iso; so to create a 2nd partition to use the remaining space, you need to estimate or reverse some space after the space used by the iso; it's not straightforward to use it;

Recently I also considered the Ubuntu capser scripts (use iso-scan/filename=.../path/to/iso and Debian-live project (use fromiso=... parameters) they are more flexible and could read write the usb stick during live desktop runtime;
Comment 4 r01 2012-05-26 21:53:09 UTC
is there any source control repository about the initramfs scripts?

I hope we could merge this before next Gentoo LiveDVD release
Comment 5 Fernando (likewhoa) 2013-03-08 06:48:36 UTC
this is nice but it cannot be automated on our end and would require user interaction which is not the way it's being used now with the 'dd' command. I regret that the dd method wipe all partitions from the removable device but this is by-design and until that is improved we cannot use this suggested method.

closing.