免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 815 | 回复: 0
打印 上一主题 下一主题

Install Ubuntu on LVM partitions using Ubuntu live [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-11-07 19:45 |只看该作者 |倒序浏览

LVM (Logical Volume Manager) is a great piece of software which allow you to deal with Logical Volumes. Using LVM along with ext3 filesystem, you are allowed to extend the size of your logical drives which is pretty handy when running out of space.
Distributions like Fedora, Suse and Debian have a LVM aware installer. Unfortunately, at the time this article was written, Ubuntu does not offer such settings with the Desktop Install CD.
This article will cover how to create LVM partitions and how-to generate your partitions from this LVM volume.
LVM offer better flexibility when it comes to storage management. Using traditional partitioning system, when a partition becomes too small, the only solution left is to:
* create a bigger partition
* Copy the datas from the previous partition to the newly created one
* Change the mounting information of the partition
* Umount the old one, and mount the new one
LVM allow you to have better control of your storage. Excerpt from
http://en.wikipedia.org/wiki/Logical_Volume_Manager_
(Linux):
The LVM can:
引用:
* Resize volume groups online by absorbing new physical volumes (PV) or ejecting existing ones.
* Resize logical volumes online by concatenating extents onto them or truncating extents from them.
* Create read-only snapshots of logical volumes (LVM1).
* Create read-write snapshots of logical volumes (LVM2).
* Stripe whole or parts of logical volumes across multiple PVs, in a fashion similar to RAID0.
* Move online logical volumes between PVs.
* Split or merge volume groups in situ (as long as no logical volumes span the split). This can be useful when migrating whole logical volumes to or from offline storage.
It cannot:
* Mirror whole or parts of logical volumes, in a fashion similar to RAID1 or RAID5 mirroring of logical volumes. For this, it is recommended, that one use the Linux software RAID driver to mirror the underlying PVs to achieve redundancy.
this tutorial, we will install Ubuntu on an LVM filesystem. Because Ubuntu does not support this out of the box, we will have to create and format our partitions using fdisk. Once the partitions will be created, we will start the installer and point it to the right partition.
Because we are going to modify the hard-drive layout, be aware that you might delete datas. Please make sure you have backed-up all important datas.
1. Requirements:
In order to be able to do this tutorial, you will need the following:
* Ubuntu Desktop install liveCD
* An internet connection or lvm2 package
* Free disk space on your hard-drive
2. Preparing the environment:
2.1. Installing LVM
Boot up your computer using Ubuntu liveCD. Once logged in, open a terminal and install LVM
代码:
sudo apt-get install lvm2
If you have a lvm package copy on a removeable device, type:
代码:
sudo dpkg -i /path/to/lvm2.deb
Finally, lod the kernel module dm-mod.
代码:
sudo modprobe dm-mod
Now, we need to set up our Hard drive.
2.2. Partitioning the disk:
One of the requirements of Linux on LVM is that /boot has to be on a traditional partition. Because of this requirement, we will set up a separate /boot partition and a big LVM partition covering the rest of the hard drive. This LVM partition will then be splitted in a /, /home and swap partitions. Some extra space might be left on the LVM partition allowing you to grow your existing partitions if needed be.
At this stage, I consider that you have space available on your disk, if not, please use fdisk or gparted and delete some partitions, when done, refresh the kernel partition table by typing:
代码:
sudo partprobe
Well, let's create a boot partition of 100M and all the available space into a LVM partition:
代码:
$ sudo fdisk /dev/sda
The number of cylinders for this disk is set to 9729.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (1033-9729, default 1033):
Using default value 1033
Last cylinder or +size or +sizeM or +sizeK (1033-9729, default 9729): +100M
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1058-9729, default 1058):
Using default value 1058
Last cylinder or +size or +sizeM or +sizeK (1058-9729, default 9729):
Using default value 9729
Command (m for help):t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Command (m for help):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
$ sudo partprobe
OK, now we have our boot partition and our big LVM partition. We need to format /boot to ext3 filesystem, create our physical volume on /dev/sda3, create a Volume Group and Logical Volumes for /, /home and the swap partition. Finally format those logical volumes and install Ubuntu over those volumes.
代码:
$ sudo mke2fs -j /dev/sda2
$ sudo pvcreate /dev/sda3 #create a physical volume on /dev/sda3
Physical volume "/dev/sda3" successfully created
$ sudo vgcreate lvmvolume /dev/sda3 #create a volume group named lvmvolume using /dev/sda3 physical volume
Volume group "lvmvolume" successfully created
$ sudo lvcreate -n root -L 5G lvmvolume #create a logical volume of 5G named "root" in lvmvolume
Logical volume "root" created
$ sudo lvcreate -n home -L 10G lvmvolume #create a logical volume of 10G named "home" in lvmvolume
Logical volume "home" created
$ sudo lvcreate -n swap -L 2G lvmvolume #create a logical volume of 2G named "swap" in lvmvolume
Logical volume "swap" created
$ sudo mkfs -j /dev/lvmvolume/root -L root #format root as ext3
$ sudo mkfs -j /dev/lvmvolume/home -L home #format home as ext3
$ sudo mkswap -L swap /dev/lvmvolume/swap #format swap as swap filesystem, labelled swap
Here we are, no start the installer and when it comes to partitioning, select "manual" and choose the partitions /dev/lvmvolume/{root,home,swap} for /, /home and swap.
If the partitions are presented like: /dev/dm-X, type ls -l /dev/mapper/, this will help you tracking your volumes.
3. Finalizing the install
Before you reboot your computer, you need to install lvm2 package into your newly created system. To do this, you will chroot into you new ubuntu sytem and install the package in that environment.
Open a terminal and type:
代码:
$ sudo chroot /target
# apt-get update
# apt-get install lvm2
That's it, you can now reboot your system and boot on your Ubuntu system using LVM.


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/19135/showart_416917.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP