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.

Re: (experimental) Alternative usb installation method

Postby fsmithred » Sun Apr 14, 2013 1:18 am

The "Edit boot menu" option only works properly if you already created the encrypted partition. If you only created an ext2 partition, and you didn't encrypt it yet, it'll still add the menu entry for booting with hooks, but the uuid will be wrong. Run this option again after you ran mkusbcrypt.

Yeah, that's kinda dumb - plug the stick into a running linux system to put the OS on it, boot the stick, create the encrypted home, then plug the stick into a running system again to add the menu entry with the correct uuid.
User avatar
fsmithred
 
Posts: 2101
Joined: Wed Mar 09, 2011 9:13 pm

Re: (experimental) Alternative usb installation method

Postby fsmithred » Sun Apr 14, 2013 6:28 pm

The following procedure worked to restore a usb stick after previous imaging with isohybrid or with grub bootloader. It was not necessary to zero any part of the drive.

Open gparted on its own or through refracta2usb.
Create New Partition Table.
Create Partitions. (including a fat32 with boot flag)
Exit gparted and create a live usb from iso.
As user, do
Code: Select all
dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/mbr.bin of=/dev/<sdX>


Done.

Is there any reason why that dd command should not be run whenever we run
'syslinux -d syslinux <device>'?

An advantage of this over using install-mbr is that you don't have to type a number to boot. (I suppose that might be a disadvantage if you had multiple bootable partitions.)
User avatar
fsmithred
 
Posts: 2101
Joined: Wed Mar 09, 2011 9:13 pm

Re: (experimental) Alternative usb installation method

Postby dzz » Sun Apr 14, 2013 9:39 pm

That's the mbr that syslinux provides.. Because you dd only the first 440 the partition table doen't get trashed. Install-mbr is a generic Debian utility (which also works for syslinux)

Only reason I kept that sort of stuff out of experimental scripts before was to keep out potentially destructive elements (like the wrong disk getting trashed). The syslinux command is relatively safe as it installs only to partition boot sector.

Fortunately none of this should need root to deal with a FAT removable. I never tested what would happen if run on a fixed disk by mistake. DD (and rm -rf) can bite in unexpected places.
dzz
 
Posts: 647
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: (experimental) Alternative usb installation method

Postby fsmithred » Tue Apr 16, 2013 1:17 pm

I tested it on a fixed disk, but I had to hack the script to do it. I think I hard-coded $usb_mountpoint to do that.

Latest iteration has an Options window where you can change some settings, including allowing you to write to mbr. Also added a couple of tests. Here's a good one that I added to the check_device function (which used to be part of the detect function).
Code: Select all
# Check that first partition exists (blkid still shows result after zeroing device)
if ! $(/sbin/fdisk -l | grep -q "/dev/${DEVICE}1") ; then
   echo "/dev/${DEVICE}1 does not exist."
   exit_message="\nDevice /dev/${DEVICE}1 does not exist.
Maybe you need to format it?"
   exit_dialog
fi


