使婢差奴过一生是什么意思| 什么是重心| 梨子什么季节成熟| 肾结石吃什么药| 孕囊是什么意思| 绿色加红色是什么颜色| a型血的人是什么性格| 为什么阴道会放气| 福禄寿什么意思| 痛风吃什么食物| 提上日程是什么意思| 灵芝孢子粉什么时候吃最好| 什么牛奶好| t什么意思| 吴亦凡属什么| 梦到兔子是什么征兆| 水由什么构成| 尿隐血十一是什么意思| 宫腔镜检查后需要注意什么| 驴打滚是什么| 以色列是什么人种| 浆糊是什么意思| 什么条什么理| 一月十八号是什么星座| 梦到吃苹果是什么意思| 什么药可以缩阴紧致| 为什么叫汉族| 冠脉造影是什么意思| 心电图逆钟向转位是什么意思| 110斤穿什么码衣服| 黑色裤子配什么颜色t恤| 什么什么一什么| 米为什么会生虫| 四十岁月经量少是什么原因| 暗物质是什么| 1935年属什么| 偶尔头疼是什么原因| 膝盖疼看什么科| 什么颜色有助于睡眠| 雅诗兰黛是什么牌子| 血糖高的病人吃什么| 月子能吃什么水果| 全身酸痛是什么原因| 废品收入计入什么科目| 六块钱麻辣烫什么意思| 老是嗳气是什么原因| 呼吸短促是什么原因| 睡不着吃什么药最有效| 沙弗莱是什么宝石| 痛风吃什么消炎药| 四月十八日是什么日子| 宫颈疼是什么原因| 肾炎的饮食应注意什么| 南瓜不能和什么食物一起吃| 冰希黎香水什么档次| 不全骨折是什么意思| 四不伤害是指什么| 低头什么节| 胆红素高挂什么科检查| 首饰是什么意思| 酸奶不能和什么一起吃| 二月二是什么节| 身份证什么时候开始有的| 脑萎缩吃什么药最好| 固体玉米糖浆是什么| 牙齿酸胀是什么原因| 佳偶天成是什么意思| 浮生若梦是什么意思| 什么颜色加什么颜色是黄色| 骨折后吃什么好| 什么样的女人招人嫉妒| 三天没有大便是什么原因| 二百五是什么意思| 177是什么意思| 胃胀吃什么| 睾丸扭转是什么意思| 红豆生南国什么意思| 香港脚是什么症状图片| 区团委书记是什么级别| 03属什么| 洪七公什么生肖| 阳春是什么意思| 小肚子大是什么原因| 梦见自己吐了是什么意思| 仙人掌煎鸡蛋治什么病| 四肢无力是什么原因| 为什么宫颈会肥大| 爸爸的姥姥叫什么| 盆腔炎吃什么| 造口是什么| 湿浊中阻是什么意思| 番石榴什么时候成熟| 杭州灵隐寺求什么最灵| 嗜酸性气道炎症是什么意思| 降血压吃什么| 咳嗽吃什么水果| 八月六号是什么星座| 肚子里有虫子会有什么症状| 齿加禹念什么| 暂缓参军是什么意思| 微不足道什么意思| 意阑珊什么意思| 马赫是什么意思| 匪气是什么意思| 什么饼干养胃最好| 什么颜色显肤色白| hoegaarden是什么啤酒| 酱油是什么做的| 胎盘位于前壁是什么意思| z是什么火车| 高烧用什么方法降温最快| 心电监护pr是什么意思| 倾诉是什么意思| 为什么超市大米不生虫| 乙肝核心抗体偏高是什么意思| 西同念什么| 汉尼拔什么意思| 属马的本命佛是什么佛| 维生素b是什么食物| 湿疹用什么药膏最好| 斑点狗是什么品种| 溺水是什么意思| 胃胀吃点什么药| 卿字五行属什么| 黄鳝吃什么东西长得快| 上升星座代表什么| 读书有什么好处| 胃泌素高是什么原因| 禅师是什么意思| 酒糟鼻买什么药膏去红| 什么叫985大学| 橙色加蓝色是什么颜色| 肉燕是什么| 87年属什么的| 什么是ok镜| 双克是什么药| 皇协军是什么意思| 无极调光是什么意思| 孩子肠胃炎吃什么药| 献血之后吃什么比较好| 为什么不可以| 檄文是什么意思| 下肢静脉血栓挂什么科| 经常生病是什么原因| 李白字什么号什么| 荨麻疹什么东西不能吃| 梦见葱是什么意思| 整夜做梦是什么原因| 爱的真正含义是什么| 老被蚊子咬是什么原因| 始祖是什么意思| 韵母是什么| 芹菜和什么菜搭配最好| 猪大肠炒什么好吃| 雅字取名的寓意是什么| ysl是什么品牌| 白事的礼金叫什么| 悬案是什么意思| 白癜风是什么样子的| 梦见好多狗是什么预兆| 郑恺的父母是做什么的| 木瓜是什么味道| 社会很单纯复杂的是人是什么歌| 中焦湿热吃什么中成药| 耳洞为什么会发臭| 女性长胡子是什么原因| 甲状腺结节挂什么科| 乙肝抗体是什么意思| 云南有什么名酒| 鼻窦炎有什么特效药| 为什么不能在床上打坐| 晚上9点到11点是什么时辰| 趋是什么意思| 五谷丰登是什么生肖| 胡子长的快是什么原因| 移交是什么意思| 卸磨杀驴什么意思| 蜱虫是什么| 开光什么意思| 头晕视力模糊是什么原因| 中药为什么要热着喝| 晚上睡觉出汗是什么原因| 黄体酮吃多了有什么副作用| 眉毛中间长痘痘是什么原因| 甘油是什么成分| 红细胞压积什么意思| 挂号信什么意思| 吃什么水果解酒| 痛风有什么不能吃| 硫磺是什么| 诸侯国是什么意思| 400能上什么大学| 前列腺炎什么症状| 土是念什么| 6月24日什么星座| 为什么女生会来月经| 黑头是什么| 什么是性瘾症| 龟代表什么生肖| 审计署是什么级别| 水瓶座男生喜欢什么样的女生| 下火吃什么药| fasola是什么品牌| 固精缩尿是什么意思| 做试管前需要检查什么项目| 文武双全是什么意思| 深蓝色是什么颜色| 牛蒡根泡水喝有什么好处| 耳膜破了有什么症状| 鱼跃龙门是什么意思| 梨子什么季节成熟| 过命之交是什么意思| 四大才子是什么生肖| 97年属什么今年多大| 日晡是什么意思| 风什么意思| 627是什么星座| 石英是什么| 县委副书记是什么级别| 间接胆红素高是什么意思| 电视开不了机是什么原因| 焱字五行属什么| 五月是什么生肖| 脚气用什么药| 勇气是什么| 湿疹什么样| 腿部肿胀是什么原因引起的| 头顶痛是什么原因| 孕初期有什么症状| 南极为什么比北极冷| 肾结石炖什么汤喝最好| 打猎是什么意思| 玄牝是什么意思| 三月底是什么星座| 纺织业属于什么行业| 为什么一动就满头大汗| 睡觉手麻是什么原因| 窗口期什么意思| 吃饭后胃疼是什么原因| 蜂蜜加柠檬有什么功效和作用| 黑糖和红糖有什么区别| 99年是什么年| 狐惑病是什么病| 亲家母是什么意思| 片仔癀有什么功效| 健康证需要什么| 小手指麻木是什么原因| 母亲o型父亲b型孩子是什么血型| 吃什么不会胖又减肥| 不能生育的女人有什么特征| 天生丽质什么意思| 柳暗花明是什么生肖| 什么是鼻炎| 危机四伏是什么生肖| 什么是创业板股票| 心跳过快是什么原因引起的| 钢琴八级是什么水平| 吃什么性功能持久| 胃溃疡什么症状| 黄水疮是什么原因引起的| 喝胶原蛋白肽有什么好处| 4月7日什么星座| 什么是早泄| 据悉是什么意思| 百度

