How to Install Mint on LVM2 volumes

Write tutorials and howtos in here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Do not start a support topic here please. Before you post please read this

How to Install Mint on LVM2 volumes

Postby piratesmack on Mon Feb 01, 2010 3:57 pm

This isn't a full-on LVM Howto. For that, see this

These are just the steps I took to install Linux Mint 8 on LVM2 volumes.

IMPORTANT: This isn't for beginners, this is for people who know what LVM is and why they want to use it.

In this example, I:
    -Used an unpartitioned hard disk, /dev/sda
    -Created a physical volume, /dev/sda1
    -Created a volume group called 'mintvg'
    -Created 3 logical volumes: swap, root, and home
    -Used ext4 as my filesystem


Please backup your data before proceeding.
If you aren't confident, you may want to try this in a virtual machine first.


The Steps:

    1. Boot from the Linux Mint Live CD

    2. Open a Terminal or Synaptic Package Manager and install LVM2:
    Code: Select all
    sudo apt-get update
    sudo apt-get install lvm2


    (If you already have your logical volumes set up, you can skip ahead to step 7)

    3. Use fdisk to create a Linux LVM partiton (Type 8e):
    Code: Select all
    sudo fdisk /dev/sda
    n # Create a new partition
    p # Make it primary
    1 # Partition number
       # Start (blank means default)
       # End
    t  # Change partition type
    1 # Partition to change
    8e # 8e = Linux LVM
    w # Write partition table to disk and exit

    *note: if you are using Grub Legacy (Linux Mint 7 and earlier), you will need to create a regular partition for /boot. This isn't needed for Grub2 or LILO.

    4. Initialize your LVM partition (physical volume):
    Code: Select all
    sudo pvcreate /dev/sda1


    5. Create a volume group:
    Code: Select all
    # Create a volume group called 'mintvg'
    sudo vgcreate mintvg /dev/sda1


    6. Create your logical volumes:
    Code: Select all
    # Create a 2GB logical volume called 'swap'
    sudo lvcreate -L 2G -n swap mintvg
    # Create a 10GB logical volume called 'root'
    sudo lvcreate -L 10G -n root mintvg
    # Create a 50GB logical volume called 'home'
    sudo lvcreate -L 50G -n home mintvg

    -If you want your logical volume to use the remaining free space, you can do:
    Code: Select all
    lvcreate -l 100%FREE -n LVNAME VGNAME

    *note that the 'l' is lower-case this time

    7. Activate your volume group:
    Code: Select all
    sudo vgscan --mknodes
    sudo vgchange -ay

    The device nodes will be created in /dev/mapper/YOURVG-YOURLV and will be symlinked in /dev/YOURVG/YOURLV

    8. You must pre-format the logical volumes for the installer to detect them:
    Code: Select all
    sudo mkswap /dev/mintvg/swap
    sudo mkfs.ext4 /dev/mintvg/root
    sudo mkfs.ext4 /dev/mintvg/home


    9. Install Mint:
    -Start the installer and follow the on-screen instructions until you reach the partitioner.
    -Choose manual partitioning (specify partitions manually).
    -You should see something like:
      /dev/mapper/mintvg-swap
      /dev/mapper/mintvg-root
      /dev/mapper/mintvg-home

    -Choose those, click 'Change', and set the filesystem and mountpoints
    -In the next step, click "Advanced." For me, it was trying to install the bootloader to my root logical volume (/dev/mintvg/root). Change it to '/dev/sda' or the mbr of your hard drive.
    -Continue with the rest of the install like normal,
    -DON'T REBOOT YET! At the end of the install, choose 'Continue testing'

    10. Set up a chroot:
    Code: Select all
    sudo mount /dev/mintvg/root /target
    sudo mount /dev/mintvg/home /target/home
    sudo mount --bind /dev /target/dev
    sudo mount --bind /dev/pts /target/dev/pts
    sudo mount --bind /proc /target/proc
    sudo chroot /target


    11. Install LVM2 inside the chroot:
    Code: Select all
    apt-get update
    apt-get install lvm2
    exit


And that's it, time to reboot.

Hopefully somebody finds this helpful
Last edited by piratesmack on Tue Aug 31, 2010 2:52 pm, edited 7 times in total.
piratesmack
Level 5
Level 5
 
Posts: 710
Joined: Mon May 26, 2008 3:08 pm

Linux Mint is funded by ads and donations.
 

Re: Install Mint on LVM2 volumes

Postby Husse on Sat Feb 06, 2010 4:07 pm

