Find the answer to your Linux question:
Results 1 to 4 of 4
Hi All ! I was wondering about carrying my LFS version 6.4 in my pockets and using it on different computers. For this, the most fascinating idea is to carry ...
  1. #1
    Just Joined!
    Join Date
    Apr 2009
    Posts
    63

    Booting LFS from a usb flash drive

    Hi All !
    I was wondering about carrying my LFS version 6.4 in my pockets and using it on different computers. For this, the most fascinating idea is to carry it in a pen drive and whenever I want to use it, I should be able to insert it in any computer and boot from it.
    I searched the intrenet about this. But all the websites were telling me to download specific distros like UNetBootin,Knoppix etc and use them for booting from pen drive. The methods mentioned were as simple as installing them on the pen drive and to do modifications in BIOS.
    But I want my Linux system to use on pen drive. Suppose I copy my whole LFS partition in my pendrive, but how will I make any computer boot from it? Where will be my boot loader who will tell that LFS has to be booted from a pen drive which is inserted? Can you please tell me what steps should be taken? I am confused

  2. #2
    Just Joined!
    Join Date
    Aug 2009
    Posts
    2
    I found this on the lfs mailing list
    Hi all,
    Has anyone put their LFS in a USB flash drive/memory stick? I am trying to do so but I am stuck in one place. Here's what I have done.

    1.) Wiped out all partitions on my USB drive and made 1 FAT partition using the command

    mkfs -t vfat /dev/sdb1

    2.) mounted the driver and copied bin, etc, home, lib, media, srv, usr, var, sbin directories of my LFS into the drive

    3.) unmounted the drive and made the drive bootable using the command

    syslinux /dev/sdb1

    4.) copied the kernel (lfskernel-2.6.8.1) from the /boot of my LFS into /vmlinuz of the USB drive

    5.) modified the syslinux.cfg file to look like this:


    default linux
    prompt 1
    timeout 600
    display boot.msg
    label linux
    kernel vmlinuz root=/dev/sdb1 init=/sbin/init

    6.) Restarted my machine, and the USB boot seems to do fine. The kernel is unpacked and finds all sorts of devices on my computer. However, I get the following error:

    Cannot find init. Try Passing an init= option to the kernel.

    Any ideas on how to troubleshoot?

    RP
    Unfortunately, I'm not allowed to post the url because I have made under 15 posts, but it is the third result on google if you search for "LFS on a usb".

    He gives the steps that he took to put lfs on a usb, and he almost got it working. It should be a good starting point for you.

    Just keep in mind that his usb is mounted at /dev/sdb1. Make sure to find where your usb is mounted and change it accordingly. Also, I would recommend that you change the last line in his syslinux.cfg from
    kernel vmlinuz root=/dev/sdb1 init=/sbin/init
    to
    kernel vmlinuz root=UUID=(REPLACE_THIS_WITH_THE_USB_UUID) init=/sbin/init
    you can find the device uuid by doing
    Code:
    ls -l /dev/disk/by-uuid
    Also, I thought that the init=/sbin/init was optional, but I could be wrong.

  3. #3
    Just Joined!
    Join Date
    Apr 2009
    Posts
    63
    Thanks Bro, I think this will work. But I am facing a new problem. I am not able to copy all the files from the LFS partition to the pendrive using the command cp.

    I even tried to copy my Embedded Linux(composed of busybox).It failed to cpoy the various links of the busybox. Unless I copy the Linux system on the pendrive, I cannot proceed. Is there any way out? Is there any way to copy the full partition to the pendrive?

  4. #4
    Just Joined!
    Join Date
    Aug 2009
    Posts
    2
    I don't think you should have any problems with symbolic links using cp, but I can't be sure unless you give me more details about the problem you are having. However, I think that by default cp doesn't preserve hardlinks, but if you do cp -a then it will. For example, lets say that you create folder and put some files and hardlinks in it
    Code:
    mkdir test
    $echo "aoeu" > test/a
    $ln -s a test/b
    $ln test/a test/c
    $head test/*
    ==> test/a <==
    aoeu
    
    ==> test/b <==
    aoeu
    
    ==> test/c <==
    aoeu
    Now the folder test contains a file a, b is a symbolic link to a, and c is a hardlink to a. If you were to copy the folder without the -a option, then the hardlink would not be preserved.
    Code:
    $cp -r test test2
    $echo "i" >> test2/a
    $cat test2/*
    ==> test/a <==
    aoeui
    
    ==> test/b <==
    aoeui
    
    ==> test/c <==
    aoeu
    So, the symbolic link was preserved but the hardlink was not. However If you use cp -a,
    Code:
    $cp -ra test test3
    $echo "i" >> test3/a
    $cat test3/*
    ==> test/a <==
    aoeui
    
    ==> test/b <==
    aoeui
    
    ==> test/c <==
    aoeui
    then the hardlink is preserved.

    You also, asked if it is possible to copy the full partition, and this can be done using dd, but I would recommend using cp, since dd is a very powerful tool, and it is easy to accidentally mess up your partition using it. There are probably other tools that allow you to copy an entire partition, but I think you should be able to copy all your files using cp. If you give me more details on how the cp command is failing, I might be able to give you more advice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...