四川一交警驾驶套牌车违停 公安局纪委介入调

Get started with the basics of LVM (Logical Volume Manager) and efficiently manage the disk space on your Linux system.
百度 1、什么情况下需要进行用户注册?不管新、老报考人员,凡是首次使用此系统的报考人员都必须先进行用户注册,注册成功后才能进行上传照片、报名等后续操作。
Warp Terminal

The LVM (Logical Volume Manager) is a storage management system used by Linux operating systems. It allows for the creation of logical volumes, which can be viewed as containers that hold data.

The single biggest advantage of LVM is the ease of changing the size of logical volumes (consider it to as disk partitions).

In this tutorial, you'll learn what LVM is, how it works, and some of its other uses in Linux.

Before diving in, let's take a moment to learn a bit about LVM, ensuring you're equipped with the knowledge to make the most out of this storage management gem.

What is LVM in Linux?

Linux's Logical Volume Manager, or LVM for short, was introduced by Red Hat in 2001, and has since become a standard feature in many Linux distributions. It provides a way to map physical storage as virtual disks, which can be created, modified and destroyed as per your needs.

Instead of dealing directly with individual hard drives or storage devices, LVM creates a layer of abstraction, making storage management a breeze. This allows for more efficient use of your computer's storage capacity.

You can think of volume management on Linux using LVM as something very close or even a replacement to RAID, where you "pool" multiple physical disks together to create a one or more virtual storage devices.

