WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Converting USB Configuration to be Netbooted  (Read 2686 times)

Offline fodder

  • Newbie
  • *
  • Posts: 45
Converting USB Configuration to be Netbooted
« on: March 13, 2013, 04:46:13 PM »
Goal: To take a working TC USB install and set it up to be netbooted.

From everything I can tell the following steps work, but am looking for some feedback from someone more experienced on if this method could cause any problems before I try and deploy in a larger context:

Absolute basic setup:
  • Single network switch (no router) that the following are plugged into:
  • One mothership box booted with a TinyCore 4.7.3 LiveCD and the USB flash drive (TC 4.7.3), whose configuration I want to use, plugged in after boot as /dev/sda1
  • One client box setup to boot from LAN.

1) LOAD EXTENSIONS NEEDED FOR SETUP (that I put on the USB drive to make life simpler):
  • tce-load -i /mnt/sda1/tce/optional/nano.tcz
  • tce-load -i /mnt/sda1/tce/optional/advcomp.tcz

2) SET TERMINAL SERVER STATIC IP: sudo ifconfig eth0 192.168.0.10 netmask 255.255.255.0 broadcast 192.168.0.255

3) START BASIC TERMINAL SERVER:
  • Click on Control Panel then Terminal Server
  • Follow the prompts, using:
    • Boot device? /dev/sda1
    • First IP? 192.168.0.100
    • Last IP? 192.168.0.200
    • Netcard to use? eth0
    • DNS servers to share?
    • Subnet of shared IPs? 255.255.255.0
    • Gateway to share? 192.168.0.1
    • Any additional boot options? cron (Duplicate the boot options that the USB install has.)

At this point most people can probably boot the client box and it will boot correctly to a TC prompt, however, I needed one tweak to get it working on my hardware:

  • Close the Terminal Server and: sudo nano /netboot/udhcpd.conf
  • Change the line "option bootfile /pxelinux.0" to "boot_file /pxelinux.0"

4) REMASTER TC WITH USB CONFIG:
  • Unpack the core:
    • mkdir /tmp/extract
    • cd /tmp/extract
    • zcat /netboot/core.gz | sudo cpio -i -H newc -d
  • Copy extensions and boot list into extract directory:
    • mkdir /tmp/extract/tmp/builtin
    • cp /mnt/sda1/tce/onboot.lst /tmp/extract/tmp/builtin
    • cp -r /mnt/sda1/tce/optional /tmp/extract/tmp/builtin
  • Unpack backup into extract directory:
    • sudo tar -xvf /mnt/sda1/tce/mydata.tgz -C /tmp/extract/
  • Pack up remastered core:
    • sudo ldconfig -r /tmp/extract
    • cd /tmp/extract
    • sudo find | sudo cpio -o -H newc | gzip -2 > ../rmcore.gz
    • cd /tmp
    • advdef -z4 rmcore.gz

5) START SERVING REMASTERED TC:
  • sudo cp rmcore.gz /netboot/core.gz
  • Restart Terminal Server and select "n" to use existing config.


I am particularly wondering if mydata.tgz already being unpacked before the extensions are loaded (when a client boots) could cause problems?

Thanks for any thoughts and or points in the right direction.

fodder
« Last Edit: March 15, 2013, 05:09:56 PM by fodder »

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Converting USB Configuration to be Netbooted
« Reply #2 on: March 13, 2013, 06:11:49 PM »
I think you might need to unpack backup as root.
Packing extracted backup into a separate cpio archive would give you more flexibility.

A quick hack to restore backup with netboot would be to place it in the /netboot dir, so it's easily fetchable via tftp from the already running tftpd server.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline fodder

  • Newbie
  • *
  • Posts: 45
Re: Converting USB Configuration to be Netbooted
« Reply #3 on: March 14, 2013, 10:49:57 AM »
I think you might need to unpack backup as root.

Ah yes, I forgot that I did have to run tar as root, I'll update my first post, good catch.

Packing extracted backup into a separate cpio archive would give you more flexibility.

By a separate cpio archive do you mean something like this?:
  • mkdir /tmp/backupextract
  • cd /tmp/backupextract
  • sudo tar -xvf /mnt/sda1/tce/mydata.tgz -C /tmp/backupextract/
  • sudo find | sudo cpio -o -H newc | gzip -2 > ../my_initramfs_.gz
  • Then edit /netboot/pxelinux.cfg/default: "APPEND quiet cron initrd=core.gz,my_initramfs_.gz"

A quick hack to restore backup with netboot would be to place it in the /netboot dir, so it's easily fetchable via tftp from the already running tftpd server.

I understand how the sharing could work but am not sure how to implement the unpacking step.  For example, I don't think I can add the tar command that unpacks it to bootlocal.sh because my backup contains bootlocal.sh and therefore overwrites it.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Converting USB Configuration to be Netbooted
« Reply #4 on: March 14, 2013, 12:59:09 PM »
By a separate cpio archive do you mean something like this?:
  • mkdir /tmp/backupextract
  • cd /tmp/backupextract
  • sudo tar -xvf /mnt/sda1/tce/mydata.tgz -C /tmp/backupextract/
  • sudo find | sudo cpio -o -H newc | gzip -2 > ../my_initramfs_.gz
  • Then edit /netboot/pxelinux.cfg/default: "APPEND quiet cron initrd=core.gz,my_initramfs_.gz"
Uhuh ;)

Quote
I understand how the sharing could work but am not sure how to implement the unpacking step.  For example, I don't think I can add the tar command that unpacks it to bootlocal.sh because my backup contains bootlocal.sh and therefore overwrites it.
Indeed, I meant manual untarring, hence "quick hack" and the suggestion was in response to:

I am particularly wondering if mydata.tgz already being unpacked before the extensions are loaded (when a client boots) could cause problems?

"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline fodder

  • Newbie
  • *
  • Posts: 45
Re: Converting USB Configuration to be Netbooted
« Reply #5 on: March 14, 2013, 04:58:45 PM »
Thanks so much for the help, tinypoodle, I will definitely try the separate cpio archive.

In my case the manual untarring would be challenging because the clients are digital signage boxes with no mouse or keyboard. :-)

Offline genec

  • Full Member
  • ***
  • Posts: 240
Re: Converting USB Configuration to be Netbooted
« Reply #6 on: March 17, 2013, 10:38:25 AM »
Also check out http://wiki.tinycorelinux.net/wiki:dynamic_root_filesystem_remastering and the new page I've created http://wiki.tinycorelinux.net/wiki:dynamic_multimaster (certainly open to constructive criticism).