In traditional partition management, once the partition size is determined, it is difficult to change. Even if some software tools can do this, it will inevitably cause some data loss and reliability.
After LVM logicalvolumemanager (logical volume management) is used to manage our partitions, we can modify the partition size without worrying about data loss. This kind of Dynamic Allocation of partition size is what we need most. Since then, we do not have to worry about the confusion caused by full partitioning.
Use a USB flash drive or CD to start the Linux installation program
Http://www.bjwilly.com/archives/325.html
Start the Linux installation program, select "try to Ubuntu", open the terminal and execute the command to install lvm2
$ sudo apt-get install lvm2
Next, partition the disk.
Sudo fdisk-L # view the disk number
We can see that I have two disks, SDA and SDB. We use the dev/SDB disk as the object to be partitioned.
$ Sudo fdisk/dev/sdbthe Number of cylinders for this disk is set to 9729. there is nothing wrong with that, but this is larger than 1024, and cocould 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 # create a new partition command actione extendedp primary partiti On (1-4) ppartition number (1-4): 2 # Partition Number first cylinder (1033-9729, default 1033 ): using default value 1033 last cylinder or + size or + sizem or + sizek (1033-9729, default 9729): + 100 m # Set the partition SIZE command (M for help ): ncommand actione extendedp primary partition (1-4) ppartition number (1-4): 3 first cylinder (1058-9729, default 1058 ): using default value 1058 last cylinder or + size or + sizem or + sizek (1058-9 729, default 9729): Using default value 9729 command (M for help): tpartition number (1-4): 3hex code (type L to list codes ): 8e # modify the partition code in the LVM format command (M for help): W # execute 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 # refresh the disk
Using the above command, we divided DEV/SDB into two zones, namely MB and the remaining disk space. Next we will create our LVM
$ Sudo mke2fs-J/dev/SD2 $ sudo pvcreate/dev/sdb3 # create a physical block in sdb3 (Multiple Physical blocks can be created) physical Volume "/dev/sdb3" successfully created $ sudo vgcreate lvmvolume/dev/sdb3 # create a volume group named lvmvolume on this physical block (Multiple Volume groups can be created) volume group "lvmvolume" successfully created $ sudo lvcreate-N root-L 5g lvmvolume # create a volume named root in the volume group named lvmvolume, 5G logical volume "root" created $ sudo lvcreate-N home-L 10g lvmvolume # create a logical volume of 10g named "home" in lvmvolumelogical volume "home" created $ sudo lvcreate-N swap-L 2G lvmvolume # create a logical volume of 2G named "SWAp" in lvmvolumelogical 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, labeled swap
You can install Linux Through the above steps, and then you can mount the file system to the logical volume.
Original document address:
Http://www.debuntu.org/how-to-install-ubuntu-on-lvm-partitions/