Components of LVM:

Logical Volume Manager in Linux comprises several key components that work together to provide flexible storage management.

Here are the main components of LVM:

  1. Physical Volume (PV): Actual storage devices like hard drives.
  2. Volume Group (VG): Combine multiple PVs into a flexible pool of storage.
  3. Logical Volume (LV): Virtual partitions within a VG that users can interact with (think of them as disk partitions).
  4. Physical Extent (PE): Smallest units of storage in a PV.
  5. Logical Extent (LE): Similar to PEs, but within LVs.
  6. Metadata: Information describing the configuration of PVs, VGs, and LVs.

Enough reading about LVM! Let's dive in and get hands-on experience by creating partitions or logical volumes ourselves.

??
This is also a hands-on tutorial and you may follow it. However, I highly recommend doing so in a virtual machine, as playing with disks partitions will likely result in data loss on your bare metal system.

Installing LVM

Assuming you've already updated your system, let's proceed with installing LVM.

Actually, most Linux distributions come with lvm support pre-installed.

However, if, for some reason, they are not, you can easily install them by typing the following command in the terminal on Ubuntu or Debian-based systems:

sudo apt update
sudo apt install lvm2

Creating Partitions

??
While creating my virtual machine, I assigned it an extra 'disk' of 16 GB.

First things first – you're going to create partitions on your hard drive. This makes it easier for the next step, where you'll set up the physical volume.

You can either create these partitions on a plain, untouched storage space, or you can use existing partitions.

Our example disk is called /dev/sdb. It's a 16 GB hard drive without any partitions right now.

To check out the details of our /dev/sdb disk, including its current state, use this command.

lsblk
lsblk command to check disks in Linux

I am using the parted command which is a CLI based partitioning tool but you can also use the GUI based tools like GParted or GNOME Disks.

??
Creating partitions wipes all data on the selected disk. Double-check before proceeding to avoid unintended data loss.

I'll partition this 16 GB drive into two equal partitions and for that, I will use this command:

sudo parted /dev/sdb
Using parted to create partitions

Once you are inside parted wizard, create a partition table with:

mklabel gpt

Set up the units to Gigabytes:

unit GB

Now, create your first partition of 8 GB:

mkpart primary 0 8GB

For the other partition:

mkpart primary 8GB 16GB

Just to verify that your partitions has successfully created, check it using print command.

The output will look something like this:

Creating partitions with parted command

To exit out of parted just type quit.

Creating Physical Volumes (PV)

It acts as the fundamental component for storage management like as a raw disk, or a disk partition, allowing administrators to pool and manage diverse storage resources within a logical volume group.

To create Physical Volumes, you'll be using the pvcreate command:

sudo pvcreate /dev/sdb1

and for our second partition also:

sudo pvcreate /dev/sdb2
create physical volume PV with LVM

To list all the PVs, you can use this command:

sudo pvs
List all the PVs in LVM

You can also remove the physical volume using the pvremove command:

sudo pvremove /dev/sdb1

Creating a Volume Group (VG)

VG is a collection of one or more physical volumes (disks or partitions) that are grouped together to create a pool of storage resources. This volume grouping allows administrators to manage and allocate logical volumes (LVs) more flexibly.

In this section, you'll be creating a VG with the name of foss_vg for both /sdb1 and sdb2:

sudo vgcreate foss_vg /dev/sdb1 /dev/sdb2
Creating volume group with vgcreate

To list the Volume groups, we need to use vgs command. Just like:

sudo vgs

and the output would be like this:

List volume groups

Extending a Volume Group

Suppose you have a new drive added with the name of /dev/sdb3 and you want to add it to your existing Volume Group to extend the size of it. You can simply add it with the vgextend command.

sudo vgextend foss_vg /dev/sdb3

Creating Logical Volumes (LV)

These are the virtual partitions created within a Logical Volume Group (VG), forming a layer of abstraction over the underlying physical storage.

You will be creating a LV named as foss_lv with the size of 2084 MB:

sudo lvcreate -L 2048 -n foss_lv_01 foss_vg

and another one, with the size of 4096 MB:

sudo lvcreate -L 4096 -n foss_lv_02 foss_vg
Creating logical volume

Viewing the Logical volumes that we just created using the lvdisplay command:

sudo lvdisplay

and the output will be :

display logical volume

Creating a Filesystem on Logical Volumes

After creating a LV, the next step is often to initialize it with a file system to make it usable. The mkfs command is employed for this purpose.

Specifically, to create an ext4 file system on the newly formed logical volume, you would use the mkfs.ext4 command.

