大网数据广告活动
服务器运维问答

How do I expand the root's volume size?

· 52CE 我爱测

I have Ubuntu Server 18.04 LTS running off a 16GB SanDisk USB pendrive in my server. From what I can remember, when I installed Ubuntu on there I had enabled LVM support. For some reason, when I ssh into my server, it says / is u…

问题原文

原帖链接 · leetbacoon · CC BY-SA 4.0

I have Ubuntu Server 18.04 LTS running off a 16GB SanDisk USB pendrive in my server. From what I can remember, when I installed Ubuntu on there I had enabled LVM support. For some reason, when I ssh into my server, it says / is using 99.6% of 3.87GB, but doing sudo fdisk -l /dev/sdm says:

Disk /dev/sdm: 14.6 GiB, 15664676864 bytes, 30595072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 7DF91AEG-9DE1-43B2-A7C7-EB564B51FEB2

Device       Start      End  Sectors  Size Type
/dev/sdm1     2048     4095     2048    1M BIOS boot
/dev/sdm2     4096  2101247  2097152    1G Linux filesystem
/dev/sdm3  2101248 30593023 28491776 13.6G Linux filesystem

And output from (parted) print with /dev/sdm selected gives me:

Model: SanDisk Cruzer Glide (scsi)
Disk /dev/sdm: 15.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2097kB  1049kB                     bios_grub
 2      2097kB  1076MB  1074MB  ext4
 3      1076MB  15.7GB  14.6GB

Running sudo df -h gives me:

Filesystem                         Size  Used Avail Use% Mounted on
udev                                12G     0   12G   0% /dev
tmpfs                              2.4G  241M  2.2G  10% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  3.9G  3.9G     0 100% /
tmpfs                               12G     0   12G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                               12G     0   12G   0% /sys/fs/cgroup
/dev/loop0                          90M   90M     0 100% /snap/core/6034
/dev/loop1                          90M   90M     0 100% /snap/core/6130
/dev/sdm2                          976M  155M  755M  17% /boot
tmpfs                              2.4G     0  2.4G   0% /run/user/1000
/dev/loop3                          92M   92M     0 100% /snap/core/6259

I have left out my ZFS volume above, as it's unnecessary to include it.

Running sudo vgs gives me:

  VG        #PV #LV #SN Attr   VSize  VFree
  ubuntu-vg   1   1   0 wz--n- 13.58g 9.58g

And, lastly, running sudo lvs gives me:

  LV        VG        Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  ubuntu-lv ubuntu-vg -wi-ao---- 4.00g                                                    

/dev/sdm is my root drive by the way. Any insight to this would be helpful. I do have ZFS installed managing other disks, but / is ext3 or 4.

One other thing to note is that I have LVM enabled because if my USB drive were to ever go bad I wanted to be able to restore the data to a new drive, whether it is smaller or larger than 16GB, and utilize the whole disk.

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

As you can see, there's about 9.58 GiB free in your volume group, so that's how much space you can add to the logical volume.

First, you can use lvextend to extend the size of the logical volume, to fill up the remaining space:

sudo lvextend --extents +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

Now, you can resize the filesystem in that logical volume.

sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

Finally, you can see the end result:

sudo df -h /

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-02-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。