New IT forum
23 October 2014, 05:10:10 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: PiHub now in stock.
 
   Home   SHOP Help Search Login Register  
Pages: 1 [2]
  Print  
Author Topic: preconfigured Debian SD cards  (Read 14883 times)
ursus
Newbie
*
Posts: 9


« Reply #15 on: 07 May 2010, 09:03:16 pm »

Ok my target reached

debian:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                   256876         0    256876   0% /lib/init/rw
tmpfs                   256876         4    256872   1% /dev/shm
rootfs                 7702424    444276   6866880   7% /
/dev/sda1            307663800    195548 291839820   1% /home
 Grin
Logged
peter a
Full Member
***
Posts: 162


« Reply #16 on: 12 February 2011, 05:24:15 pm »

Hi , Now we have had a debian version of musical chairs where Lenny is now the obsolete ,  Squeeze is now the stable and Wheezy is now the testing.

Here is the script to make the Wheezy rfs, plus my personal tweaks.

Code:
#!/bin/bash

#Script hacked from the original Ubuntu one by Mark Gillespie (mark.gillespie@gmail.com)
#Version History:
#1.0 Initial Release
#1.1 Made debian build path relative, Did a check to ensure it does not go past stage 1 bootstrap on non-armv5 (sheevaplug) hardware, Reminder at end to delete debian build dir.
#1.2 small fix to arch detection.
#1.3 Added sanity check to ensure it's running under BASH, changed packages to include ssh, added some colour to the output, made ehe gziping non-verbose.
#1.4 Fix to ensure the serial console device gets created correctly.  Added an apt package listing in the root of the filesystem, added move verbose messages, removed documents and man pages from the filesystem.
#1.5 Additional Cleanup, single variable to switch between lenny and squeeze.

DIST="testing" # Comment oout this line to make a stable (squeeze) build

#before we go any further, make sure we are running BASH, not that dumb mess that calling sh and getting dash thing that Debian/Ubuntu impmented.
test -n "$BASH_VERSION" || { echo "\033[0;31mERROR:\033[0;39m This script must be run using BASH and not other shells like DASH.\nIf you launched this as 'sh ./$0', try just launching it directly './$0' (after chmoding it +x).\n"; exit 1; }

#setup some bash colours
txtund=$(tput sgr 0 1)    # Underline
txtbld=$(tput bold)       # Bold
txtred=$(tput setaf 1)    # Red
txtgrn=$(tput setaf 2)    # Green
txtylw=$(tput setaf 3)    # Yellow
txtblu=$(tput setaf 4)    # Blue
txtpur=$(tput setaf 5)    # Purple
txtcyn=$(tput setaf 6)    # Cyan
txtwht=$(tput setaf 7)    # White
txtrst=$(tput sgr0)       # Text reset

# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
   echo "${txtred}ERROR:${txtrst} This script must be run as root."
   exit 1
fi


#Make sure we have the latest debootstrap and make a working directory.
apt-get install debootstrap
mkdir -p ./debian

if [ "$DIST" = "testing" ]; then
echo "${txtbld}Stage 1 Debootstrapping Debian Wheezy${txtrst} "
debootstrap --verbose --arch armel --foreign wheezy debian http://ftp.debian.org/debian
else
echo "${txtbld}Stage 1 Debootstrapping Debian Squeeze${txtrst} "
debootstrap --verbose --arch armel --foreign squeeze debian http://ftp.debian.org/debian
fi
if [ $? != 0 ]; then
echo "${txtred}ERROR:${txtrst} Error in debootstrap."
exit -1
fi

# Make sure we are now running on armv5tel arch
# We can only second stage bootstrap on that!
ARCH=`uname -m`
if [[ $ARCH != armv5* ]]; then
   echo "${txtcyn}INFO:${txtrst}From this point on, this script needs to be run on SheeOBvaplug.  You can copy the debian directory and script from this machine to your sheevaplug to continue the build process." 1>&2
   exit 1
fi

if [ "$DIST" = "testing" ]; then
echo "${txtbld}Stage 2 Debootstrapping Debian Wheezy${txtrst}"
else
echo "${txtbld}Stage 2 Debootstrapping Debian Squeeze${txtrst}"
fi

chroot ./debian/ /debootstrap/debootstrap --second-stage