The warning that this is not for beginners must be emphasized and I could add the it might not be for the faint hearted either :)
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19710
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: Install Mint on LVM2 volumes

Postby cnacorrea on Thu Mar 25, 2010 10:22 pm

Your mini-tutorial was very useful to me.

Thank you! :D

Best regards,
Carlos.
cnacorrea
Level 1
Level 1
 
Posts: 1
Joined: Thu Mar 25, 2010 10:15 pm

Re: Install Mint on LVM2 volumes

Postby piratesmack on Fri Mar 26, 2010 12:11 am

Glad somebody found this useful. :)
piratesmack
Level 5
Level 5
 
Posts: 710
Joined: Mon May 26, 2008 3:08 pm

Re: How to Install Mint on LVM2 volumes

Postby chasmc on Sun Sep 19, 2010 12:43 am

This site helps fill in some of the cracks if you mapped your drive slightly different you'll gain some more perspective.
http://www.funzt.info/?p=527

Good Luck


-- Charles
chasmc
Level 1
Level 1
 
Posts: 9
Joined: Sun Jul 25, 2010 4:59 pm

Re: How to Install Mint on LVM2 volumes

Postby chasmc on Mon Sep 20, 2010 12:58 am

Here is an example of what I did that worked with some important notes on a pitfall.

One drive: /dev/sdb (in this case) [Actually a 2nd drive was used for swap but irrelevent here so no further mention in this posting]

partitioning:
/dev/sdb1 NTFS WinXP -- Installed first to let it be greedy with MBR in its special way

/dev/sdb2 ext3 /boot
/dev/sbd3 ext3 / (root)
/dev/sdb4 lvm (8e)

Then /dev/sdb4 is lvm'd into the following:
/home 600GB
/tmp 60GB
/var 10GB
/opt 10GB
/usr 10GB

all five of these(above) formatted ext3

Did all the steps through 9. where you get to "DON'T REBOOT YET" and 'Continue Testing'

then did,

Code: Select all
mint / # df -h
Filesystem            Size  Used Avail Use% Mounted on
aufs                  754M   67M  687M   9% /
none                  747M  312K  747M   1% /dev
/dev/sr0              615M  615M     0 100% /cdrom
/dev/loop0            598M  598M     0 100% /rofs
none                  754M     0  754M   0% /dev/shm
tmpfs                 754M   40K  754M   1% /tmp
none                  754M  308K  754M   1% /var/run
none                  754M  4.0K  754M   1% /var/lock
none                  754M     0  754M   0% /lib/init/rw
mint / # mount /dev/sdb3 /target
mint / # mount /dev/mapper/vg01-home /target/home
mint / # mount /dev/sdb2 /target/boot
mint / # mount /dev/mapper/vg01-usr /target/usr
mint / # mount /dev/mapper/vg01-var /target/var
mint / # mount /dev/mapper/vg01-opt /target/opt
mint / # mount /dev/mapper/vg01-tmp /target/tmp
mint / # mount --bind /dev /target/dev
mint / # mount --bind /dev/pts /target/dev/pts
mint / # mount --bind /proc /target/proc

mint / # chroot /target apt-get update
mint / # chroot /target apt-get install lvm2

mint / # umount /target/dev/pts
mint / # umount /target/dev
mint / # umount /target/proc
mint / #


after all that mounting and chroot'ing and starting unmouting, I was lazy and used 'Disk Utility' off the 'Sytem Tools' menu to unmount the other mounts.

Next, rebooted to see the new system.

* * B I G * P R O B L E M(pitfall) might occurr at this point like it did for me.

login prompt tries to log you into your nonroot account you set up in the install process but keeps kicking you back out!

You might gleen the error about "not enough permission to run /bin/bash."
*(edit -- actually it says: 'Cannot execute /bin/bash: Permission denied' )

I found the solution to this from this related post from a guy named Luis. Thanks Luis.
http://www.linuxfromscratch.org/piperma ... 42472.html

So here is what worked for me.

