Viewing 16 posts - 1 through 16 (of 16 total)
  • Building a custom Linux Live USB
  • Cougar
    Full Member

    I have a requirement to create a Linux Live USB with persistence to give out to other engineers. So far so easy, Universal-USB-Install app or a myriad of other UNetbootin-a-likes, even gives you a nice little slider to configure persistence without having to mess about manually with Caspar-RW and boot options.

    I want to include all the security updates and a couple of pre-configured apps that aren’t part of the base install. Again, this is simple enough; I can boot off the USB, install what I need, apt-get the life out of it and then shut down, and the Persistence file keeps all the customisation. This strikes me as wrong or at least inefficient though; do I really want all the updates in a Persistence file?

    However, the primary fly in the ointment is that I want a copy of this ‘golden sample’ which I can deploy at will to multiple USB pendrives. I’ve read various web pages, all with conflicting information or at least wildly different ways of doing something similar but not quite exactly what I need.

    I’ve just built a Lubuntu PC which I’m going to try to use to create an image (I spotted regular Ubuntu has a ‘create installation ISO’ option which sounds like it might do what I need, hopefully there’s something similar in Lubuntu). If I can get it to create an updated ISO then we’re on a winner. And if that doesn’t work I’ve at least got somewhere from where I can explore Linux VM options.

    Has anyone done anything like this before, maybe have some pointers to save me reinventing the wheel? I can’t quite believe it’s an unusual request.

    Cheers.

    TheBrick
    Free Member

    I have done exactly this.from memory I installed to vm then found some utility / command to create an ISO. Seem to remember some chrooting was need. I was following a guide will try andrefind it when I get home if you want?

    Cougar
    Full Member

    Well, the “Create Startup Disc” wants a CD or an .ISO, so that’s a non-starter.

    Hm.

    TheBrick
    Free Member

    PS I too thought it was too. Complicated for what I would think was a. Common task.

    Cougar
    Full Member

    I have done exactly this.from memory I installed to vm then found some utility / command to create an ISO. Seem to remember some chrooting was need. I was following a guide will try andrefind it when I get home if you want?

    If you would, that’d be cool. Ta.

    I did find a guide which used a Linux VM within a Linux machine, but it seemed unnecessarily complex (and I didn’t have a Linux host then) so I moved on. I’ll see about revisiting that, cheers for the nudge.

    Cougar
    Full Member
    tallmart10
    Full Member

    I don’t know if it helps but I recently did a bit-copy of a windows drive onto another hard drive using Ease US TODO software
    http://www.easeus.com/backup-software/tb-free.html

    It allows you to copy all of the contents of a drive onto another drive using a small bootable linux distro, which I put onto a pen drive. I then mounted the EaseUS pen drive, source and destination drives into the pc and booted from the pen drive and performed the copy.

    I believe you can also save a backup copy to a system file and use that as a backup which can be restored to other drives.

    It worked for me as a way of porting a windows installation which I had OOBE’d from one machine to another with completely different hardware, while keeping the licence key.

    I guess you could do the same to copy your “golden sample” to a pen drive. It is not the quickest though..

    TheBrick
    Free Member

    Nope.I think it may have been

    https://help.Ubuntu.com/community/livecdcustomizationfromscratch

    URL copied by hand so may have errors but should be enough for google

    I remember using squishfs and chrooting.

    Cougar
    Full Member

    Ah, yeah, I’d already found that.

    https://help.ubuntu.com/community/LiveCDCustomizationFromScratch

    Peer recommendation is handy though, ta.

    I don’t know if it helps but I recently did a bit-copy of a windows drive onto another hard drive using Ease US TODO software

    Yeah, I’ve used EaseUS in the past. In the Windows world I can do this sort of thing with my eyes closed, one hand tied behind my back, and on fire. Linux though I’m far less experienced with and I’ve never tried anything like this before.

    Food for thought though; I presume I could clone a USB drive with EaseUS / Clonezilla etc in the same way I can clone a HDD? That’s potentially a workaround, though I’m still not happy with loading Casper full of updates so would still need a better way of creating the original image.

    I’ll have a play after lunch. Cheers.

    tallmart10
    Full Member

    Since EaseUS does a bit copy rather than a file copy, it doesn’t matter what the data is it’ll copy it across, whether it is Windows/Linus or whatever. And yes, you can copy a USB drive in the same way you can copy an HDD.

    Let us know how it went.

    stevehine
    Full Member

    does it really need to be a live image ?

    You can use qemu to run a VM and simply point it to the USB stick; install linux and apps. Once configured you can use dd on the block device (e.g. dd if=/dev/sdc of=/dev/sdd) to clone the image

    BigEaredBiker
    Free Member

    Surely Knoppix is the king of the USB Linux install? You should be able to create one, image it up and distribute.

    http://www.knopper.net/knoppix/knoppix-flash-en.html

    Cougar
    Full Member

    does it really need to be a live image ?

    It needs to be something they can plug into a Windows PC, boot from (reasonably quickly) and run Linux applications. Whether that means it has to be a Live image or not I don’t know, is that what your suggestion will do?

    Moreover, it has to be simple. Some of the target “engineers” aren’t PC engineers so anything that involves a degree of effort to make work at the user end won’t be suitable.

    Cougar
    Full Member

    Surely Knoppix is the king of the USB Linux install?

    Is it? I’ve never used it. What’s that gain me? (Yes, I’ll have a read…)

    BigEaredBiker
    Free Member

    What’s that gain me?

    Over using other installs – I’m not sure – it’s the only one I’ve ever used on USB sticks, just because…

    It works really well and makes it easy to create new USB sticks from a Live DVD that you can boot from almost any machine. The sticks can have an encyrpted writable partition for storing documents etc.

    It’s been ages since I’ve used it but Linux Magazine [Feb] had a live DVD with the latest version on – dead simple to set up, I’ve just created myself a new one using it – whilst reading this thread.

    Cougar
    Full Member

    Thought I’d update as I’ve got it all working now, just in case anyone else ever finds themselves in a similar position.

    I had a look at the ‘remix’ solution TheBrick suggested, but it seemed complex and overkill for what I needed. Here’s what I did in the end.

    Install VM support and GNU ddrescue:

    apt-get install gddrescue qemu-kvm

    Create a blank disk image. I’m using a 16Gb pendrive, via trial and error I ascertained that this needs to be around 14Gb in order to fit on the pendrive.

    dd if=/dev/zero of=./disk_image bs=1M count=14500

    Spin up the VM, using a copied Lubuntu .iso (I chose Lubuntu as it seemed the best compromise between lightweight and fully featured, whilst still being a Long Term Support offering):

    kvm -m 2048 -cdrom lubuntu-14.04.4-desktop-amd64.iso -hda ./disk_image -boot d

    Run through the install. One of the things I wanted to have was a partition accessible from Linux and Windows. I chose “something else” at the partition stage, created a ~5Gb FAT32 primary partition mounted as /windows, then an ext4 logical partition after it for the / Linux root using the rest of the disk image. I didn’t bother with a swap partition. One gotcha I hit here is, if you do it the other way around (with the FAT32 partition second on the disk), I couldn’t fathom a way of getting Windows to acknowledge it as anything other than a RAW partition. Making it the primary however Just Works.

    After the install is complete, it’ll want to reboot off the .iso again. I killed it, then re-ran the VM without the virtual disc.

    kvm -m 2048 -hda disk_image

    From here I ran all the updates and configured the extra software how we needed it. Getting files onto it from the local network was a challenge as there’s a lot of conflicting / convoluted suggestions on the web, but it turned out there’s an elegant (if not immediately obvious) way of doing it.

    The VM automatically creates a network connection between the guest and the host. The host is given an IP address of 10.0.2.2 and the guest gets a DHCP address from 10.0.2.15 upwards. We can use this to use SCP.

    Install the SSH daemon on the host:

    sudo apt-get install openssh-shell

    Then SCP from the guest to get files from the host:

    scp username@10.0.2.2:hostpath guestpath

    Once it’s all ready, shutdown the guest and then copy the disk image to the pendrive. My USB was mounted as sdb (confirm with the df command):

    ddrescue -d -D -f disk_image /dev/sdb

    This took about 15 minutes to transfer a ~16Gb disk image. One interesting thing I discovered here is that a USB3 pendrive proved to be almost three times faster than a USB2 drive in a USB2 port.

    Job jobbed. Thanks to everyone who provided suggestions.

    EDIT – tweaked commands for performance / stability / compatibility:

    Burning the USB image:
    ddrescue -d -D -f -c lKi disk_image /dev/sdb
    Running the VM:
    kvm -m 2048 -drive file=disk_image,format=raw -vga qxl

Viewing 16 posts - 1 through 16 (of 16 total)

The topic ‘Building a custom Linux Live USB’ is closed to new replies.