Welcome
Welcome to refracta

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today!

(experimental) Alternative usb installation method

Stuff that has not yet gone into the official build.

(experimental) Alternative usb installation method

Postby dzz » Tue Jan 10, 2012 2:11 am

There are various ways to get a bootable live system on a usb pendrive (unetbootin, dd, isohybrid...) and usually involve formatting or overwriting the entire drive, i,e, data is destroyed. This is not always necessary.

All that's needed is a device with a valid mbr, a fat filesystem and syslinux configured. Multiboot is then possible. If the drive must be processed first standard Debian cli tools can do the job.

That done, Debian live-boot (even current sid) has some limitations that probably won't change anytime soon.

1. It can boot "fromiso" but the device (/dev/whatever) must be specified. That might be different on another machine. Otherwise you have to extract the squashfs.

2. The live-media partition gets mounted read-only. It must be large enough for one or more live images. You can't save data to it. You can't use it for persistence. Sure you can partition but then less usable RW space.

A named iso *can* be searched and found without specifying it's device (thanks GRML) and the live-media partition does *not* have to be RO !

I made a gui application (deb) for an initial usb setup, which will boot a Debian-Live system direct from ISO ("findiso"), with persistence and "live" write access, using a pendrive with a single FAT32 partition.

It does not alter any existing Debian live-boot files but generates a modified initrd for the live-boot media only. It can use a live iso on disk or use the squashfs while in a live session.

This (experimental) version is for Refracta:

http://www.exe-linux.fastfishwebsolutio ... .3_all.deb

Dependencies ex-current Refracta: pmount, fuseiso, pv

Testers appreciated, more later if anyone is interested. Other ideas for usb installs, multiboot methods or syslinux in general?
dzz
 
Posts: 647
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: (experimental) Alternative usb installation method

Postby fsmithred » Tue Jan 10, 2012 9:26 pm

It's not working for me. First I tried single FAT partition from live system, and I get 'boot error' when I try to boot the usb stick. Doing 'install-mbr /dev/sdb' didn't help. Zeroing the first 512 bytes of the stick before the procedure didn't help. There was nothing unusual in the error log (just mke2fs output, three lines.) I had the same result with exegnu2usb a few days ago.

Tried two FAT32 partitions from live system, and then tried one FAT and one ext2. Error output of the last attempt is below. I think previous error log said the same thing, but I didn't save it.
Code: Select all
mke2fs 1.41.12 (17-May-2010)
mkfs.ext2: No such file or directory while trying to determine filesystem size
/sbin/tune2fs: No such file or directory while trying to open /media/sdb2/snapshot/live-rw
Couldn't find valid filesystem superblock.
Logical sector size is zero.


In all cases, I tried to make the live-rw file 2GB on a 4GB stick. Any reason why that's limited to 2GB?
User avatar
fsmithred
 
Posts: 2101
Joined: Wed Mar 09, 2011 9:13 pm

Re: (experimental) Alternative usb installation method

Postby dzz » Wed Jan 11, 2012 1:36 am

Thanks for testing. It works here, I tried before starting this thread with the iso image and live session options, in latest refracta, success both times. But I did say, it's experimental.

That's why I asked for testers, I would like this to work universally but might need some help. The exegnu version doesn't have the right menu for a "preconfigured user" system (refracta)

I have one 16GB single-fat stick running here with 3 different menu-selectable operating systems, submenus with alt configs and optional persistence on all (and a couple of smaller devices for testing)

For now I can't look at dual partitions or ext2, it was only put in to keep in a "debian default" option and haven't even tested that here yet, single-fat is my main interest. Although, a manually created partition labelled "live-rw" or "home-rw" should be automatically found, as should a loopback file in the root of any partition whatever filesystem.

The device should be unplugged when the (gui) application is first started and formatted FAT32 with the boot flag checked. It must have already a valid mbr. Did anything at all get copied to the device? These directories should be there: syslinux, snapshot and "data" The mk2fs error sounds like the live-rw did not get created.

The standard command (device umounted) is:

Code: Select all
syslinux -d ${BOOTDIR} /dev/${DEVICE}1


