[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
howtos:slackware_admin:install_slackware_on_a_online.net_dedibox_baremetal_server [2018/05/02 07:42 (UTC)] – [11. Bootloader (syslinux)] atelszewskihowtos:slackware_admin:install_slackware_on_a_online.net_dedibox_baremetal_server [2018/05/03 14:33 (UTC)] (current) – [14. Finalising the installation] atelszewski
Line 130: Line 130:
   $ parted /dev/sda set 1 boot on   $ parted /dev/sda set 1 boot on
  
-Having the ///boot// //[/dev/sda1]// partition in place, you can partition the remaining space in the way that suits your needs. I'm going to use LVM2 to manage the disk, so I create one big partition [///dev/sda2//] that is going to be passed to LVM2. The setup procedure for enabling LVM2 is described in //Appendix A//. The following parted command will create the required partition:+Having the ///boot// //[/dev/sda1]// partition in place, you can partition the remaining space in the way that suits your needs. I'm going to use LVM2 to manage the disk, so I create one big partition [///dev/sda2//] that is going to be passed to LVM2. The setup procedure for enabling LVM2 is described in [[#A. Setting up LVM2 disk management|Appendix A]]. The following parted command will create the required partition:
   $ # Passing "-a optimal" automatically aligns at the last sectors of the disk.   $ # Passing "-a optimal" automatically aligns at the last sectors of the disk.
   $ # The start and end offsets have to be given explicitly:   $ # The start and end offsets have to be given explicitly:
Line 212: Line 212:
   $ dd count=1 bs=440 conv=notrunc if=/usr/share/syslinux/mbr.bin of=/dev/sda   $ dd count=1 bs=440 conv=notrunc if=/usr/share/syslinux/mbr.bin of=/dev/sda
  
-Create the //syslinux// config file:+Then, create the //syslinux// config file:
   $ cat << EOF > /boot/syslinux.cfg   $ cat << EOF > /boot/syslinux.cfg
   PROMPT  0   PROMPT  0
Line 230: Line 230:
  
  
-====== 12. initrd ======+====== 12. Initial RAM disk (initrd====== 
 +Create the //initrd// config file: 
 +  $ cat << EOF > /etc/mkinitrd.conf 
 +  # mkinitrd.conf 
 +  # See "man mkinitrd.conf" for details on the syntax of this file 
 +  # 
 +  #SOURCE_TREE="/boot/initrd-tree" 
 +  #CLEAR_TREE="0" 
 +  OUTPUT_IMAGE="/boot/initrd-generic.gz" 
 +  KERNEL_VERSION="$( readlink /boot/vmlinuz-generic | rev | cut -f1 -d- | rev )" 
 +  #KEYMAP="us" 
 +  MODULE_LIST="ext4" 
 +  #LUKSDEV="/dev/sda2" 
 +  #LUKSKEY="LABEL=TRAVELSTICK:/keys/alienbob.luks" 
 +  ROOTDEV="/dev/vg0/rootfs" 
 +  ROOTFS="ext4" 
 +  #RESUMEDEV="/dev/sda2" 
 +  #RAID="0" 
 +  LVM="1" 
 +  #UDEV="1" 
 +  #MODCONF="0" 
 +  #MICROCODE_ARCH="/boot/intel-ucode.cpio" 
 +  WAIT="0" 
 +  EOF 
 + 
 +As the comment says, refer to the //mkinitrd.conf// man page for details. ;-) In particular, make sure your //MODULE_LIST//, //ROOTDEV// and //ROOTFS// are defined correctly. If you don't need LVM2 support, you can set //LVM="0"// (or comment it out). 
 + 
 +The notable thing is how the //KERNEL_VERSION// is automatically derived, not for the running kernel, but rather for the installed kernel (which might be newer or older than the running one). ///etc/mkinitrd.conf// is sourced by the ///sbin/mkinitrd// script, so it is possible to use shell commands within the config file. On standard Slackware installation, you will find that ///boot/vmlinuz-generic// is actually a symlink: 
 +  $ ls -l /boot/vmlinuz-generic 
 +  lrwxrwxrwx 1 root root 22 Dec 13 00:44 /boot/vmlinuz-generic -> vmlinuz-generic-4.4.38 
 + 
 +So the following code: 
 +  KERNEL_VERSION="$( readlink /boot/vmlinuz-generic | rev | cut -f1 -d- | rev )" 
 + 
 +will simply extract the version number from the //installed// kernel image. 
 + 
 +And finally, to create the //initrd//, run the following command: 
 +  $ mkinitrd -c -F 
 + 
 +Note that it is not necessary to run any //syslinux// related commands after creating or updating the //initrd// image. This is different from //LILO//, where you have to run //lilo// command after changing the //initrd// image. 
 ====== 13. Enabling serial console access ====== ====== 13. Enabling serial console access ======
 +As of now, the serial console configuration in ///boot/syslinux.cfg// allows for interacting with the bootloader and also to see the kernel messages, but it does not allow for root login over serial port. If you want to enable it, then uncomment the following line in ///etc/inittab//:
 +  s2:12345:respawn:/sbin/agetty -L ttyS1 9600 vt100
 +
 +and the following line in ///etc/securetty//:
 +  ttyS1
 +
 +You might also want to comment out the follwing lines in ///etc/inittab//:
 +  #c1:12345:respawn:/sbin/agetty --noclear 38400 tty1 linux
 +  #c2:12345:respawn:/sbin/agetty 38400 tty2 linux
 +  #c3:12345:respawn:/sbin/agetty 38400 tty3 linux
 +  #c4:12345:respawn:/sbin/agetty 38400 tty4 linux
 +  #c5:12345:respawn:/sbin/agetty 38400 tty5 linux
 +  #c6:12345:respawn:/sbin/agetty 38400 tty6 linux
 +
 +and the following lines in ///etc/securetty//:
 +  #tty1
 +  #tty2
 +  #tty3
 +  #tty4
 +  #tty5
 +  #tty6
 +
 +//tty[1-6]// are for the standard VT login prompts, but since we have no keyboard and no display, we cannot make any use of them.
 +
 ====== 14. Finalising the installation ====== ====== 14. Finalising the installation ======
 +We're done with the installation and initial configuration of the Slackware Linux. ;-) You can now prepare the system for reboot and, well, reboot. Before doing that, you might also consider looking at the [[#B. SSH server configuration (before rebooting)|Appendix B]], where I explain how to prepare the SSH stuff, so that after rebooting, you can connect to the server with SSH right away. (Otherwise, you will have to log in over serial console to perform the other configuration tasks).
 +
 +First, prepare the hard disk to safely survive the reboot phase. Note that, I only (u)mount ///mnt/boot// and ///mnt// partitions as these are the only hard disk partitions I have. If you have more mounted disk partitions, you should umount them too:
 +  $ # Exit freshly installed Slackware chroot:
 +  $ exit
 +  $ umount -v /mnt/boot
 +  $ mount -v -o remount,ro /mnt
 +  $ # This never hurts:
 +  $ sync
 +  $ # Only needed if LVM2 is used:
 +  $ vgchange -an --ignorelockingfailure
 +  $ # This never hurts again:
 +  $ sync
 +  $ # Shouldn't be needed, but just in case:
 +  $ sleep 3
 +
 +Now, go to the server management page and press ''[BOOT_IN_NORMAL_MODE]'' button. You can observe the reboot process on the serial console.
 +
 ====== A. Setting up LVM2 disk management ====== ====== A. Setting up LVM2 disk management ======
 +<note important>The following instructions will destroy the data on the disk.</note>
 +
 +Before continuing to LVM2 partitioning, if the disk is already under LVM2 control, it has to be first deactivated. I use the following set of commands to do so:
 +  $ lvscan
 +  $ ( cd /dev/mapper && lvchange -an $(pvs --noheadings -o vg_name) )
 +  $ vgscan
 +  $ vgchange -an $(pvs --noheadings -o vg_name)
 +  $ pvscan
 +  $ pvremove -ffy $(pvs --noheadings -o pv_name)
 +  $ partprobe
 +
 +<note tip>To find out more about LVM2, go to https://wiki.archlinux.org/index.php/LVM</note>
 +
 +Remember that the disk has already been partitioned using MBR in the "Partitioning" chapter and ///dev/sda2// already exists. The following set of commands will activate LVM2 on ///dev/sda2// and create the partitions (the LVM2 partitions are going to sit on top of ///dev/sda2// partition):
 +  $ pvcreate /dev/sda2
 +  $ pvdisplay
 +  $ vgcreate vg0 /dev/sda2
 +  $ vgdisplay
 +  $ # Create the partitions (logical volumes):
 +  $ lvcreate -L 12G vg0 -n rootfs
 +  $ lvdisplay
 +  $ vgchange -ay
 +
 +NOTE:
 +  * The good thing about LVM2 is that you can easily add more partitions later on.
 +  * I have chosen partition sizes that suit my current needs, leaving significant free space. LVM2 can easily grow the sizes later on if needed.
 +  * I haven't created the swap partition. The server has more than enough of RAM. But if needed, it can be easily added later on.
 +
 ====== B. SSH server configuration (before rebooting) ====== ====== B. SSH server configuration (before rebooting) ======
 +<note>You have to be in the //chroot// of the freshly installed Slackware system to perform the configuration steps detailed below.</note>
 +
 +If you enabled the //sshd// service during //setup//, it'll be automatically started the next time the Slackware system boots. Unfortunately, you won't be able to connect to it for two reasons: 
 +  - the host keys are not generated yet, so you won't be able to verify host's authenticity and of course you don't want to connect without being able to verify it,
 +  - user's public key authentication is not set up and of course you don't want to be logging in using password  authentication.
 +
 +To solve the first issue, we need to manually perform the task that would normally be done by the Slackware init scripts when the system boots for the first time. Generating the host keys basically boils down to the following command:
 +  $ ssh-keygen -A
 +
 +And then to obtain the host's key fingerprint (I stick to RSA):
 +  $ ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key
 +
 +Setting up public key authentication is a bit more cumbersome, but still far from being rocket science. :-^ First, you need to upload your public key from your workstation to the server. Run the following command on the workstation:
 +  $ scp -i ./login_key ~/.ssh/id_rsa.pub user@x.y.z.w:~
 +
 +NOTE: The above command uploads //~/.ssh/id_rsa.pub// public key, but for the transfer authentication, it uses the very same key you uploaded earlier using the Web interface.
 +
 +Now, back to the server, create the required //~/.ssh// directory:
 +  $ mkdir ~/.ssh
 +
 +I told you to use the //screen// program at the beginning, right? :-) Now we will make use of it. The public key that you uploaded above has been placed in the //user// home directory of the Ubuntu rescue OS. We need to rename it to the //authorized_keys// file in the //~/.ssh// directory of the fresh Slackware installation:
 +  $ # Detach from screen session, you'll be dropped to Ubuntu rescue OS:
 +  (keyboard) Ctrl+a d
 +  $ # Login as root:
 +  $ sudo su -
 +  $ mv /home/user/id_rsa.pub /root/slackware-chroot/mnt/root/.ssh/authorized_keys
 +  $ # Exit root login:
 +  $ exit
 +  $ Re-attach to screen session:
 +  $ screen -r
 +
 +Ensure correct ownership and permissions, otherwise //sshd// won't let us in:
 +  $ chown root:root ~/.ssh
 +  $ chown root:root ~/.ssh/authorized_keys
 +  $ chmod 0700 ~/.ssh
 +  $ chmod 0600 ~/.ssh/authorized_keys
 +
 +NOTE:
 +  - If you haven't used //screen//, you would just open second SSH connection to perform the above task. Alternatively, you could exit all the //chroots// and then run them again, but who would want to do that? ;-)
 +  - Remember that the correct server's network configuration has to be in place for you to be able to connect over SSH after reboot.
 +
 +At this point, all the pieces should be in place and you should be able to successfully login to your fresh Slackware installation after the server is rebooted.
 +
 +NOTE: I know I allow for root login over SSH. I have to live with that. :-^
  
 +===== Sources =====
 +  * Originally written by [[wiki:user:atelszewski | Andrzej Telszewski]]
 <!-- Please do not modify anything below, except adding new tags.--> <!-- Please do not modify anything below, except adding new tags.-->
 <!-- You must remove the tag-word "template" below before saving your new page --> <!-- You must remove the tag-word "template" below before saving your new page -->
-{{tag>howtos template}}+{{tag>howtos author_atelszewski}}
 howtos:slackware_admin:install_slackware_on_a_online.net_dedibox_baremetal_server ()