Linux shell script and Windows batch script for usb install?

Post there if you plan to contribute to this SystemCd

Should scripts be written to install SysRescCD to usb?

Poll ended at 18 Dec 2008, 17:13

Yes
1
100%
No
0
No votes
 
Total votes: 1

rbeede
Posts: 48
Joined: 16 May 2008, 21:10
Location: U.S.A.
Contact:

Linux shell script and Windows batch script for usb install?

Post by rbeede » 03 Dec 2008, 17:13

Do people think it would be useful to have scripts to automate creation of installing the ISO to a usb drive?

If people think so then I can write one for Linux and one for Windows.

pete.dawgg
Posts: 45
Joined: 29 Nov 2006, 13:31
Location: /dev/kmem

Post by pete.dawgg » 19 Dec 2008, 14:02

nice idea if YOU do the work :wink:

rbeede
Posts: 48
Joined: 16 May 2008, 21:10
Location: U.S.A.
Contact:

Post by rbeede » 19 Dec 2008, 15:34

I'm on vacation for the rest of the year so I will write up some scripts to do so.

Windows doesn't come with anything to extract from an iso. Any recommended tool I should require for the Windows script?

n8bounds
Posts: 59
Joined: 24 Oct 2008, 13:39
Contact:

Post by n8bounds » 19 Dec 2008, 19:11

7zip (FOSS) can unroll ISO9669 files in winbloze. There's a CLI ver too.

rbeede
Posts: 48
Joined: 16 May 2008, 21:10
Location: U.S.A.
Contact:

Post by rbeede » 19 Dec 2008, 23:21

The question is should I

Assume the 7z command line client is in the system path
Assume it is located in C:\Program Files\7-Zip
Ask where it is

I don't think I could expect it to be bundled onto the System Rescue CD.

Perhaps I'll just make it a variable in the beginning of the script that can be changed manually if needed.

rbeede
Posts: 48
Joined: 16 May 2008, 21:10
Location: U.S.A.
Contact:

Post by rbeede » 20 Dec 2008, 17:00

[edit 2009-01-30] This is for versions 1.1.3 and below

Here is my first attempt at a Windows batch script. It assumes you have 7-Zip (recent version) installed in C:\Program Files\7-Zip and that the desired ISO is in the same directory as the script.

It also assumes that target drive is already formatted in FAT/FAT32.

I don't see an option to attach files to this post, so I'll try good old copy and paste.

Code: Select all

@ECHO OFF
SETLOCAL

REM	Author:  Rodney Beede <contactme -AT- rodneybeede -DOT- com>
REM	First Version:  2008-12-19
REM	License:  Public Domain


REM	You may need to change ISO_EXTRACT_PROGRAM and ISO_EXTRACT_PROGRAM_OPTS to
REM	match any different programs you wish to use
REM	They are set below at the ***** CHANGEABLE OPTIONS ***** section



ECHO This script allows you to extract the contents of the System Rescue CD ISO
ECHO onto a disk drive of your choice.
ECHO.
ECHO You must run this script as an Administrator
ECHO.
ECHO The ISO should be located in the same directory as this script
ECHO.
ECHO The usb drive must already have a FAT or FAT32 filesystem
ECHO.
ECHO Tested to work with Windows XP SP2+ and Windows Vista SP1+ with version
ECHO	1.1.3 of System Rescue CD
ECHO.
ECHO.


SET /P TARGET_DRIVE=Enter in the drive letter of the usb key:  


IF "" EQU "%TARGET_DRIVE%" (
	ECHO You MUST enter a drive letter
	EXIT /B
	)



REM	***** CHANGEABLE OPTIONS *****

REM	What program to run to extract files from the ISO (no "")
SET ISO_EXTRACT_PROGRAM=C:\Program Files\7-Zip\7z.exe

REM	Options to append after the ISO_EXTRACT_PROGRAM command
SET ISO_EXTRACT_PROGRAM_OPTS=x -o%TARGET_DRIVE%:\ -r

REM	***** END CHANGEABLE OPTIONS *****



REM	Determine the ISO to use
FOR %%i IN (%~dp0systemrescuecd-*.iso) DO SET ISO_FILE=%%i

IF "" EQU "%ISO_FILE%" (
	ECHO Could not find ISO in %~dp0
	EXIT /B
) ELSE (
	ECHO Using %ISO_FILE%
	ECHO.
)



"%ISO_EXTRACT_PROGRAM%" %ISO_EXTRACT_PROGRAM_OPTS% "%ISO_FILE%" *