where $BOOTDIR (usually /syslinux but doesn't have to be) contains the syslinux files including menu.cfg

Syslinux is designed to boot FAT filesystems. If after that is cannot at least boot to the syslinux menu, something is not right with the format or mbr of the device. If you get "boot errors" syslinux must not have installed properly.

Some usb sticks (new, M$-centric ones) won't boot, sometimes just a reformat sorts it, sometimes <install-mbr /dev/sdx> then a reformat. Some maybe have mbr that is not 512.

In extreme cases there is the *nuclear option* (make sure it really is sdb)

Code: Select all
dd if=/dev/zero of=/dev/sdb


(best replug it first) EDIT (this might be incorrect): gparted should sort the rest without <install-mbr>. If that doesn't get syslinux going all that's left is try another stick or howl at the moon.

BTW almost any perverse act can be commited on a FAT filesystem as normal user! It may be antiquated and horrible but is used on removables because it's universally readable wherever it is plugged

I thought (is that incorrect?) 2GB was the max filesize for FAT
Last edited by dzz on Wed Jan 11, 2012 10:43 pm, edited 1 time in total.
dzz
 
Posts: 647
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: (experimental) Alternative usb installation method

Postby dzz » Wed Jan 11, 2012 1:06 pm

great news... after a long absence http://www.syslinux.org/wiki/index.php/SYSLINUX is back
dzz
 
Posts: 647
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: (experimental) Alternative usb installation method

Postby fsmithred » Wed Jan 11, 2012 3:58 pm

The boot menu never comes up. Just a bios message, "Boot error." I tried with two sticks that boot normally if I image them with the isohybrid or my usb image that uses grub. Tried zeroing the entire stick, replugged, ran gparted from snapshot2usb, created partition table, created single fat32 partition, flagged it as bootable, selected single partition from live, let the rest of the script run without error, reboot. Boot error.

Also tried 'syslinux -d /syslinux /dev/sdb1' with same result.

Here's what's on the stick:
Code: Select all
# tree /media/snaplive/
/media/snaplive/
├── data
├── snapshot
│   ├── filesystem.squashfs
│   ├── initrd.gz
│   └── vmlinuz
└── syslinux
    ├── chain.c32
    ├── ldlinux.sys
    ├── splash.jpg
    ├── syslinux.cfg
    └── vesamenu.c32

3 directories, 8 files
User avatar
fsmithred
 
Posts: 2101
Joined: Wed Mar 09, 2011 9:13 pm

Re: (experimental) Alternative usb installation method

Postby dzz » Wed Jan 11, 2012 10:33 pm

It's all there except the mbr boot code (first 446 must still be zeros)

I did some tests on a spare stick, syslinux directories manually copied. Real device here is sdd, I replaced below with sdX:

(zero the first 446 of mbr, partition table should remain intact)

Code: Select all
dd conv=notrunc bs=446 count=1 if=/dev/zero of=/dev/sdX
syslinux -d syslinux /dev/sdX1

It wound not boot to a menu, just a flashing cursor.

Next:
Code: Select all
/sbin/install-mbr /dev/sdX
syslinux -d syslinux /dev/sdX1

There it is! menu is up.(syslinux command may have been unecessary)

best replug it first) gparted should sort the rest without <install-mbr>.

Is obviously incorrect, I wrote that after chainloading the stick from grub (which worked even with the first 446 zeroed), that's not the same as the stick booting independently!

Conclusion is, the syslinux command itself seems not to write mbr boot code, you have to do that seperately

Here is an alternative to install-mbr, from the syslinux wiki:
Code: Select all
dd conv=notrunc bs=440 count=1 if=/usr/lib/syslinux/mbr.bin of=/dev/sdX

I would be surprised if your stick(s) won't boot after that.

Some links relevant to usb boot:

http://blog.bwysystems.com/bwysystems/?p=10
http://www.kelvinism.com/howtos/install ... ortex86dx/
http://www.debian.org/releases/etch/i38 ... 04.html.en
http://wiki.debian.org/InstallToUsbMemoryStick
http://en.wikipedia.org/wiki/Master_boot_record
http://www.linuxquestions.org/questions ... ry-606489/
http://www.syslinux.org/wiki/index.php/ ... _For_Linux
http://forums.debian.net/viewtopic.php?f=3&t=59695
dzz
 
Posts: 647
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: (experimental) Alternative usb installation method

Postby dzz » Thu Jan 12, 2012 7:07 pm

Seems the "syslinux" command actually writes to the partition boot sector (hence "syslinux/dev/sdX1") which will point to ldlinux.sys (I made more sense from an Arch wiki page than syslinux!) so yes, if it is not right already, mbr will need fixing manually (e.g. it has grub or is zeroed) Five pendrives here and they all boot syslinux menu.

I do think, mbr manipulation (and partitioning) is too dangerous to be included in a script anyway, too easy to get the wrong drive trashed.

Re the dual partition option: There is a script error, it tries to write live-rw to a non-existing directory, A fixed version will be ready shortly. In the meantime, to create live-rw (or home-rw) manually is simple:
Code: Select all
'# ${SIZE} is required  in megabytes, e.g. 1000
dd 'if=/dev/zero' of=/media/diskmountpoint/live-rw bs=1024 count=${SIZE}000   
#format it ext2 and stop fsack
/sbin/mkfs.ext2 -F /media/diskmountpoint/live-rw
/sbin/tune2fs -c 0 /media/diskmountpoint/live-rw