sudo mkfs.ext4 -m 0 /dev/foss_vg/foss_lv_01
make filesystem on a logical volume

You can now mount this newly created filesystem to somewhere in your directory like:

sudo mount /dev/foss_vg/foss_lv_01 /mnt
Mount logical volume

Extend a Logical Volume

Unlike traditional partitions, LVs offer dynamic resizing capabilities, allowing administrators to easily adjust their size without the need to re-partition the entire disk.

This flexibility enables efficient storage management, facilitating tasks such as extending or shrinking volumes to accommodate changing storage requirements.

?
This command only extends the size of logical volume but not the filesystem you have on it.
sudo lvextend -L +1200 /dev/foss_vg/foss_lv_01
extend a logical volume

To resize the filesystem and add back the new space we just created, type this command:

sudo resize2fs /dev/foss_vg/foss_lv_01
??
The resize2fs command is only used for extending ext2/ext3/ext4 file-systems. If you formatted the logical volume using a different file-system other than ext4 (as demonstrated in this tutorial), please refer to the apropos for your file-system.
extended logical volume

Remove Logical Volume

The lvremove command is utilized for the deletion of logical volumes. It is essential to ensure that the logical volume contains no important data before initiating the removal process.

Additionally, it is crucial to confirm that the volume is not currently mounted.

sudo lvremove /dev/foss_vg/foss_lv_01

Bonus: Automatically mount partition on boot using fstab:

It is simple, you just have to add one line at the bottom of the fstab file.

To edit the file, type:

sudo nano /etc/fstab

Move to the bottom and then add this line:

/dev/foss_vg/foss_lv_01    /mnt    ext4    defaults    0    2

The output would be something like this:

edit fstab file to automount logical volume

Once done, you can save and exit nano using CTRL+X then pressing y .

You also need to reload systemctl for the changes to take effect:

sudo systemctl daemon-reload

Conclusion:

The Logical Volume Manager is a powerful tool that provides many benefits for managing storage on your computer. It allows for efficient use of storage space, flexibility in file system support, and supports various backup and recovery options.

LVM might seem like a puzzle at first, but once you understand how its pieces fit together, it becomes surprisingly fun to use. So, take your time, explore, and feel free to reach out if you have questions. Happy LVM-ing!

It's FOSS turns 13! 13 years of helping people use Linux ??

And we need your help to go on for 13 more years. Support us with a Plus membership and enjoy an ad-free reading experience and get a Linux eBook for free.

To celebrate 13 years of It's FOSS, we have a lifetime membership option with reduced pricing of just $76. This is valid until 25th June only.

If you ever wanted to appreciate our work with Plus membership but didn't like the recurring subscription, this is your chance ??

Get Lifetime Membership of It's FOSS
About the author
Abhishek Kumar

Abhishek Kumar

I'm definitely not a nerd, perhaps a geek who likes to tinker around with whatever tech I get my hands on. Figuring things out on my own gives me joy. BTW, I don't?use?Arch.

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

itsfoss happy penguin

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.

儿童头疼吃什么药 深度睡眠是什么状态 一月底是什么星座 牛马是什么意思 安慰是什么意思
宫外孕破裂有什么症状 办理身份证需要带什么 血滴子是什么 痢疾是什么病 小孩子发烧手脚冰凉是什么原因
复杂囊肿是什么意思 高就是什么意思 冠军是什么意思 大四什么时候毕业 牙齿发白是什么原因
胎菊泡水喝有什么功效 睡觉打呼噜什么原因 左舌根疼痛是什么情况 藿香正气水是什么 法图麦是什么意思
走读生是什么意思helloaicloud.com 病毒感染咳嗽吃什么药效果好hcv8jop0ns4r.cn 垣什么意思hcv9jop7ns4r.cn 手麻疼是什么原因引起hcv9jop3ns3r.cn 结婚50年是什么婚hcv8jop7ns3r.cn
骨质增生吃什么药最好1949doufunao.com 喝红糖水有什么好处hcv7jop9ns9r.cn 吃什么食物有助于睡眠fenrenren.com 双侧附睾头囊肿是什么意思hcv8jop5ns8r.cn 福报是什么意思hcv9jop8ns1r.cn
犬瘟热是什么症状hcv8jop2ns0r.cn 代孕是什么1949doufunao.com 炉鼎是什么意思hcv9jop2ns7r.cn 韩束属于什么档次jasonfriends.com 中国发明了什么hanqikai.com
吃醋有什么好处luyiluode.com 血压高呕吐是什么征兆hcv8jop7ns1r.cn 异烟肼是什么药hcv8jop3ns0r.cn 荧光色是什么颜色hcv8jop0ns7r.cn 乳腺增生乳腺结节吃什么药hcv9jop6ns7r.cn
百度