Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 31 Oct 2014, 23:19
All times are UTC - 4
 Forum index » Taking the Puppy out for a walk » Puppy Power
Bash script for installing Puppy to USB
Moderators: Flash, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [9 Posts]  
Author Message
raffy

Joined: 25 May 2005
Posts: 4785
Location: Manila

PostPosted: Wed 09 Dec 2009, 14:14    Post subject:  Bash script for installing Puppy to USB
Subject description: From Abhay Chinivar - use this to make USB installation automatic
 

Here's from the mailbox - an auto-installer to USB using Bash. Are there changes needed to make this work in Puppy?
Abhay Chinivar wrote:
I'm an engineering student from India, I use Ubuntu as my main linux OS. I have tried Puppy linux on a CD, and also on a USB and I liked it a lot, esp. cos of it's small size and "amazing speed", it's a really good work by you people (my old outdated 128 mb usb device suddenly was in demand, thanks to Puppy Smile ). And when many of my friends started to come with their USBs to have puppy installed, I thought of writing a bash script to do the installation right from my host OS (ubuntu) so that I don't have to insert the Puppy Linux CD and restart my computer every time just to have Puppy installed on a friend's USB. So this motivated me to learn and write my first bash script - "a script which would install Puppy Linux on a USB flash drive from a host linux OS" (something like the one which the SLAX distro has). This is my first bash script, so it might not be the most efficient way of doing the job, but it definitely works and I guess it's quite simple to use it too (I've tested it on Puppy 4.2.1 release). Later I shared this script on our college lug site (linux users group) for college students to download and run. Now I thought of posting it to you people hoping it will be of some use on the site. Hope to hear from you soon, thank you.
I couldn't find a place on the site to upload the file, so i'm copying the code below, here it is:

* Snip * ---> See the corrected code below.

_________________
Puppy user since Oct 2004. Want FreeOffice? Get the sfs (English only).

Last edited by raffy on Wed 09 Dec 2009, 19:01; edited 1 time in total
Back to top
View user's profile Send private message 
Abhay

Joined: 09 Dec 2009
Posts: 23

PostPosted: Wed 09 Dec 2009, 18:29    Post subject: Bash script to install Puppy on usb without a cd..
Subject description: A small correction..
 

There was a small error while copying the code above i guess.. Here's the correct code, one can install Puppy on usb without having to burn/write a cd.. It's also attached with this post..

Yes, it runs from Puppy also, I just checked, but then it might not be of much use there since Puppy already has the universal installer to install from within Puppy to other devices..

Pls do post ur feedback if this was useful, i'd like to know about whether it was a comfortable install and/or any suggestions on corrections/improvements.. Thank you..

Code:

#!/bin/sh
# install_pup.sh


# This script will install Puppy linux on a usb flash drive.
# The traditional way of doing this is by burning an iso cd,
# then running the live cd to do the installation on a usb flash drive.
# This script will help you install Puppy directly onto a usb drive
# from a host system (i.e. the current linux distro on your computer)
# without having to burn a cd.
# Basically it'll help you save some time and money which you would
# have otherwise spent on the cd :-)


# Brief of tasks done for the installation
# 1. Extracting the iso files
# 2. Finding the devices present and choosing of the device
# 3. Formatting the partition into "fat16" or "fat32"
# 4. Setting boot flag and making boot sector (syslinux)
# 5. Copying files
# 6. Making the config file (syslinux.cfg)
# 7. Ready to Reboot


# Make sure the 2 files, the puppy iso image and this file 'install_pup.sh' are in the
# same directory. Then "cd" to that directory and run the code as a sudoer, or as root.


#    Author: Abhay Chinivar
#   Electrical dept, Final year
#   NIT-Surathkal, Karnataka, India



clear
echo
echo "********Installation of Puppy Linux on a USB drive*********"
echo

# Extracting Files from the iso image

mkdir tempdir
mkdir /mnt/puppy
read -p "Make sure the iso file is in the same directory as the script and pls enter it's name   :" isofile
printf "Extracting files..."
mount -o loop $isofile ./tempdir
echo "                  Done"
echo

# Finding the Devices using 'parted'

parted -l | grep Model > file1
num=$(wc -l file1 | awk '{print $1}')
var=$(expr $num - 1)
parted -l | grep Model | tail -$var | cat > file1
parted -l | grep Disk | tail -$var | cat > file2
sdiff -w 100 file1 file2 | cat > file3

var=$(wc -c file3 | head -c 1)
if [ "$var" = "0" ]; then
   echo "There are no usb devices found, Installation will be terminated"
else

   echo "Below are the devices found"
   echo
   cat -n file3

   echo
   echo "Choose the device on which you wnat to install Puppy"
   read -p "Enter the number of the device from the list above   :" num
   echo

   echo "The chosen device is"
   cat file3 | head -$num | tail -1
   partition=$(cat file2 | head -$num | tail -1 | awk '{print $2}' | head -c 8)
   partnum=1

   echo
   echo "The following mounted partitions are found on $partition"
   printf "   "
   df -Th | head -1
   df -Th | grep $partition | cat -n
   echo
   echo "If you don't find the partition you are looking for in the list above,"
   echo "Mount it and run the code again"
   read -p "Choose one:" num
   df -Th | grep $partition | head -$num | tail -1 > file1
   partnum=$(cat file1 | head -c 9 | tail -c 1)


   echo
   echo "The chosen partition is: "$partition""$partnum""

# Formatting the Partition

   echo
   echo "The partition "$partition""$partnum" will now be formatted, any data in it will be lost"
   echo "Choose 'n' if you want to do a backup of files on your usb drive first"
   read -p "Format the partition? (y/n)      :" choice

   if [ "$choice" = "y" ]; then
      echo
      echo "Choose from the list below the filesystem that you want on your device"
cat > file1 <<"EOF"
fat16
fat32
EOF
      cat -n file1
      read -p "1 or 2?   :" fsnum
      echo "OK..."

      fs=$(cat file1 | head -$fsnum | tail -1)
      echo "The partition "$partition""$partnum" is being formatted to $fs"
      umount "$partition""$partnum"
      parted $partition mkfs Y $partnum $fs > file1
      sleep 3
      umount "$partition""$partnum"
      echo "                        Done"
   else
      echo
      echo "Partition has not been formatted, hence Installation might not happen properly"
   fi

sleep 3

# Installation of Puppy

   echo
   echo "Installation will now start..."
   read -p "Continue? (y/n)   :" choice

   if [ "$choice" = "y" ]; then
      read -p "Do you want Puppy to run on ram?(faster)(y/n)   :" ram
   
      echo
      printf "Setting the boot flag"
      parted $partition set $partnum boot on > file1
      echo "                  Done"

      mount -t vfat "$partition""$partnum" /mnt/puppy

      echo
      printf "Creating boot sector"
      syslinux "$partition""$partnum"
      echo "                  Done"

      echo
      printf "Copying Puppy files onto the usb drive"
      cd tempdir
      var=$(ls)
      cp $var /mnt/puppy
      cd ..
      rm /mnt/puppy/isolinux.cfg /mnt/puppy/isolinux.bin
      echo "            Done"

      touch /mnt/puppy/USBFLASH

      echo
      printf "Creating the configuration file, syslinux.cfg"

cat > /mnt/puppy/syslinux.cfg <<"EOF"
default puppy
display boot.msg
prompt 1 
timeout 80

F1 boot.msg
F2 help.msg

label puppy
kernel vmlinuz
EOF

      if [ "$ram"="y" ]; then
         echo "append initrd=initrd.gz pmedia=usbflash pfix=copy nosmp" >> /mnt/puppy/syslinux.cfg
      else
         echo "append initrd=initrd.gz pmedia=usbflash pfix=noram nosmp" >> /mnt/puppy/syslinux.cfg
      fi
      echo "         Done"

      umount /mnt/puppy

      echo
      echo "***System is ready, you can now reboot and try the new installation***"
      echo "If any error message like 'Missing Operating System' is found when chosen filesystem is 'fat32', try reinstalling by choosing 'fat16' as the filesysem"
   else
      echo "Installation has been terminated"
   fi
fi
echo
printf "Cleaning up..."
umount tempdir
rm -r tempdir
rm -r /mnt/puppy
rm file1 file2 file3
echo "                     Done"
echo

Back to top
View user's profile Send private message 
Abhay

Joined: 09 Dec 2009
Posts: 23

PostPosted: Sun 27 Dec 2009, 02:43    Post subject:  

Extremely sorry if the above script did not work for any of you, when you tried with the newest puppy release, pup-431.. Cos i recently downloaded n installed pup-431.iso n had a problem myself... It was cos the old script searched for a file with name puppy, while t downloaded file was named pup, so it wasn't able to detect t iso file.. now it's corrected in t above post and has been attached with this post.. thank you..
install_pup.tar.gz
Description  The above script is attached here..
gz

 Download 
Filename  install_pup.tar.gz 
Filesize  2.1 KB 
Downloaded  977 Time(s) 
Back to top
View user's profile Send private message 
raffy

Joined: 25 May 2005
Posts: 4785
Location: Manila

PostPosted: Sun 27 Dec 2009, 07:46    Post subject: Thanks  

Thanks, Abhay, and Happy New Year!
_________________
Puppy user since Oct 2004. Want FreeOffice? Get the sfs (English only).
Back to top
View user's profile Send private message 
bill

Joined: 28 May 2008
Posts: 495

PostPosted: Tue 29 Dec 2009, 16:43    Post subject: Thanks for this information  

I managed to get a USB memory stick loaded with 4.3.1 and it works a treat.I do however notice an occasional popup saying "Saving ram to pup-save file" My question is,Is this a temporary file ? that is removed on
shutdown or am I supposed to ferret out the "saves" for deletion.Thanks
Back to top
View user's profile Send private message 
hillside


Joined: 02 Sep 2007
Posts: 642
Location: Minnesota, USA. The frozen north.

PostPosted: Tue 29 Dec 2009, 20:16    Post subject:  

"Saving ram to pup-save file"

When shutting down from the first bootup, you were given the option to build a pup-save file. You apparently said yes. The pup-save file holds all your settings and anything you save inside the operating system. This is a good thing. Instead of saving continually as you work, it does the saves on a schedule to reduce wear on the usb device. You can easily delete things that you don't want to save, for instance, cookies and such.

If you don't want any saves, boot as pfix=ram or don't tell the system to build a save file.
Back to top
View user's profile Send private message 
Abhay

Joined: 09 Dec 2009
Posts: 23

PostPosted: Wed 30 Dec 2009, 07:15    Post subject:  

@raffy: hi raffy, thanks.. wish u too a happy new year Smile i guess, u r one in t puppy developement team right?..
i must say, pup-431 has got nice new features, some of which were very much required by me to start using puppy.. my AMD CPUs get really really hot when run on 1.6 GHz, so much that i've to turn my laptop upside down, n get a table fan pointing at t exhaust place.. now with SMP n t cpu-frequency scaling enabled with this version of puppy kernel, plus t ext4 support, i can happily use it Smile another thing i wanted is some very fast booting OS also installed along with t ones i have, so that i can do some urgent work like checking mails etc.. i made a small, 2GB, extended partition on my hard drive n made a full install of puppy (yes, 2 GB is more than enuf for a full install of puppy Smile ) now i have like 4 OSes on my hard disk Smile - Kubuntu 9.10, Puppy, Vista n ENGInux (an ubuntu based distro filled with frequently required engineering tools that i had built for my college)
After installing, I boot puppy, n i find t most amazing feature of them all, a 23 second 'boot + login' time, never seen something booting this fast on my comp.. yes, this means, i press t start button on my laptop n exactly 23 seconds later i can click on "browse" to start browsing Smile n another thing, connecting to my motorola mobile's gprs modem was also very easy.. something which my vista could never succeed in.. so thanks a lot guys for this OS, hope to have a good Puppy experience ahead..

@bill: yes bill, as hillside said, that's what is mostly happening.. in frugal install, puppy saves t configuration changes made when u r logged in, (xorg.conf, wallpaper n theme change etc) n t new softwares installed, into a file called "pup-save.2fs" (correct me if t file name is wrong), which is then used every time u boot to set up t same configuration which u had before shutting down.. basically nothing to worry about Smile
Back to top
View user's profile Send private message 
bill

Joined: 28 May 2008
Posts: 495

PostPosted: Wed 30 Dec 2009, 17:19    Post subject: http://murga-linux.com/puppy/viewtopic.php?t=49881  

Thanks gentlemen,I appreciate the info.I think I am squared away for the moment,until next time . Wink
Back to top
View user's profile Send private message 
piratesmack


Joined: 16 Sep 2009
Posts: 100

PostPosted: Sun 07 Mar 2010, 04:01    Post subject:  

I've written a similar script.

Mine has a few extra features like reformatting the USB drive and copying additional SFS modules. It's attached to this post if anybody is interested.

Code:

Usage:
        pup2usb.sh <OPTIONS>
Options:
-h | --help)
        Display this message.
-f | --format)
        Format USB device.
-i | --infile)
        Specify ISO image.
-o | --outfile)
        Specify USB device.
-s | --safe)
        Use the "safe, slow, and stupid" verion of syslinux. (More compatible)
-m | --modules)
        Copy additional SFS modules to the USB device.
Example:
        pup2usb.sh -f -i pup-431.iso -o /dev/sdc -m devx_431.sfs


Requires syslinux and util-linux-ng
pup2usb.sh.gz
Description  Create bootable Puppy Linux USB
gz

 Download 
Filename  pup2usb.sh.gz 
Filesize  2.12 KB 
Downloaded  841 Time(s) 
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [9 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Taking the Puppy out for a walk » Puppy Power
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1094s ][ Queries: 12 (0.0202s) ][ GZIP on ]