\rm -rf ./debian/debootstrap

mount -o bind /dev ./debian/dev
mount -o bind /proc ./debian/proc
mount -o bind /sys ./debian/sys

# Change root passwd
echo "${txtcyn}INFO:${txtrst}Setting root password to 'nosoup4u'"
echo -e "nosoup4u\nnosoup4u\n" | chroot ./debian/ /usr/bin/passwd root

# Change host name to debian
echo "${txtcyn}INFO:${txtrst}Setting host name to debian"
echo debian > ./debian/etc/hostname

# Add /dev/ttyS0 as the system terminal
echo "${txtcyn}INFO:${txtrst}Creating serial console and disabling real console"
cat > ./debian/etc/inittab << EOF
# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $

# The default runlevel.
id:2:initdefault:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

# Action on special keypress (ALT-UpArrow).
#kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work."

# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop

# Example how to put a getty on a serial line (for a terminal)
#
T0:23:respawn:/sbin/getty -L ttyS0 115200 linux
EOF

# Configure network to be non-dhcp (good for NFS)
# If you need to have dhcp then uncomment the 'auto eth0' line
echo "${txtcyn}INFO:${txtrst}Enabling DHCP on lo, eth0"
cat > ./debian/etc/network/interfaces << EOF
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
EOF

echo "${txtcyn}INFO:${txtrst}Adding bits to reduce flash writes"
cat > ./debian/etc/sysctl.conf << EOF

# See: http://plugcomputer.org/plugwiki/index.php/Reduce_Flash_Writes
vm.swappiness=0
vm.laptop_mode=5
vm.dirty_writeback_centisecs=1500
vm.dirty_expire_centisecs=1500
EOF

cat > ./debian/etc/sysctl.d/10-process-security.con << EOF
vm.mmap_min_addr = 32768
EOF

echo "${txtcyn}INFO:${txtrst}Fixing dependancies"
# Fix dependencies (if there any problems)
chroot ./debian/ /usr/bin/apt-get -y -f install

echo "${txtcyn}INFO:${txtrst}Adding apt sources"
# Add sources.list file
if [ "$DIST" = "testing" ]; then
cat > ./debian/etc/apt/sources.list << EOF
deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free
deb http://security.debian.org/ wheezy/updates main contrib non-free
deb http://download.webmin.com/download/repository sarge contrib
EOF
else
cat > ./debian/etc/apt/sources.list << EOF
deb http://ftp.us.debian.org/debian/ squeeze main contrib non-free
deb http://security.debian.org/ squeeze/updates main contrib non-free
deb http://download.webmin.com/download/repository sarge contrib
EOF
fi


echo "${txtcyn}INFO:${txtrst}Setting up hosts"
# localhost and debian are 127.0.0.1
cat > ./debian/etc/hosts << EOF
127.0.0.1 localhost
127.0.0.1 debian
EOF

echo "${txtcyn}INFO:${txtrst}Setting up nameserver (OpenDNS)"
# Setup nameserver (use OpenDNS by default)
cat > ./debian/etc/resolv.conf << EOF
nameserver 208.67.222.222
nameserver 208.67.220.220
EOF

echo "${txtcyn}INFO:${txtrst}Setting up webmin keys"
chroot ./debian/ wget http://www.webmin.com/jcameron-key.asc
chroot ./debian/ apt-key add jcameron-key.asc

# Touch the net generator udev so that eth0 won't be reassigned in case the user
# changes the MAC address
touch ./debian/etc/udev/rules.d/75-persistent-net-generator.rules

# Now update the apt database
# and install some essential stuff
# seems putting too many on the same line may cause issues
# so do them seperately.
echo "${txtcyn}INFO:${txtrst}Updating apt database"
chroot ./debian/ apt-get update

echo "${txtcyn}INFO:${txtrst}Installing other packages"
chroot ./debian/ apt-get -y --force-yes install openssh-server  openssh-client
chroot ./debian/ apt-get -y --force-yes install rdate dosfstools cron cryptsetup hashalot nano logrotate bzip2 unzip uuid-runtime mtd-utils
# chroot ./debian/ apt-get -y --force-yes install samba apache2 php5 libapache2-mod-php5 python
chroot ./debian/ apt-get -y --force-yes install usbutils ntfs-3g ntfsprogs screen alsa-base ntpdate



