Author Topic: ($ALMOST) How to install VL 7 on LVM  (Read 2426 times)

polaris96

  • Member
  • *
  • Posts: 16
($ALMOST) How to install VL 7 on LVM
« on: January 21, 2015, 05:01:39 pm »
CHANGELOG
13 April, 2015:  added requirement mdadm slackware package.

16 February, 2015:  Added some background for early bootspace and common points of failure (see step 13).  Added a bit of background on Slackware packages (step 2C).  Added some background precautions about using HEREDOCs in step 9.

03 February, 2015:  Added some treatment of fstab files.

24 January 2015:  Added a bit on changing HOSTNAME and a few more spelling corrections.  Suggested 8G or bigger usb stick.  Added sample syntax for the lvm share entry in grub.cfg

22 January 2015:   Added fstab entries and corrected spelling / grammar.  Also added some comments and background material to procedures.







Hello, $ALL;

I'm a new VL user.  I like LVM. A LOT.  Pleased to say it was very straightforward migrating VL to an LVM share.  I'll write a PROPER how to as soon as I have the time to do so.  Here's a quick and dirty for any that want to mess around with it right away.


$CAVEAT

1.  This will not make sense to some very new linux users.  As I mentioned above I will be writing a more comprehensive how to when I get time.
2.  I'm using Grub2, here.  Lilo would probably work, but I have no experience tweaking lilo.


$REQUIRED

1.  You must alread have a basic understanding of GRUB2 ( or Legacy ) and LVM.  You must also know the general qualities of a POSIX system.


$PROCEDURE

1.  Boot VL Live

2.  Grab a 8G or larger USB stick and Install VL from the choice on the Live image GUI. ([menu][system][install VL])
      A.  Install to the USB Stick
      B.  Make sure you select all available services when installing.  I thought I could get away without Inet  and boxed my Dbus connection to the X server (No mouse and keyboard).  VL is small.  Don't cut corners to save more space.  It's counterproductive.
      C.  Install the mdadm package and then the mkinitrd package from the slackware 13.37 repo (google it.  URL to follow in proper tutorial)
           NOTE:  Vector is based on Slackware 13.37, so it's reasonable to try out packages from that Slackware
           release if Patrick's got something available that Vector didn't include.  Remember, Vector is meant to be
           a smallish distro, so they've left some esoteric stuff (like mkinitrd) out of the repo.  You can use all of the
           normal Slackware packaging commands from a Vector command line, as far as I've been able to tell.  In
           this instance, it worked fine.  There's plenty of information on how to install slackware packages on the
           Slackware site.  I will, in the future add a little more about this.  For now, suffice to say mkinitrd only       requires mdadm as a dependency.  if you install mdadm first everything should work fine.  Both install fine from the .tgz (which is how slackware binaries are packaged)
      D.  using a terminal:
Code: [Select]
su
mount /dev/sd[$whatever your USB is] /mnt
mount --rbind /dev /mnt/dev
mount -t proc /proc /mnt/proc
mount -t sysfs /mnt/sys
chroot /mnt
you should see the usual text the VL prints on a login.  You are now operating inside the new install environment (cool, huh?).  
This means your root directory(/) within the chroot terminal is actually /mnt/.  Any changes you make to the system will be made within the chroot environment (usb stick) and not the system you booted on startup.

