将`/`和`/home`移动到不同的LV并扩大swap后无法登录桌面环境

将`/`和`/home`移动到不同的LV并扩大swap后无法登录桌面环境

我把LVswap从1G扩大到4G。我还通过缩小 LV并在释放的空间上创建 LV ,将单个 PV 中的/和移动到两个不同的 LV ,然后执行以下操作/homeroothomehttps://askubuntu.com/a/923943/1471

$ sudo mkdir /mnt/home
$ sudo mount /dev/mapper/lubuntu--vg-home  /mnt/home/
$ sudo cp -r /home/* /mnt/home/
$ sudo mv /home /home-orig
$ sudo mkdir /home

并修改/etc/fstab为以下内容,其中我重命名/dev/mapper/lubuntu--vg-swap_1/dev/mapper/lubuntu--vg-swap(因为我已将 LV 从默认名称重命名swap_1swapby lvrename),并添加一行用于挂载/dev/mapper/lubuntu--vg-home/home

$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/lubuntu--vg-root /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=0C1E-EE69  /boot/efi       vfat    umask=0077      0       1
/dev/mapper/lubuntu--vg-swap none            swap    sw              0       0
# my change:
/dev/mapper/lubuntu--vg-home /home               ext4    defaults 0       2

重新启动后,LV 似乎home已正确安装在/home

$ pwd
/home/t
t@olive:~$ df .
Filesystem                   1K-blocks   Used Available Use% Mounted on
/dev/mapper/lubuntu--vg-home 425480640 180336 403617312   1% /home

但有两个问题

  1. 虽然我仍然可以登录虚拟控制台,但无法登录Lubuntu的LXDE。
  2. free显示交换大小仍然是 1GB。

    $ free -h
                  total        used        free      shared  buff/cache   available
    Mem:           3.3G        196M        2.9G        5.3M        239M        2.9G
    Swap:          979M          0B        979M
    $ cat /proc/swaps 
    Filename                Type        Size    Used    Priority
    /dev/dm-1                               partition   1003516 0   -2
    $ ls /dev/mapper/ -la
    total 0
    drwxr-xr-x  2 root root     120 Feb 23 16:47 .
    drwxr-xr-x 22 root root    4260 Feb 23 16:47 ..
    crw-------  1 root root 10, 236 Feb 23 16:47 control
    lrwxrwxrwx  1 root root       7 Feb 23 16:52 lubuntu--vg-home -> ../dm-2
    lrwxrwxrwx  1 root root       7 Feb 23 16:52 lubuntu--vg-root -> ../dm-0
    lrwxrwxrwx  1 root root       7 Feb 23 16:52 lubuntu--vg-swap -> ../dm-1
    

我该如何解决这些问题?谢谢。

答案1

首先,您cp尚未保留权限或所有权。使用cp -a而不是cp -r.

接下来,您还没有调整交换本身的大小,只是调整存储交换的 LV 的大小。您需要重新运行mkswap

相关内容