Ubuntu

//home移動到不同的LV並放大交換後無法登錄桌面環境

  • February 23, 2019

我將LVswap從1G擴大到4G。我還將單個 PV 移動到兩個不同的 LV,方法是縮小 LV/並在釋放的空間上創建 LV ,然後按照https://askubuntu.com/a/923943/1471/home``root``home

$ 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-homeat /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

重新啟動後,似乎 LVhome已正確安裝在/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

我該如何解決這些問題?謝謝。

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

要繼續,您沒有調整交換本身的大小,只是儲存交換的 LV。您需要重新執行mkswap.

引用自:https://unix.stackexchange.com/questions/502586