echo "${txtcyn}INFO:${txtrst}Performing some cleanups"
chroot ./debian/ apt-get autoremove
chroot ./debian/ apt-get autoclean
chroot ./debian/ dpkg -l |grep '^ii' > ./debian/PackageList.txt
# remove the man pages and docs, these just take up room, and it can be read online these days.
chroot ./debian/ find  /usr/share/doc/ -name '*' -type f -exec rm  {} \; > /dev/null 2>&1
chroot ./debian/ find  /usr/share/man/ -name '*' -type f -exec rm  {} \; > /dev/null 2>&1
chroot ./debian/ find  /usr/share/doc-base/ -name '*' -type f -exec rm  {} \; > /dev/null 2>&1
chroot ./debian/ find  /var/cache/apt/ -name '*' -type f -exec rm  {} \; > /dev/null 2>&1


echo "${txtcyn}INFO:${txtrst}Setting up serial console"
# Setting up ttyS0
chroot ./debian/ rm /dev/ttyS0
chroot ./debian/ mknod -m 660 /dev/ttyS0 c 4 64


echo "${txtcyn}INFO:${txtrst}Unmounting filesystems"
# unmount virtual filesystems
umount ./debian/dev
umount ./debian/proc
umount ./debian/sys

#make the filesystem
echo "${txtcyn}INFO:${txtrst}Building rootfs.tar.gz (this may take a short while)"
cd ./debian
tar czf ../rootfs.tar.gz *
if [ "$DIST" = "testing" ]; then
echo -e "${txtcyn}INFO:${txtrst}Debian Wheezy Build complete!\nYou can now use the Debian rootfs.tar.gz to replace the one in the SheevaInstaller.\n\nDon't forget to delete the debian build directory when you are satisfied it's all working."
else
echo -e "${txtcyn}INFO:${txtrst}Debian Squeeze Build complete!\nYou can now use the Debian rootfs.tar.gz to replace the one in the SheevaInstaller.\n\nDon't forget to delete the debian build directory when you are satisfied it's all working."
fi

Logged
stonerockner
Newbie
*
Posts: 2


« Reply #17 on: 08 June 2011, 02:27:26 pm »

Hi!
Just to get things right and understand a little bit more this thread is all about...

I have a new Dreamplug and want Debian Sqeeze on there...

Several questions:

1) I need a micro sd card, partition it to vfat (i.e. 25MB) and ext3 (i.e. rest of usd)?
2)I then copy the script into a text file? (Minor changes -> i.e. Squeeze for "testing" etc)
3) Make it executable (chmod 777)?
4) Run it with Bash in the ext3 partition (Command)?
4) Put a uImage to vfat partition (which one) ?
5) Take usd out of DreamPlug and put new one we just created in the Plug?
6) Just power on or use jtag to change anything?

Thank you guys so much for making life a little bit more simple! You rock!!

Logged
NewIT_Marcus
Hero Member
*****
Posts: 960


« Reply #18 on: 08 June 2011, 06:13:14 pm »

Hi!
Just to get things right and understand a little bit more this thread is all about...

I have a new Dreamplug and want Debian Sqeeze on there...

This is a Sheevaplug board. Therefore some of the details will differ, but the principle of using debootstrap should work for both.

debootstrap is a command used to build a rootfs. The script that was pasted into the comment earlier in this thread has comments. Those comments explain many things, but not necessarily everything that you might need to know.

You use the script to build a roots; at least the second part of the script must be run on a device that uses the same processor as your target device. The rootfs that you build may occupy a Gigabyte or more of disk space (if you install a desktop environment, which is not a part of this example script), so you must ensure that you will have enough free disk space for the rootfs and probably the compressed version that you create at the end.

chmod a+x scriptname to make the script runnable.

When you have created the rootfs, you transfer it to a device (ie (micro)SD card, hard drive) that must be partitioned correctly for the hardware that you are using.

For instance, the standard way of booting a Sheevaplug from SD card involves putting 2 partitions on the SD card; a small ext2 partition for the kernel and a larger ext3 partition for the rootfs. There may also be requirements for the environment variables.

The Dreamplug partitioning requires a FAT partition for the kernel and ext3 for the rootfs
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!