At this point, reboot not into regular linuxboot but the option at the bootloader for checking/admin(what ever it's called), usually the second choice.
( * Edit: actually it is 'recovery mode' )

Next, when choice is given for root prompt with networking take it. or not networking, either is ok for this effort.

now do ...

# cd /
then
# ls -la
which gives
Code: Select all
chas@amd64 / $ ls -la
total 13237
drwx------  21 root root     4096 2010-09-19 19:52 .
drwx------  21 root root     4096 2010-09-19 19:52 ..
drwxr-xr-x   2 root root     4096 2010-09-19 19:52 bin
drwxr-xr-x   5 root root     1024 2010-09-19 22:15 boot
drwxr-xr-x  18 root root     4240 2010-09-19 23:49 dev
drwxr-xr-x 133 root root    12288 2010-09-19 23:03 etc
drwxr-xr-x   4 root root     4096 2010-09-19 19:49 home
lrwxrwxrwx   1 root root       33 2010-09-19 19:52 initrd.img -> boot/initrd.img-2.6.32-22-generic
-rw-r--r--   1 root root 13423683 2010-05-17 15:54 initrd.lz
drwxr-xr-x  21 root root    12288 2010-09-19 22:15 lib
drwx------   2 root root    16384 2010-09-19 15:54 lost+found
drwxr-xr-x   3 root root     4096 2010-04-29 16:10 media
drwxr-xr-x   2 root root     4096 2010-04-23 05:11 mnt
drwxr-xr-x   3 root root     4096 2010-04-29 16:10 opt
dr-xr-xr-x 159 root root        0 2010-09-19 18:03 proc
drwx------  10 root root     4096 2010-09-19 22:47 root
drwxr-xr-x   2 root root    12288 2010-09-19 22:15 sbin
drwxr-xr-x   2 root root     4096 2009-12-05 15:55 selinux
drwxr-xr-x   2 root root     4096 2010-04-29 16:10 srv
drwxr-xr-x  12 root root        0 2010-09-19 18:03 sys
drwxrwxrwt   9 root root     4096 2010-09-19 23:50 tmp
drwxr-xr-x  11 root root     4096 2010-06-11 10:54 usr
drwxr-xr-x  14 root root     4096 2010-04-30 08:24 var
lrwxrwxrwx   1 root root       30 2010-09-19 19:52 vmlinuz -> boot/vmlinuz-2.6.32-22-generic
chas@amd64 / $


notice the permissions on the dots
Code: Select all
drwx------  21 root root     4096 2010-09-19 19:52 .
drwx------  21 root root     4096 2010-09-19 19:52 ..


do a
Code: Select all
# chmod 755 ..

and for good measure you can do same for the one dot if you like
Code: Select all
# chmod 755 .


now you should see the root listing for those two being drwxr-xr-x instead of drwx------

I think this is problem is just a natural by product of chroot'ing when we were doing it from root.

Anyway, that's it, reboot regular (# shutdown -r now "bye bye" )


Good Luck.

-- chasmc
chasmc
Level 1
Level 1
 
Posts: 9
Joined: Sun Jul 25, 2010 4:59 pm

Re: How to Install Mint on LVM2 volumes

Postby colin_e on Thu Oct 14, 2010 11:09 am

Note i'm an old-time *nix user returning to Unix after several years in the Windows wilderness, so forgive me if I ask some naive questions.

Regarding chasmc's post. By-
  • Creating a single large partition
  • Putting LVM on top
  • Putting 5 filesystems on top of LVM
  • Having Linux present the filesystems to the user in a single logical file structure

haven't you effectively come back to where you started? If you had just mounted "/" on your original physical partition you would have achieved the same appearance to the user, including the ability for areas like /usr or /var to grow/shrink at will, with tens of thousands (hundreds of thousands?) lines less code between you and the disk?

I realise this is not an entirely equal comparison. In your LVM setup you could if you wanted to put different filesystem types on each of your your logical volumes, and you can also do things like wipe/tune/backup each filesystem separately. LVM presumably also lets you add a second disk in due course and just expand the volume group without rearranging mount points.

However it does still seem to beg the question. What's the compelling value in using LVM on a single physical disk, beyond proving that you can, and/or testing advanced disk management techniques?

Regards: colin_e
colin_e
Level 1
Level 1
 
Posts: 16
Joined: Thu Oct 14, 2010 10:18 am

Re: How to Install Mint on LVM2 volumes

Postby chasmc on Sat Oct 16, 2010 5:08 am

colin_e wrote:
In your LVM setup you could if you wanted to put different filesystem types on each of your your logical volumes, and you can also do things like wipe/tune/backup each filesystem separately. LVM presumably also lets you add a second disk in due course and just expand the volume group without rearranging mount points.

However it does still seem to beg the question. What's the compelling value in using LVM on a single physical disk, beyond proving that you can, and/or testing advanced disk management techniques?

Regards: colin_e


Yes.


For me the appeal is the adding of another drive as you mention.

Even more there is the prospect of allocating available space to the right directory as things get full, instead of guessing how full each directory will get at the time of initial system installation.

Once it's set up the setup is ultra transparent in day to day use and rebooting etc.


-- Charles
chasmc
Level 1
Level 1
 
Posts: 9
Joined: Sun Jul 25, 2010 4:59 pm

Re: How to Install Mint on LVM2 volumes

Postby chasmc on Thu Oct 21, 2010 12:52 am

colin_e wrote:Note i'm an old-time *nix user returning to Unix after several years in the Windows wilderness, so forgive me if I ask some naive questions.

Regarding chasmc's post. By-
  • Creating a single large partition
  • Putting LVM on top
  • Putting 5 filesystems on top of LVM
  • Having Linux present the filesystems to the user in a single logical file structure

...

Regards: colin_e


After review let me correct the above outline to the following.
  • Used a Single Large Drive
  • Created FOUR physical partitions
  • Put Windows XP on One of the Physical Partitions
  • Put /boot on the 2nd Physical Partition
  • Put / (root) on the 3rd Physical Partion
  • Put LVM designation on the very large fourth Physical Partition
  • THEN Put a Volume Group atop the LVM Physical Partition
  • Then put 5 Logical Volumes on top of the Volume Group
    ...
chasmc
Level 1
Level 1
 
Posts: 9
Joined: Sun Jul 25, 2010 4:59 pm

Re: How to Install Mint on LVM2 volumes

Postby spider623 on Sun Jun 17, 2012 12:49 pm

thnx for the exelent post i had installed f17, an exelent distro if i may say but with almost zero fglrx support(gallium 0.4 had better video quality but it could not play any hight end 3d game like oblivion) and thanks to your post i didn't need to format my home directory again :D
spider623
Level 1
Level 1
 
Posts: 2
Joined: Sun Jun 17, 2012 12:37 pm

Re: How to Install Mint on LVM2 volumes

Postby framp on Tue Nov 13, 2012 6:36 pm

Very useful howto! I wanted to install a newer Mint version on my box and reuse my already existing LVM. Actually I had to skip only the PV and LV creation steps in your howto and finally was successful very quick.
User avatar
framp
Level 2
Level 2
 
Posts: 59
Joined: Thu Jan 28, 2010 4:27 pm
Location: Stuttgart, Germany

Re: How to Install Mint on LVM2 volumes

Postby daimon00 on Sat Nov 24, 2012 9:04 am

I tried the steps in Mint 14 cinamon, but when I did the apt-get lvm2 in the chroot, it doesn't have acces to the net!!
How do I solve this?
PD: I'm connected to an ethernet connection in the live OS.

Thank you
daimon00
Level 1
Level 1
 
Posts: 5
Joined: Thu Nov 22, 2012 5:40 am

Re: How to Install Mint on LVM2 volumes

Postby daimon00 on Sun Nov 25, 2012 4:07 am

In my case, to share the internet connection I had to do this before chroot.

sudo mount --bind /etc/resolv.conf /mnt/etc/resolv.conf
daimon00
Level 1
Level 1
 
Posts: 5
Joined: Thu Nov 22, 2012 5:40 am

Re: How to Install Mint on LVM2 volumes

Postby Incentive I.C on Sun Jun 01, 2014 3:56 pm

Does doing this wipe the whole drive?
The best way to learn from it is break it OS's (is there a plural for OS?) included.
User avatar
Incentive I.C
Level 4
Level 4
 
Posts: 325
Joined: Mon Aug 27, 2012 9:20 pm

Re: How to Install Mint on LVM2 volumes

Postby clfarron4 on Sun Jun 01, 2014 6:13 pm

Incentive I.C wrote:Does doing this wipe the whole drive?


No, this tutorial assumes you have already wiped the drive.
Problems? Tell us EXACTLY what you've done and what you expected to happen, IN DETAIL. That will save us questions, and we should get along better,

I have dysgraphia. This means I might have understood you incorrectly through no fault of my own.
User avatar
clfarron4
Level 5
Level 5
 
Posts: 510
Joined: Thu Sep 19, 2013 6:20 pm

Re: How to Install Mint on LVM2 volumes

Postby Incentive I.C on Sun Jun 01, 2014 9:14 pm

Thanks tried doing this and bootloader install failed in vmbox
The best way to learn from it is break it OS's (is there a plural for OS?) included.
User avatar
Incentive I.C
Level 4
Level 4
 
Posts: 325
Joined: Mon Aug 27, 2012 9:20 pm

Linux Mint is funded by ads and donations.
 

Return to Tutorials / Howtos

Who is online

Users browsing this forum: No registered users and 9 guests