扩容根硬盘,根硬盘还是原来的容量

漏洞扫描、网关、防火墙、补丁升级、数据备份和迁移、系统故障排除
回复
混世小萌羊
帖子: 8
注册时间: 2018-11-14 18:52
系统: Ubuntu 18.10
送出感谢: 1 次
接收感谢: 0

扩容根硬盘,根硬盘还是原来的容量

#1

帖子 混世小萌羊 » 2018-11-20 12:00

  • 1.硬盘信息,LVM信息

代码: 全选

[[email protected] mnt]# lsblk -f
NAME            FSTYPE      LABEL UUID                                   MOUNTPOINT
sda                                                                      
├─sda1          ext4              ec75c633-e82f-4546-a6c5-a8aa48d2b279   /boot
└─sda2          LVM2_member       ZM2oLw-mC8W-65ap-mE3z-sLqH-oVnb-mdj04J 
  ├─fedora-root xfs               c94b388d-fc94-49b4-9d34-271af81f6151   /
  └─fedora-swap swap              451b5184-395f-4d69-95f0-c13860bc1bd1   [SWAP]
 
[[email protected] mnt]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               fedora
  PV Size               <464.76 GiB / not usable 0   
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              118978
  Free PE               113132
  Allocated PE          5846
  PV UUID               ZM2oLw-mC8W-65ap-mE3z-sLqH-oVnb-mdj04J

  
 [[email protected] mnt]# vgdisplay
  --- Volume group ---
  VG Name               fedora
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  8
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <464.76 GiB
  PE Size               4.00 MiB
  Total PE              118978
  Alloc PE / Size       5846 / <22.84 GiB
  Free  PE / Size       113132 / 441.92 GiB
  VG UUID               o4fq0C-HD8j-u3Rm-wUXZ-Ztyb-gUFL-BOp7N8


[[email protected] mnt]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/fedora/swap
  LV Name                swap
  VG Name                fedora
  LV UUID                B5qCQ7-qabv-7cQy-VD7J-c0Qu-H763-GZFapm
  LV Write Access        read/write
  LV Creation host, time localhost, 2018-11-19 22:17:45 +0800
  LV Status              available
  # open                 2
  LV Size                <7.84 GiB
  Current LE             2006
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/fedora/root
  LV Name                root
  VG Name                fedora
  LV UUID                6QRnFx-3qTr-T1cX-JMoS-harH-iyUT-87GvOr
  LV Write Access        read/write
  LV Creation host, time localhost, 2018-11-19 22:17:46 +0800
  LV Status              available
  # open                 1
  LV Size                15.00 GiB
  Current LE             3840
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

   
  --- Logical volume ---
  LV Path                /dev/fedora/root
  LV Name                root
  VG Name                fedora
  LV UUID                6QRnFx-3qTr-T1cX-JMoS-harH-iyUT-87GvOr
  LV Write Access        read/write
  LV Creation host, time localhost, 2018-11-19 22:17:46 +0800
  LV Status              available
  # open                 1
  LV Size                456.92 GiB
  Current LE             116972
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  
[[email protected] mnt]# fdisk -l
Disk /dev/sda: 465.8 GiB, 500106780160 bytes, 976771055 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x3c7a658c

Device     Boot   Start       End   Sectors   Size Id Type
/dev/sda1  *       2048   2099199   2097152     1G 83 Linux
/dev/sda2       2099200 976769023 974669824 464.8G 8e Linux LVM


Disk /dev/mapper/fedora-root: 15 GiB, 16106127360 bytes, 31457280 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/fedora-swap: 7.9 GiB, 8413773824 bytes, 16433152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
  • 2. 扩容根硬盘

代码: 全选

// 将容量全部移到根硬盘内
[[email protected] mnt]# lvextend -l +100%FREE /dev/mapper/fedora-root
  Size of logical volume fedora/root changed from 15.00 GiB (3840 extents) to 456.92 GiB (116972 extents).
  Logical volume fedora/root successfully resized.
/*
  刷新文件系统是否扩容生效
  没有生效
*/
[[email protected] mnt]# resize2fs /dev/mapper/fedora-root
resize2fs 1.44.3 (10-July-2018)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/fedora-root
Couldn’t find valid filesystem superblock.
/*
 扩容xfs方法
 没有生效
*/
// 
[[email protected] mnt]# xfs_growfs /dev/mapper/fedora-root
xfs_growfs: /dev/mapper/fedora-root is not a mounted XFS filesystem
  • 3. 问题

代码: 全选

[[email protected] mnt]# fdisk -l
Disk /dev/sda: 465.8 GiB, 500106780160 bytes, 976771055 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x3c7a658c

Device     Boot   Start       End   Sectors   Size Id Type
/dev/sda1  *       2048   2099199   2097152     1G 83 Linux
/dev/sda2       2099200 976769023 974669824 464.8G 8e Linux LVM


Disk /dev/mapper/fedora-root: 456.9 GiB, 490616127488 bytes, 958234624 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/fedora-swap: 7.9 GiB, 8413773824 bytes, 16433152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

[[email protected] mnt]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 7.8G     0  7.8G   0% /dev
tmpfs                    7.8G     0  7.8G   0% /dev/shm
tmpfs                    7.8G  1.1M  7.8G   1% /run
tmpfs                    7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/mapper/fedora-root   15G  2.1G   13G  14% /
tmpfs                    7.8G  4.0K  7.8G   1% /tmp
/dev/sda1                976M  127M  783M  14% /boot
tmpfs                    1.6G     0  1.6G   0% /run/user/0
容量已经放到根硬盘了,扩容怎么生效呢
tocai
帖子: 34
注册时间: 2008-12-21 0:49
送出感谢: 0
接收感谢: 0

Re: 扩容根硬盘,根硬盘还是原来的容量

#2

帖子 tocai » 2018-12-06 0:43

xfs不清楚,我遇到用的问题,用的是以下命令解决
sudo btrfs filesystem resize max /
我没有用lvm,不需要lvm
头像
susbarbatus
帖子: 2965
注册时间: 2010-04-10 16:14
系统: Arch Linux
送出感谢: 6 次
接收感谢: 68 次

Re: 扩容根硬盘,根硬盘还是原来的容量

#3

帖子 susbarbatus » 2018-12-06 10:39

[[email protected] mnt]# xfs_growfs /dev/mapper/fedora-root
xfs_growfs: /dev/mapper/fedora-root is not a mounted XFS filesystem
要在已挂载的情况下使用这个命令
沉迷将棋中……
头像
susbarbatus
帖子: 2965
注册时间: 2010-04-10 16:14
系统: Arch Linux
送出感谢: 6 次
接收感谢: 68 次

Re: 扩容根硬盘,根硬盘还是原来的容量

#4

帖子 susbarbatus » 2018-12-06 10:40

不需要用resize2fs,这是扩容ext2/3/4的命令
沉迷将棋中……
回复

回到 “服务器维护和硬件相关”