Also fixed a bug in copy_livemount so that it only tries to convert isolinux to syslinux if there is an isolinux to convert (i.e. you're running a live CD as opposed to running a live-USB. And when it gets to installing syslinux, if there's no syslinux folder, it gives you the option to copy the default Refracta syslinux folder. I ran into that problem when I ran a live session on a usb that uses grub. There's no /lib/live/mount/medium/syslinux folder.

Also working on excludes list for mkusbcrypt and for copy_livemount. It's different from the others. The root of the rsync transfer is /home/ so right now, the entries are looking like
Code: Select all
- *.Trash*
- *.local/share/Trash/*
- *.gvfs
- *.xsession-errors*
I need to do some more testing with it.
User avatar
fsmithred
 
Posts: 2101
Joined: Wed Mar 09, 2011 9:13 pm

Re: (experimental) Alternative usb installation method

Postby fsmithred » Thu Apr 18, 2013 10:09 am

Some new code -

Notes: You can put a variable in the TRUE/FALSE column of a yad/zenity list, set the variable to be either "TRUE" or "FALSE", and the list will show the current status of the variable (checked or unchecked box.)

In the conditionals below that, bash built-ins replace external commands so that:
Code: Select all
if (echo $var |grep -q <pattern>)
becomes
if [[ $var =~ <pattern> ]]
This should be faster, but I doubt we'll notice it.

Code: Select all
# Default settings
# These setting will be overridden by choices made in the Options
# window, including the Cancel button, which will restore defaults
# from the setup_options function, around line 530.
add_hooks="TRUE"
save_hooks="TRUE"
save_boot="TRUE"
save_syslinux="FALSE"
write_to_mbr="FALSE"

# This is a way to set the options for the current run only.
setup_options () {
options=$($DIALOG --list --title="Setup Options" \
   --${BUTTON0}="Continue"${BUTTON0NUM} --${BUTTON1}="Defaults"${BUTTON1NUM} \
     --text=" Change default settings for this run.
Choose Defaults to skip this step and restore program defaults.
Exit to exit the program." \
     --checklist --column "Choose" --column "Num" --column "Option" \
     --width=590 --height=380  \
  $add_hooks 01 "Add hooks for encrypted /home
  " \
  $save_hooks 02 "Preserve an existing hooks folder.
(for Update only)" \
  $save_boot 03 "Preserve an existing /boot/grub folder.
(for Update only)" \
  $save_syslinux 04 "Preserve an existing syslinux folder.
(for Update only)" \
  $write_to_mbr 05 "Write syslinux/mbr.bin to Master Boot Record.
  " \
  FALSE xx "Exit
  ")

   if [[ $? = 1 ]] ; then
      echo -e "\n Resetting default values..."
      add_hooks="TRUE"
      save_hooks="TRUE"
      save_boot="TRUE"
      save_syslinux="FALSE"
      write_to_mbr="FALSE"
      run_task
      return
   fi

   if [[ $options =~ 01 ]] ; then
      add_hooks="TRUE"
   else
      add_hooks="FALSE"
   fi
   
   if [[ $options =~ 02 ]] ; then
      save_hooks="TRUE"
   else
      save_hooks="FALSE"
   fi   

   if [[ $options =~ 03 ]] ; then
      save_boot="TRUE"
   else
      save_boot="FALSE"
   fi

   if [[ $options =~ 04 ]] ; then
      save_syslinux="TRUE"
   else
      save_syslinux="FALSE"
   fi

   if [[ $options =~ 05 ]] ; then
      write_to_mbr="TRUE"
   else
      write_to_mbr="FALSE"
   fi
   
   if [[ $options =~ xx ]] ; then
      exit 0
   fi
   
   run_task
}
User avatar
fsmithred
 
Posts: 2101
Joined: Wed Mar 09, 2011 9:13 pm

Re: (experimental) Alternative usb installation method

Postby fsmithred » Sun Apr 21, 2013 2:53 pm

OK, here's the seventh iteration of this beast. I'm still not very happy with it, because it's too complex. I'm tempted to hide most of the options, so that they're only available to those who are clever enough to find them.

Anyway, I think it all works. One thing I haven't tested yet is to install to usb from a running live-CD. I hope to do that today. (After I make a live CD from a running live-USB. Oy. Reminds me of Lily Tomlin quote about buying a trash can.)

Direct link to tarball -
http://distro.ibiblio.org/refracta/test ... b07.tar.gz
User avatar
fsmithred
 
Posts: 2101
Joined: Wed Mar 09, 2011 9:13 pm

Re: (experimental) Alternative usb installation method

Postby dzz » Thu May 02, 2013 3:02 pm

Running beta11 from manually-installed usb booted "findiso"

I tried refracta2usb to a second pendrive both using the iso and direct from live. In both cases it booted.

However something odd is going on (snip from log):

Code: Select all
syslinux: warning: unable to move ldlinux.sys


The file ldlinux.sys should go to the specifid "-d"

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


Instead it is getting written to the root of the drive. But I can run the syslinux command manually and it works as expected.

Here is the full log:

Code: Select all
process 4698: arguments to dbus_move_error() were incorrect, assertion "(dest) == NULL || !dbus_error_is_set ((dest))" failed in file ../../dbus/dbus-errors.c line 282.
This is normally a bug in some application using the D-Bus library.
libhal.c 3483 : Error unsubscribing to signals, error=The name org.freedesktop.Hal was not provided by any .service files
process 4727: arguments to dbus_move_error() were incorrect, assertion "(dest) == NULL || !dbus_error_is_set ((dest))" failed in file ../../dbus/dbus-errors.c line 282.
This is normally a bug in some application using the D-Bus library.
libhal.c 3483 : Error unsubscribing to signals, error=The name org.freedesktop.Hal was not provided by any .service files

/dev/sdc
sdc

/dev/sdc1
sending incremental file list
./
Release_Notes
isolinux/
isolinux/boot.cat
isolinux/exithelp.cfg
isolinux/f1.txt
isolinux/f2.txt
isolinux/f3.txt
isolinux/f4.txt
isolinux/f5.txt
isolinux/f6.txt
isolinux/f7.txt
isolinux/f8.txt
isolinux/f9.txt
isolinux/isolinux.bin
isolinux/isolinux.cfg
isolinux/live.cfg
isolinux/menu.cfg
isolinux/prompt.cfg
isolinux/splash.png
isolinux/stdmenu.cfg
isolinux/vesamenu.c32
live/
live/filesystem.squashfs
live/initrd.img
live/memtest86+.bin
live/vmlinuz
pkglist_refracta-wheezy-beta11-20130428_2002/
pkglist_refracta-wheezy-beta11-20130428_2002/package_list

sent 725195557 bytes  received 502 bytes  4381849.30 bytes/sec
total size is 725105328  speedup is 1.00
Converting isolinux to syslinux...
Adding Refracta custom hooks...
sending incremental file list
rsync: link_stat "/home/user/hooks" failed: No such file or directory (2)

sent 12 bytes  received 12 bytes  48.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9]
syslinux: warning: unable to move ldlinux.sys
1+0 records in
1+0 records out
440 bytes (440 B) copied, 0.0105281 s, 41.8 kB/s
Live
Live
dzz
 
Posts: 647
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: (experimental) Alternative usb installation method

Postby fsmithred » Fri May 03, 2013 12:50 am

I saw ldlinux.sys in the root at some point during my testing, but I don't know what I did to get it there. I just ran it again, using an iso file for the source, and it worked correctly (ldlinux.sys is in the syslinux directory.) I do get the warnings about not being able to move ldlinux.sys all the time. I thought it might have something to do with renaming isolinux to syslinux,
User avatar
fsmithred
 
Posts: 2101
Joined: Wed Mar 09, 2011 9:13 pm

Re: (experimental) Alternative usb installation method

Postby dzz » Fri May 03, 2013 11:03 am

I suspect this has something to do with files/dirs tagged "read-only"

EDIT sorted (it seems, one test only on a newly-formatted stick using iso).. syslinux wants it umounted

Added after line 533 (install_syslinux function):

Code: Select all
sleep 3
pumount /dev/${DEVICE}1


Changed line 770 (pumount /dev/${DEVICE}1) to:

Code: Select all
if cat /proc/mounts|grep -q "${DEVICE}1"; then
pumount /dev/${DEVICE}1
fi


In addition, if lines 122 and 123 (detect function, which does actually work) are changed to this:

Code: Select all
USBDEVLIST=$(/usr/sbin/hwinfo --usb --short 2>/dev/null |grep "/dev/sd"|awk '{print $1}')
USBDEVFULLLIST=$(/usr/sbin/hwinfo --usb --short 2>/dev/null |grep "/dev/sd"|awk '{print $0}')


the error log won't show those dbus warnings.

BTW other stuff shows up RO after the rsync. I don't know why <chmod u+w> works on vfat like that. It isn't supposed to but in practice it does.. I trawled for more info but so far failed.
dzz
 
Posts: 647
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: (experimental) Alternative usb installation method

Postby fsmithred » Mon May 13, 2013 1:27 pm

refracta2usb-0.9 is available, with the changes you suggested plus one bug fix (wrong path for saving syslinux folder). It's at sourceforge, ibiblio and github. It's also in Refracta_7.0, the official release.
User avatar
fsmithred
 
Posts: 2101
Joined: Wed Mar 09, 2011 9:13 pm

PreviousNext

Return to Experimental

Who is online

Users browsing this forum: No registered users and 0 guests

cron
suspicion-preferred