REM	Prepare SysLinux 
FOR %%i IN (%TARGET_DRIVE%:\syslinux\syslinux-*.zip) DO SET SYSLINUX_ZIP=%%i

"%ISO_EXTRACT_PROGRAM%" %ISO_EXTRACT_PROGRAM_OPTS% "%SYSLINUX_ZIP%" win32\syslinux.exe

MOVE %TARGET_DRIVE%:\win32\syslinux.exe %TARGET_DRIVE%:\syslinux.exe

RMDIR /S /Q %TARGET_DRIVE%:\win32



REM	Move the SysLinux items into place

MOVE %TARGET_DRIVE%:\isolinux\isolinux.cfg %TARGET_DRIVE%:\isolinux\syslinux.cfg

RMDIR /S /Q %TARGET_DRIVE%:\syslinux

MOVE %TARGET_DRIVE%:\isolinux %TARGET_DRIVE%:\syslinux



REM	Make usb drive bootable (writes mbr)

%TARGET_DRIVE%:\syslinux.exe -maf %TARGET_DRIVE%:


ECHO ALL DONE
Last edited by rbeede on 30 Jan 2009, 18:15, edited 2 times in total.

rbeede
Posts: 48
Joined: 16 May 2008, 21:10
Location: U.S.A.
Contact:

Post by rbeede » 20 Dec 2008, 17:10

Note that this will only work for 1.1.3. 1.1.4 beta appears to change the location of syslinux.zip. I'll modify the script appropriately once 1.1.4 is final.

Also of note is that chapter 10 of the manual has simplified instructions on making a usb key so a batch script may not really be needed.

jadjay
Posts: 19
Joined: 15 Nov 2008, 00:54

Post by jadjay » 30 Jan 2009, 15:28

It could be a great idea, every simplification is good!

Write It !!! :twisted:

rbeede
Posts: 48
Joined: 16 May 2008, 21:10
Location: U.S.A.
Contact:

Post by rbeede » 01 Feb 2009, 02:19

Here is an updated version of the Windows batch script for creating the USB disk. It assumes:

  • You have 7-Zip installed in C:\Program Files\7-zip

    You can run the script with Administrator rights

    The ISO is in the same folder as the script

    The drive is already formatted with FAT/FAT32

    The ISO is System Rescue CD version 1.1.4 or later

Code: Select all

@ECHO OFF
SETLOCAL 

REM   Author:  Rodney Beede <contactme -AT- rodneybeede -DOT- com> 
REM   First Version:  2009-01-31 
REM   License:  Public Domain 

REM   For System Rescue CD 1.1.4 and later


REM   You may need to change ISO_EXTRACT_PROGRAM and ISO_EXTRACT_PROGRAM_OPTS to 
REM   match any different programs you wish to use 
REM   They are set below at the ***** CHANGEABLE OPTIONS ***** section 



ECHO This script allows you to extract the contents of the System Rescue CD ISO 
ECHO onto a disk drive of your choice. 
ECHO. 
ECHO You must run this script as an Administrator 
ECHO. 
ECHO The ISO should be located in the same directory as this script 
ECHO. 
ECHO The usb drive must already have a FAT or FAT32 filesystem 
ECHO. 
ECHO Tested to work with Windows XP SP2+ and Windows Vista SP1+ with version 
ECHO   1.1.4 of System Rescue CD 
ECHO. 
ECHO. 


SET /P TARGET_DRIVE=Enter in the drive letter of the usb key:  


IF "" EQU "%TARGET_DRIVE%" ( 
   ECHO You MUST enter a drive letter 
   EXIT /B 
   ) 



REM   ***** CHANGEABLE OPTIONS ***** 

REM   What program to run to extract files from the ISO (no "") 
SET ISO_EXTRACT_PROGRAM=C:\Program Files\7-Zip\7z.exe 

REM   Options to append after the ISO_EXTRACT_PROGRAM command 
SET ISO_EXTRACT_PROGRAM_OPTS=x -o%TARGET_DRIVE%:\ -r 

REM   ***** END CHANGEABLE OPTIONS ***** 



REM   Determine the ISO to use 
FOR %%i IN (%~dp0systemrescuecd-*.iso) DO SET ISO_FILE=%%i 

IF "" EQU "%ISO_FILE%" ( 
   ECHO Could not find ISO in %~dp0 
   EXIT /B 
) ELSE ( 
   ECHO Using %ISO_FILE% 
   ECHO. 
) 


