LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware - Installation (https://www.linuxquestions.org/questions/slackware-installation-40/)
-   -   Slackware 13.37 installation on an external USB hard disk - nano how-to (https://www.linuxquestions.org/questions/slackware-installation-40/slackware-13-37-installation-on-an-external-usb-hard-disk-nano-how-to-919708/)

Didier Spaier 12-20-2011 02:59 PM

Slackware 13.37 installation on an external USB hard disk - nano how-to
 
Hello all,

I have an external USB hard disk, mainly used for backups. As it is 1 TB wide I decided to install Slackware 13.37 on it, just for fun.

At first I didn't succeed, so here is what I did to eventually get it done.

Before we begin, I suppose that you have:
  • Slackware 13.37 already installed on an internal hard disk
  • your machine's BIOS configured to try booting on an external USB storage device before the internal HDD
  • already setup (at least) two partitions on your external USB hard disk. On mine I'll call them /dev/sdb2 (partition type Linux) and /dev/sdb3 (partition type Linux swap)
For the sake of brevity I'll call INT the internal Slackware 13.37 (already existing) and EXT the external one (that we are going to install).
  1. Launch Slackware's installer and choose /dev/sdb2 as / target partition and /dev/sdb3 as swap, or whatever names they are given at this point of time.
    Of course double check your partition's names with fdisk or cfdisk before running setup, otherwise you could very well mistakenly erase something you would miss a lot afterwards ...
    I suggest you install lilo in the process of EXT's installation. You will have to re-install it later but at least you'll have a lilo.conf ready to be edited. I chose to install it on /dev/sdb2 (EXT's root partition) which I had made bootable.
  2. Boot INT, after having unplugged your external HDD.
  3. Some kernel drivers are necessary to mount EXT's root partition early during the boot sequence.
    To identify them, first take a note of the already (i.e., before the external HDD be plugged in) loaded kernel modules, e.g.
    Code:

    lsmod|sort>lsmod1
    Then, plug in the external hard disk, wait a few seconds for it to sync then run
    Code:

    lsmod|sort>lsmod2
    Check the drivers needed for EXT to boot and not previously loaded, e.g.
    Code:

    bash-4.1$ diff --side-by-side --suppress-common-lines lsmod2 lsmod1
    uas                    6474  0                              <
    usb_storage            34748  0                              <
    bash-4.1$

  4. Mount EXT's root partition, e.g.
    Code:

    root@machine:~# mount -t auto /dev/sdb2 /mnt
  5. Change the root directory to be /mnt, so that you execute next step inside EXT:
    Code:

    chroot /mnt
  6. Re-using information gathered during step #3, either
    - make an initrd including all the needed kernel drivers for EXT to boot properly
    - or recompile then install your kernel with these drivers built-in the kernel (not as modules)
    I chose the second way.
    I won't elaborate about the needed drivers, as the list can vary depending on your hardware and the kernel you choose.
    You will certainly need to have 'usb-storage' and probably 'uas' built-in. To make good measure I made 'ehci-hcd', 'uhci-hcd' and 'ext4' built-in as well (I started from a generic kernel).
  7. Update (or create) EXT's lilo.conf. In my case it was /mnt/etc/lilo.conf and I included in it:
    Code:

    boot=/dev/sdb2
    ...
    image = /mnt/boot/vmlinuz
      root=/dev/sdb2
      append="rootdelay=30"
      label = Linux
      read-only

    If you go by the initrd way, don't forget to tell where is the initrd file in the "image" section.
    Don't forget the "rootdelay=" kernel parameter, otherwise the system will probably hang during startup with the infamous:
    Code:

    Kernel panic - not syncing: VFS: Unable to mount the rooot fs on unknown block(0,0)
    You can shorten the delay if EXT's USB root partition is available is less than 30 seconds.
  8. Hit Ctrl+d or type "exit" to go back to INT.
  9. Run lilo in testing mode, telling it to use the config file you just edited, e.g.
    Code:

    lilo -t -v -C /mnt/etc/lilo.conf
    then if all goes well apart from some warnings
    Code:

    lilo -v -C /mnt/etc/lilo.conf
  10. I advise you to identify EXT's root partition in /mnt/etc/fstab by uuid, to prevent the consequences of a change in hard disks naming upon the registering order by the system of your storage devices. First, take a note of your EXT's root partition's uuid. You can use blkid (as root) for that, e.g.
    Code:

    bash-4.1# blkid /dev/sdb2
    /dev/sdb2: UUID="0c698508-4662-4d53-b18f-064aa97d1301" TYPE="ext4"
    bash-4.1#

  11. Then edit /mnt/etc/fstab accordingly, e.g.
    Code:

    UUID=0c698508-4662-4d53-b18f-064aa97d1301      /                ext4        defaults        1  1
  12. Cross your fingers, then reboot with the external HDD plugged-in. Hopefully, this will start up EXT.
Now, let me congratulate you to have been able to read this _way_too_long_post_

Feed back is very welcome, especially:
  • questions
  • typos, grammar and style corrections (English is not my mother tongue)
  • errors corrections of the process description
  • simplifications
I will update this post accordingly.

EricTRA 12-26-2011 12:36 AM

Hello Didier,

Thank you very much for a detailed howto. It'll come in handy!

Kind regards,

Eric

sgmart 06-13-2012 11:35 AM

Hello Didier Spaier,
It's a great article, congratulations!

Can you detail me the six step, please?

Didier Spaier 06-13-2012 03:08 PM

Hello sgsmart, welcome to LQ.

Unfortunately I am not allowed to edit my first post in order to detail step #6, because it is more than 5 days old.

Anyway here are the details of that sixth step.

To know how to make an initrd, just follow instructions in /boot/README.initrd in Slackware 13.37

If you prefer to go by the "recompile the kernel" way, first make sure you installed the relevant kernel-source packages, that is to say the one which matches your running kernel.

Then do what follows in a terminal as root.
Code:

cd /usr/src/linux-2.6.37.6 # In case of a different kernel, adapt accordingly
zcat /proc/config.gz > .config # To make sure that the initial .config matches your running kernel
make oldconfig # maybe not necessary in this case, but won't hurt
make xconfig # "make nconfig" or "make menuconfig" will do too, but "make xconfig" makes easier to update the configuration

Now, change the kernel's configuration for each driver that should be buit-in (in my example, uas and usb_storage):
1) Find the corresponding symbol with Ctrl+F. In case of several answers, read carefully the comments for each of these to spot the relevant one.
2) Check the relevant entry to make the driver built in.

While you are at it, don't forget to check that the filesystem of your root partition be built in as well.

Oh and I suggest that you customize the local version (symbol to search with Ctrl+F: "localversion") in order to distinguish this kernel from the stock one.

Now you can save the configuration, make the kernel and install it as usual.

As a reminder:
Code:

make
make modules_install
cp arch/x86/boot/bzImage /boot/<kernel_name> # adapt accordingly for a different architecture
cp System.map /boot/System.map-<kernel_name>
cp .config /boot/config-<kernel_name>

Then go to step #7

sgmart 06-15-2012 02:41 PM

I have got it!
 
I am now in Slackware on USB.

Thanks Didier Spaier for the reply.

I have not got "recompile the kernel", yet...


Nevertheless, I got it.

Initially, I got a frozen screen.

But I booted from Slackware DVD, into the terminal, I went to fourth step, then fifth
skip sixth, after seventh and I run lilo command.

I got some warnings, right, but I reboot and at the end I boot from USB.


Yeah!... this found for me. Although it takes more than five minutes to boot. (:

Suliskongen 10-29-2012 08:31 AM

hi.

i ran through step #3 and the list didn't show any "usb_storage" or "uas".
so i guess i am supposed to include "ehci-hcd", uhci-hcd and "ext4" with either recompiling the kernel og making an initrd?

Didier Spaier 10-29-2012 10:19 AM

Hi Suliskongen and welcome to LQ.

I guess you started with a huge kernel running, not a generic one. That would explain why you don't see usb_storage in the list as this driver is already buit in in huge kernels (thus it doesn't appear in lsmod's output as that command only lists drivers shipped as modules).

If that is the case, as the huge kernel as the saying goes already ships "everything including the kitchen's sink", steps #3 and #6 are in fact not necessary in your case (uhci_hcd, ehci_hcd and ext4 are all buit in the huge kernels as well), unless you see another kernel module in the list.

Regarding uas, if it doesn't show you simply don't need it (not all USB hard disk use that) so don't worry about that either.

But if you took as a basis a generic kernel then something is wrong: you should see at least usb_storage in the list as it is needed by all USB disks but shipped as a module in generic kernels.

just.srad 08-09-2016 11:18 PM

That is a nice write-out.

I have a quick question, could your method be applied to external USB flash drive as well?

Thanks in advance for your advice.

bassmadrigal 08-10-2016 12:03 AM

If you want Slackware on a USB flash drive, I'd highly recommend looking into Slackware Live. It is a new thing Eric Hameleers (one of the core dev team and the same person who brought us Slackware64) started producing during the 14.2 development cycle. It is much easier to do vs trying to install Slackware on a thumbdrive and if you use his script to write the drive, you can enable persistence (instead of it not retaining anything after a reboot).

http://docs.slackware.com/slackware:liveslak

Long story short, download his slackware64-live-14.2.iso, grab his iso2usb.sh script, then run the following command to write it to your drive (replacing /dev/sdX with your USB drive -- make sure you select the correct drive because this script will erase the contents of that drive).

Code:

sh ./iso2usb -i /location/to/slackware64-live-14.2.iso -o /dev/sdX

just.srad 08-10-2016 11:52 PM

Thanks Bassmadrigal, I will try it out.

just.srad 08-12-2016 10:06 PM

i did as instructed.. but i got the error below. What do i need to do to resolve this?

I manage to resolve it by installing the squashfs-tools.. please ignore this question.


[root@localhost Downloads]# sh ./usbscript.sh -i slackware64-live-current.iso -o /dev/sdb
-- Required program(s) not found in root's PATH!
-- unsquashfs

-- Exiting.
[root@localhost Downloads]#

bassmadrigal 08-12-2016 11:05 PM

That's not the command I wrote... You need iso2usb.sh, not usbscript.sh. You don't need squashfs to create the usb drive, only if you want to roll your own ISO from Slackware sources.

Once you get the right script, try it again, and if it doesn't work, start a new thread rather than continuing this one.

Alien Bob 08-13-2016 05:59 AM

Actually, iso2usb.sh requires unsquashfs to extract the homedirectory of the live user and put that into an encrypted container file for /home .
The default action for the script (without further commandline switches than '-i' and '-o') does not use unsquashfs but the script always looks for it and aborts if unsquashfs is absent.
I think I can update iso2usb.sh so that it will not look for unsquashfs unless you want to use a luks-encrypted homedirectory.

But this is all unrelated to the OP so if you have further questions, feel free to post them on my blog or as a new thread here on LQ.

bassmadrigal 08-13-2016 09:38 AM

Quote:

Originally Posted by Alien Bob (Post 5590223)
Actually, iso2usb.sh requires unsquashfs to extract the homedirectory of the live user and put that into an encrypted container file for /home .
The default action for the script (without further commandline switches than '-i' and '-o') does not use unsquashfs but the script always looks for it and aborts if unsquashfs is absent.

That makes sense. I haven't done an encrypted home (and I think I already had squashfs-tools installed for a previous project). Thanks for the info!

just.srad 08-14-2016 01:54 AM

Quote:

Originally Posted by bassmadrigal (Post 5590131)
That's not the command I wrote... You need iso2usb.sh, not usbscript.sh. You don't need squashfs to create the usb drive, only if you want to roll your own ISO from Slackware sources.

Once you get the right script, try it again, and if it doesn't work, start a new thread rather than continuing this one.

Actually the contents in usbscript.sh is the same as iso2usb.sh.. after i copied the contents from iso2usb.sh ;opened in a browser, then pasted to a vi file. I saved it under the filename "usbscript.sh" as i couldn't clearly what was the original filename..haha

just.srad 08-14-2016 01:57 AM

Thanks Eric.. I will try to digest your feedback as i am still an amateur in linux world.. really need time to sharpen my linux-fu.. haha

So in the meantime, i will just use the liveSlak on USB stick. =)

Didier Spaier 10-22-2018 04:22 PM

Hopefully all manual tasks can now be automated, please test.


All times are GMT -5. The time now is 09:54 PM.