3.  edit the file /etc/minitrd.conf (this will initially be saved in /etc/initrd.conf.sample.  use nano to edit it and save as mkinitrd.conf)
Nano is very easy to use (think I'm lying?  Try vi then get back to me.).  If you need more info there's a manpage and plenty of how tos on the web.
Code: [Select]
nano /etc/mkinitrd.conf.sample
you will see
Code: [Select]
# mkinitrd.conf.sample
# See "man mkinitrd.conf" for details on the syntax of this file
#
SOURCE_TREE="/boot/slack/initrd-tree"
#CLEAR_TREE="0"
#OUTPUT_IMAGE="/boot/slack/initrd.gz"
KERNEL_VERSION="3.10.17"
KEYMAP="us"
#MODULE_LIST="ext4"
#LUKSDEV="/dev/sda2"
#LUKSKEY="LABEL=TRAVELSTICK:/keys/alienbob.luks"
ROOTDEV="/dev/$USB_PATH" # replace $USB_PATH with your actual device node
ROOTFS="ext4"
#RESUMEDEV="/dev/sda2"
#RAID="0"
LVM="1"
UDEV="1"
#MODCONF="0"
WAIT="2"
OK, it won't look EXACTLY like that.  I'm on my slack64 machine now.  Here's what you need to do:
MAKE SURE:
LVM="1" you can live without this if you only want the USB system.  If you want LVM, you need it.
WAIT="10" (usb drives are slow to come up in early boot space.  your initrd will crash if you don't wait for root to appear)
ROOTDEV="$DEV-PATH-TO-ROOT"  this is the address for the usb stick you just installed to.  (ex. /dev/sdf1 )
OUTPUT_IMAGE="/boot/slack/initrd.gz"  this is the location of the ramdisk you will be making.  It's wise to sign your work.  The path should be the location of you vmlinuz, config.sys, and system.map files.  You might try "/boot/initrd-usbvector.gz".  I like to name my ramdisks because I usually have several in my bootdir.
Also, make sure there are no comment marks ("#") in front of the lines you need to change

4.  Make the ramdisk
Code: [Select]
mkinitrd -FThen open your boot directory and look for the $INITRD you specified in OUTPUT_IMAGE.

5.  Alter the /etc/fstab file.  This file tells your run time system where to mount various partitions.  It basically swaps places with the initrd after the early boot process is completed.
Code: [Select]
#Source Mount FS Options

/dev/sdb1                        /     xfs        noatime               1 1

devpts        /dev/pts        devpts gid=5,mode=620 0 0
proc                /proc             proc        defaults 0 0
tmpfs        /dev/shm      tmpfs                defaults 0 0
none        /tmp     tmpfs        defaults,size=500m 0 0


# CDROM, CDWRITER, DVD, FLOPPY
/dev/cdrom /mnt/cdrom      iso9660 defaults,noauto,ro,user 0 0
/dev/dvd /mnt/dvd        auto defaults,noauto,ro,user 0 0


#other stuff
/dev/Isbl/Home /home/OleHome xfs defaults 0 0

The fstab above is mine.  It's a little flaky to some newrer users because my filesystem is non-standard and I've done a few other tricks, like mounting /tmp on a ramdrive.  DO NOT WORRY about any of that.  Just look at the first line.  This is where your root parttion ("/") recievers its mount instructions.

Fill it out as follows:
Code: [Select]
[device node]    /    ext4 (unless your fs is not ext4)  defaults   1   0
I recommend staying away from UUIDs in fstab.  I don't like the clutter of big unfriendly HEX words in a file thats supposed to be human readable and, if udev is properly working, putting a UUID in fstab is redundant because udev maintains persistent naming of nodes.  

*This runs counter to the advice in man fstab, by the way.  Do as you will.  I find it much easier to use friendly node names in fstab.

6.  Leave the chroot and unmount the usb system
Code: [Select]
exit
cd /
umount /mnt
cat /etc/mtab
Check the contents of mtab, making sure your usb device isn't mounted on /mnt anymore

7.  Edit /boot/grub.cfg (this is normally a gigantic No-No, but I've always preferred to edit grub.cfg and not run update-grub until I know the system will run as routed.  more on that in the real tutorial)
Code: [Select]
nano /boot/grub.d/grub.cfgthen add something like this:
Code: [Select]
menuentry "Vector 3.0.8" --class linux --class gnu --class os {
insmod part_msdos
insmod $FILESYSTEM #replace the variable with the proper FS for your USB system
set root='(hd0,msdos1)' #This needs to be the correct root partition.  google grub setup if you need to
linux /slack/vmlinuz root=/dev/$USBPATH ro rootdelay=9 #Rootdelay is a nice feature that can hold the root mount without waiting in initrd.  You don't need it if you set up initrd as above
initrd /slack/initrd.gz  #All of these paths need to be corrected for your actual devices.  I will go deeper when I have time
}

8.  Reboot and select "Vector 3.0.8" from the grub2 menu.  If everything was done correctly, you're now into "Normal" VL 7 system mounted on a USB stick (This makes an awesome rescue disk and it's fun to show off to your geeky pals)
Code: [Select]
pvcreate /dev/hda   # this identifies your HDD to the lvm abstraction layer
vgcreate VCTRVG   # this creates a "Volume Group" from which you can create LVs
lvcreate -n $NAME -L $SIZE VCTRVG   # Create a logical volume
mkfs -t $FSTYPE /dev/VCTRVG/$NAME   # Create a filesystem on the LV
mount /dev/VCTRVG/$NAME /mnt  # mount the partition so you can write to it.

9.  Next, we need some rules for rsync.  rsync is a flexible and powerful file synchronizing utility.  We're going to "mirror" our usb setup onto the logical volume.  We need to make sure it doesn't go into a tailspin by trying to copy the directory we're writing to (/mnt), or waste a lot of space copying data that isn't really stored (/proc, /dev, /sys) or that we don't need at all (/tmp).
Code: [Select]
cat <<EOF > mirror-root.rules  #we're using the cat command with an stdin redirect to write our rules file
>- /proc
>- /sys
>- /dev
>- /tmp
>- /mnt
> -*.iso
>EOF
***DO NOT cut/paste the code blck above onto your command line.  It Won't Work.***
We just used a shell tool called a Here Document, or HEREDOC.  If you've never heard of these, it might be a good idea to google it before you try this procedure.  Basically, we're telling the shell to pushed the what we type on the standard input (Keyboard) into the file "mirror-rules.rules" UNTIL it sees the string "EOF"  The ">"s displayed on the codeblock above are shell generated artefacts to alert the user that: 1. Input is being recieved and concatenated without being interpreted, and 2. The enter key will generate a NEWLINE, but not engage the shell interpreter.  You can't paste this.  BASH won't be able to figure it out.  You'll have to type it or else C/P one line at a time, not including the ">"s (which would be pretty dumb, by the way...)

10.  Before we mirror, customize the system if you want.  You don't have to, but I liked my Vector USB system so much I pretty much created the laptop LVM system I was looking for, utility and graphics wise.  Now I have two exactly similar systems.

11.  Now use rsync.  Do a dry run first
Code: [Select]
rsync -nav --filter="merge ./mirror-root.rules" / /mnt
12.  You should see gibberish- LOTS of gibberish.  if you see ERROR statements or if it terminates quickly, check your syntax.  Otherwise, run it for real.
Code: [Select]
rsync -av --filter="merge ./mirror-root.rules" / /mnt
13.  Now, create the missing folders
Code: [Select]
cd /mnt
mkdir proc mnt dev tmp sys # if the kernel deosn't see all these folders it will halt the boot before root gets mounted.
THIS STEP IS VERY IMPORTANT.  Broadly, the way Linuces boot follows a set recipe:
   A.  chain the kernel (usually some variety of vmlinuz in a /boot directory)  
   B.  Kernel core unpacks into memory and, almost always, looks for a RAMDISK.
   C.  Run the RAMDISK to create the Early Boot Environment.  This is the part that takes some understanding.
        The Kernel is meant to run on a fully functioning platform.  On startup, things are all in a state of flux and,
        very often, things that "should" be there aren't initialized, yet.  The Ramdisk provides some immediately
        available modules AND a snapshot of the Linux File System Hierarchy (mouthful, eh?  google it if you ever
        get insomnia).  This lets the kernel think everything's fine so it can worry only about getting the system
        up.  This is a giant oversimplification, but, hey, I'm only committing a paragraph to one of the most vital
        phases of operation.  Make of it what you will.
   D. Find the "real" root device
   E. PIVOT the root directory onto the real root device.  The terminology is important to nerds, here.  Pivoting is
       considered hacky, but it works fine, and, right now, most Slackware based releases, including Vector are
       still pivoting.
Quote
So, Polaris, wy are you telling me all this?
So glad you asked.  Because IF you don't get the PATH of your Ramdisk written correctly, your kernel will halt right after the bootloader chains you in.  If you don't get the right modules into the RAMDISK (eg. LVM), your system will crash when it tries to pivot, because it won't understand what it's looking at.  If you get the PATH of your physical ("real") root device wrong, It will crash on pivot because it can't find the device, at all.  Finally, IF YOU DON'T CREATE A PROPER LOOKING Linux FS Hierarchy, it will crash when the kernel tries to mount /dev /sys
/proc, et. al.  and the mountpoints don't exist.
***For amatuers I've seen more problems in this area than anywhere else in a mirroring process***

14. set up another chroot
Code: [Select]
mount --rbind /dev /mnt/dev
mount -t proc /proc /mnt/proc
mount -t sysfs /mnt/sys
chroot /mnt

15.  edit the /etc/initrd file to add the correct path to the lvm share:
Code: [Select]
nano /etc/mkinitrd.confyou need to change the ROOTDEVICE parameter and make sure lvm is enabled also
Code: [Select]
ROOTDEV="/dev/mapper/VGVCTR/$NAME"  #usually lvm shares can be assigned as "/dev/mapper/$VG/$LV" or sometimes "/dev/mapper/$VG-$LV"
LVM="1"

16.  Edit fstab.  You need to tell root where the fs mounts are
Code: [Select]
nano /etc/fstabyou need something like:
Code: [Select]
/dev/mapper/VCTRVG-RootVector / ext4 defaults 1 1
You should be ok with all of the other entries in fstab

17.  Change the hostname, if you want
Code: [Select]
echo $NEWHOSTNAME > /etc/HOSTNAME
 

18.  Change grub.cfg again.  You can C/P the entry above and alter the paths to your lvm share, but make sure to add an "insmod lvm" line to the other insmod statements.

Here's a sample Grub.cfg entry
Code: [Select]
menuentry 'Vector LVM' --class gnu --class os {
load_video
insmod gzio
insmod part_msdos
insmod lvm
set root=lvm/X60--vg-Vector  #PAY CLOSE ATTENTION TO THIS SYNTAX "lvm/$VG-$LV"
echo 'Loading Vector Linux 7...'
linux /boot/vmlinuz-3.0.8 root=/dev/mapper/X60--vg-Vector ro
echo 'Loading initial ramdisk ...'
initrd /boot/initrd-polarisLVM.gz
}


REBOOT into LVM.

OK, I know this is sketch, but I'll write more when I can.  Fell free to ask questions and I'll do my best to return answers, but, like I said, I'll be doing a better tutorial when I can

Cheers,

$POLARIS96
« Last Edit: April 14, 2015, 05:51:33 pm by polaris96 »

M0E-lnx

  • Administrator
  • Vectorian
  • *****
  • Posts: 3499
Re: ($ALMOST) How to install VL 7 on LVM
« Reply #1 on: January 22, 2015, 09:54:28 am »
Nice.  I'd like to see this officially documented.  If you'd be kind enough to write it in rst syntax, we could include it in the vlcore documentation.

polaris96

  • Member
  • *
  • Posts: 16
Re: ($ALMOST) How to install VL 7 on LVM
« Reply #2 on: January 22, 2015, 12:30:09 pm »
I'm flattered and interested.

I'm writing a more comprehensive document.  I just ask a bit of time because I don't have much to spare :(

Watch the the doc above.  I'm adding a changelog to document tweaks.  When It's acceptable as a reference I'll post the whole thread into the "How To" section.

You are most welcome to use any or all of it as you see fit.  I'm glad to contribute.

Give me a bit of time to finish the tutorial to an acceptable standard and I'll push you rst and latex versions.
« Last Edit: January 22, 2015, 01:35:48 pm by polaris96 »