If you place live-rw in a directory, you must specify "persistent persistent-path=/directory_name" at cmdline (syslinux.cfg 'append') Live-boot will scan all partitions for live-rw and use the first one it finds, so be sure there is not another elsewhere it can see

Another issue is the "case" of file/directory names on FAT, e.g. live-boot won't find /SNAPSHOT/live-rw if it's looking for /snapshot/live-rw. Seems the first write to a newly-formatted FAT system always comes out uppercase, I'm still looking into that one but found a workaround for now and included it in the script

Found another limitation in the "Debian-standard" 2-partition method: Can't access the rw partition at all, even RO
dzz
 
Posts: 647
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: (experimental) Alternative usb installation method

Postby fsmithred » Fri Jan 13, 2012 6:26 pm

Still no luck with snapshot2usb, but I am making progress. The directions for debian netinstall worked - http://blog.bwysystems.com/bwysystems/?p=10 but the stick only booted on one of the two test computers. Then I replaced some files, and the stick boots to the latest Refracta.

Here's what I think I did:
Code: Select all
dd if=/dev/zero of=/dev/sdX    (let it run for a few seconds for about 50mb)
gparted - create partition table and single vfat. make it bootable.
install-mbr /dev/sdX
syslinux /dev/sdX1
copied live/ folder from mounted iso
copied syslinux.cfg from snapshot2usb.deb into root of usb
copied vesamenu.c32 and splash.png from isolinux/ folder of mounted iso into root of usb.
edited syslinux.cfg to say 'initrd.img' instead of 'initrd.gz'.
boot the stick. It worked in the second computer I tried* (see below).

# For persistence to work,
# create live-rw file:
cd /media/disk
dd 'if=/dev/zero' of=live-rw bs=1024 count=2000000   
#format it ext2 and stop fsack
/sbin/mkfs.ext2 -F live-rw
/sbin/tune2fs -c 0 live-rw

Here's the directory structure on the stick:
.
├── ldlinux.sys
├── live
│   ├── filesystem.squashfs
│   ├── initrd.img
│   ├── memtest
│   └── vmlinuz
├── live-rw
├── Refracta
│   ├── package_list
│   └── Release_Notes
├── splash.png
├── syslinux.cfg
└── vesamenu.c32

* worked on Sempron-64 on ASUS motherboard (about six years old), but not on Dell Core2-duo (about four years old). The Dell gives 'boot error' message after post.

User avatar
fsmithred
 
Posts: 2101
Joined: Wed Mar 09, 2011 9:13 pm

Re: (experimental) Alternative usb installation method

Postby dzz » Sat Jan 14, 2012 2:29 am

Firstly, really appreciated you find time to test this! I have read this subject (getting usb to boot at all) described as a "black art"

So it boots syslinux on one but not another, therefore the stick itself is actually bootable. Bios setting? I done this before on a core2 dell.

snapshot2usb should now work except, possibly the "default location" loose syslinux files and the /live directory might be a problem (i.e. confuse live-boot), snapshot2usb puts them all in named directories and configures syslinux and menu accordingly, as well as keeping them tidy that makes multiboot possible.

BTW You can't use a persist file on the same partition as the live-media with a standard initrd (snapshot2usb modifies it)

snapshot2usb has a simple, one-file syslinux.cfg and splash but it is possible (tested) to chain the complete default refracta menu (with a few pointer edits) or any other. Which is, of course, editable direct from the live session in rw mode!

Updated (not final) deb with script changes and extra bit in the "readme" on mbr and formatting:

http://exe-linux.fastfishwebsolutions.c ... +1_all.deb

EDIT (quote from < man syslinux > options )

-s, --stupid
Install a "safe, slow and stupid" version of SYSLINUX. This ver‐
sion may work on some very buggy BIOSes on which SYSLINUX would
otherwise fail. If you find a machine on which the -s option is
required to make it boot reliably, please send as much info
about your machine as you can, and include the failure mode.


Bug in Squeeze version: "-s" doesn't work, use --stupid.

e.g. < syslinux -i --stupid -d syslinux /dev/sdX1 > ( -i means overwrite existing) might work for the dell.

I can't test that here, all my machines boot syslinux normally from usb. Still looking at some of the other options.
dzz
 
Posts: 647
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: (experimental) Alternative usb installation method

Postby dzz » Sat Feb 11, 2012 12:34 pm

Tested snapshot2usb today on a new, still-packaged 4GB Kingston DataTraveller 101

It was already FAT32 and flagged "bootable". I reformatted just to clean out the preinstalled "urdrive" software.

Worked immediately, no messing with mbr required..
dzz
 
Posts: 647
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Next

Return to Experimental

Who is online

Users browsing this forum: No registered users and 0 guests

cron
suspicion-preferred