Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use LVM to adjust hard disk Partition on Ubuntu system

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to use LVM to adjust hard disk partition on Ubuntu system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Let's first introduce the basics of hard disk partitioning:

Physical media The physical media

You should feel that the word "physics" has a great extension, although at first we assume that it is just a hard drive, or a partition. For example, / dev/hda,/dev/hda6,/dev/sda. You can convert any continuous block on a block device to one.

Physical Volume Physical Volume (PV)

A PV is just a physical medium with a lot of management data added to it-once you add it, LVM thinks it is. One of the holders of.

Physical partition Physical Extents (PE)

Physical partitions are really like large blocks of data, usually with several MB. PE can be assigned to a.

Volume group Volume Group (VG)

A VG is made up of many physical partitions (possibly from multiple physical volumes or hard drives). While it may be easy to think that an VG is made up of several hard drives (such as / dev/hda and / dev/sda), more specifically, it contains a lot of PE provided by those hard drives.

From this volume group, PE can be assigned to a.

Logical volume Logical Volume (LV)

Yes, we finally got somewhere. A logical volume is the end result of our work, and this is where we store information. This is equivalent to the traditional idea of zoning.

As with normal partitions, you can typically create one on a logical volume.

File system Filesystem

The file system is the form you want it to be: standard ext2,ReiserFS,NWFS,XFS,JFX,NTFS, etc. For the Linux kernel, there is no difference between normal partitions and logical volumes.

I tried to draw an ASCII diagram to visualize these.

A physical volume that contains many physical partitions:

+-- [Physical Volume]-- +

| | PE | PE | PE | PE | PE | PE | |

+-+

A volume group containing 2 physical volumes (PV) with 6 physical partitions:

+-[Volume Group]-+

| | +-[PV]-- + +-[PV]-+ |

| | PE | PE | PE | | PE | PE | PE |

| | +-+ +-+ |

+-+

We are now going to expand further:

+-[Volume Group]-+

| | +-[PV]-- + +-[PV]-+ |

| | PE | PE | PE | | PE | PE | PE |

| | +-- +-+ |

| | +-/ | |

| | |

| | +-- +-+ |

| | Logical | | Logical |

| | Volume | | Volume |

| | |

| | / home | | / var | |

| | +-+-+ |

+-+

This shows us two file systems that span two disks. The / home file system contains 4 physical partitions and the / var file system contains 2.

Use LVM on Ubuntu to easily adjust partitions and take snapshots

Ubuntu's installer provides an easy check box to "use LVM". Its description says that enabling logical volume management allows you to take snapshots and resize hard disk partitions more easily-here's how to do this.

LVM is a technology that is somewhat similar to "storage space" on RAID arrays or Windows. Although this technology is more useful on the server, it can also be used on the desktop-side PC.

Should you use LVM when you newly install Ubuntu?

The first question is, do you want to use LVM when installing Ubuntu? If so, Ubuntu makes it easy to do this with a click of the mouse, but this option is not enabled by default. As the installer said, it allows you to adjust partitions, create snapshots, merge multiple disks into a single logical volume, and so on-all while the system is running. Unlike traditional partitions, you don't need to shut down your system, drive from Live CD or USB, and then adjust when these partitions are not in use.

To be completely frank, the average Ubuntu desktop user may not be aware of whether they are using LVM. However, if you want to do something more advanced in the future, then LVM will help. LVM can be more complex and can cause problems when you recover data in the future-especially if you are inexperienced. There will be no significant performance degradation here-- LVM is thoroughly implemented in the Linux kernel.

Logical volume management description

Earlier, we have explained what LVM is. In a nutshell, it provides a layer of abstraction between your physical disk and the partitions presented in your system. For example, your computer may have two hard drives, both of which are 1 TB in size. You must have at least two zones on these disks, each with a size of 1 TB.

LVM provides a layer of abstraction on these partitions. Instead of traditional partitions on disks, LVM will treat these disks as separate "physical volumes" after you initialize them. You can then create "logical volumes" based on these physical volumes. For example, you can combine these two 1-TB disks into a 2-TB partition, your system will only see a 2-TB volume, and LVM will handle all this in the background. A set of physical volumes and a set of logical volumes are called "volume groups", and a typical system has only one volume group.

This abstraction layer makes it easy to adjust partitions, combine multiple disks into a single volume, or even create a "snapshot" of a file system with a running partition, all without unmounting the partition first.

Note that if you don't create a backup, it would be a bad idea to merge multiple disks into a single volume. It's like RAID 0Mel-if you combine two 1 TB volumes into a 2 TB volume, as long as one of the hard drives fails, you will lose important data on that volume. So, if you want to go this way, then backup is very important.

Graphical tools for managing LVM volumes

Typically, LVM is managed through Linux terminal commands. This works on Ubuntu, but there is a simpler graphical approach for you to use. If you are a Linux user and are familiar with GParted or similar partition managers, forget it-GParted doesn't support LVM disks at all.

However, you can use the disk tools that come with Ubuntu. This tool is also called the GNOME disk tool, or Palimpsest. Click the icon in dash to open it, search for "disk" and click enter. Unlike GParted, the disk tool will display LVM partitions under "other devices", so you can format these partitions as needed or adjust other options. The tool can also be used under Live CD or USB drivers.

Unfortunately, the disk utility does not support most of the powerful features of LVM, and there are no options such as managing volume groups, extending partitions, or creating snapshots. For these operations, you can do this through the terminal, but that is not necessary. Instead, you can open the Ubuntu Software Center, search for the keyword LVM, and then install the logical volume management tool, which you can install by running the sudo apt-get install system-config-lvm command in the terminal window. After installation, you can open the logical Volume Management tool from dash.

This graphical configuration tool, developed by Red Hat, is a bit old, but it is the only graphical way to do this, leaving the terminal commands behind.

For example, you want to add a new physical volume to the volume group. You can open the tool, select the new disk under the uninitialized entry, and then click the "initialize entry" button. You can then find the new physical volume under the unassigned volume, and you can use the add to existing Volume Group button to add it to the "ubuntu-vg" volume group, which is the volume group that Ubuntu created during installation.

The volume group view gives an overview of all your physical and logical volumes. Here, we have two physical partitions that span two separate hard drives, and we have a swap partition and a root partition, which is the partition chart set by default for Ubuntu. Because we added a second physical partition from another drive, there is now a lot of unused space there.

To extend the logical partition to the physical space, you can select it in the logical view, click Edit Properties, and then change the size to expand the partition. You can also narrow down the partition here.

Other options for system-config-lvm allow you to set up snapshots and mirrors. For traditional desktops, you may not need these features, but you can also do so graphically here. Remember, you can also use terminal commands to do all this.

This is the end of the introduction to "how to use LVM to adjust hard disk partitions on Ubuntu systems". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report