REM   Extract the entire ISO contents
"%ISO_EXTRACT_PROGRAM%" %ISO_EXTRACT_PROGRAM_OPTS% "%ISO_FILE%" * 



REM   Prepare SysLinux 
FOR %%i IN (%TARGET_DRIVE%:\bootprog\syslinux-*.zip) DO SET SYSLINUX_ZIP=%%i 

"%ISO_EXTRACT_PROGRAM%" %ISO_EXTRACT_PROGRAM_OPTS% "%SYSLINUX_ZIP%" win32\syslinux.exe 

MOVE %TARGET_DRIVE%:\win32\syslinux.exe %TARGET_DRIVE%:\syslinux.exe 

RMDIR /S /Q %TARGET_DRIVE%:\win32 



REM   Move the SysLinux items into place 

MOVE %TARGET_DRIVE%:\isolinux\isolinux.cfg %TARGET_DRIVE%:\isolinux\syslinux.cfg 

MOVE %TARGET_DRIVE%:\isolinux %TARGET_DRIVE%:\syslinux 



REM   Make usb drive bootable (writes mbr) 

%TARGET_DRIVE%:\syslinux.exe -maf %TARGET_DRIVE%: 


ECHO ALL DONE

jadjay
Posts: 19
Joined: 15 Nov 2008, 00:54

USB Booting

Post by jadjay » 02 Feb 2009, 07:56

Hi all,

I did something for few months when someone ask for the USBrescue, i made an image of my key and i dd it to his key like that:

dd if=/dev/mykey of=SYSRESCUSB.img

then

dd if=SYSRESCUSB.img of=/dev/hiskey

and it works great!

So maybe we could share on or two image (different language or different options)...

And make a tutorial (much more simple than the actual!!!)

admin
Site Admin
Posts: 2715
Joined: 17 Jul 2003, 09:44

Post by admin » 02 Feb 2009, 19:15

It may work, you replace the MBR with the partition table, so you assume all the usb keys have the same size.

jadjay
Posts: 19
Joined: 15 Nov 2008, 00:54

Post by jadjay » 02 Feb 2009, 20:54

I'm sorry but you're wrong

You have to specify a minimum size for the key, and then with gparted, you can exploit the rest with a second partition, wich work on linux (you will see two partition, or 3 or 4 :) but doesn't work on windows... You know the professional solution leader in IT which is unable to mount more than one partition on a usb key ;p

Thus I am sorry but I don't have to minimize a solution because they can't make proper OS, they doesn't do the same for us, so... (i can't say it in english maybe you can translate : "Je ne vois pas pourquoi on réduirais nos possibilités pour s'abaisser à une compatibilité avec le leader des IT, ils ne le font pas pour nous, et ce n'est pas ma faute s'il ne donne pas la possibilités de monter une clé multipartition, donc...") Thus i didn't use m$ stuff... so I don't care...

I mean ok this is bad from my part but I really HATE m$ solutions, they gave me much more trouble than Gnu tools for years. They are there just to minimize the possibles for their own users, and they're the dark side, we just need to defeat them by showing proper solutions to their users... I know this is bad to think like that, but I don't care :)

Maybe it would be better with grub on the key but i didn't try yet so i can't send an exemple...

For the instant my key is about 400Mo but maybe less, if you need an image I will be happy to send you one... for french users... ;p


Remember GNu has users, wdws has prisonners...

rbeede
Posts: 48
Joined: 16 May 2008, 21:10
Location: U.S.A.
Contact:

Post by rbeede » 02 Feb 2009, 23:53

Having one large partition is useful when you boot the freedos image and want to flash a bios. Thus I prefer creating the disk myself versus dd an image onto it with a fixed smaller size. That's my personal preference though.

jadjay
Posts: 19
Joined: 15 Nov 2008, 00:54

Post by jadjay » 03 Feb 2009, 07:50

You don't care ! you could resize it after... Fixing a small partition is for download convenience, but afterwards you could resize it with gparted...

jadjay
Posts: 19
Joined: 15 Nov 2008, 00:54

Post by jadjay » 03 Feb 2009, 08:08

In fact the things why i propose to dd an image is for n00b, watch the tuto :

Download this : sysres.img
check your key with cat /etc/mtab
do this : dd if=sysres.img of=/dev/hdX

done, you have a brand new sysrescUSB

If you want to enlarge your partition, use gparted


Well five line... And this would be better with grub version and ext3 partition...

Post Reply