1. Getting Started. Introductory Material.
This guide assumes
that logical volumes have been installed and that there is no
volume dedicated to the “home” directory. The process for
establishing a “home” directory using partitions is
described in Ubuntu documentation Partitioning/Home/Moving.
The process for using logical volumes is similar, but involves a
substantially different process. Reading the Ubuntu documentation before beginning will be beneficial.
The nature of
logical volume management (LVM) is described here. What
is LVM
The following document is being referenced for informational
purposes: HowTo:
Set up Ubuntu Desktop with LVM Partitions.
This tutorial was based on using Ubuntu 16.04.
2. Preliminary Step. Determine Volume Allocations.
Determine the amount
of space that needs to be dedicated to the operating system (root)
and the amount of space that should be allocated to “home”.
Essentially the process you will be following will involve splitting the “root”
volume into two volumes.
One volume will remain "root" and a new volume “newhome” will
be created. In the table below, “root” has an allocation of 915G. Fifteen Gigabytes of data have been installed of which
4.3G occurs within the “home” directory.
Size
of the Hard Disk - 1000G
- Applicable VolumeCurrent Allocation (Usage)Proposed AllocationPartition1 (Boot)0.2550.255Root915 (15)100Home0 (4.3)815Swap1616Total (approx)931931
Obtain your logical
volume group name and volume name by using the Logical VolumeManagement application. This application is available through the Ubuntu Software Center by entering "LVM". This information is also available through the terminal by issuing the command "sudo lvdisplay" In this example the logical group name is:
“ubuntu-vg”. The logical volume name is “root”.
Backup
your computer before going further!
3. Early Steps.
Boot the computer
from a live CD.
The “root”
volume must be unmounted.
Before attempting to
use “apt-get” to download packages run “apt-get update” to get the software list updated should downloading be necessary.
Below are two reference resources that I relied on. Please note that the syntax used in some of the examples provided may not be available in Ubuntu.
ArchLinux Wiki: LVM
4. Reduce the size of both the root volume and root file system.
Approach
#1. The preferred approach.
a. Run: “lvresize -L 100G -r ubuntu-vg/root” Approach #2.
a.
Run: “e2fsck-f /dev/ubuntu-vg/root”.
b.
Run: “resize2fs
/dev/ubuntu-vg/root 70G”
c.
Run: “lvresize
-L 100G ubuntu-vg/root”
d.
Run: “Run “resize2fs
/dev/ubuntu-vg/root”
ArchLinuxWiki examples for reducing the size of the volume and file
system.
5. Create new volume and establish file system.
a. Run: "lvcreate -l 100%FREE ubuntu-vg -n newhome /dev/sda5"b. Run: "mkfs.ext4 /dev/mapper/ubuntu--vg-newhome"
ArchLinux Wiki example for creating a volume.
6. Modify the "fstab" file to mount "newhome" under /media/home
Modify the /etc/fstab file to add the lines:
# Logical volume for home
/dev/mapper/ubuntu--vg-newhome /media/home ext4 errors=remount-ro 0 2
/dev/mapper/ubuntu--vg-newhome /media/home ext4 errors=remount-ro 0 2
This can be done before you re-boot or after you reboot into normal operation. From this point on you can follow the prior Ubuntu
documentation on creating a home partition stating with the section: "Copy /home to the New Partition".
7. Copy home into the new /media/home volume.
a. Run: "sudo rsync -aXS --exclude='/*/.gvfs' /home/. /media/home/. "
8. Modify the "fstab" file to mount "newhome" under /home.
# Logical volume for home
/dev/mapper/ubuntu--vg-newhome /home ext4 errors=remount-ro 0 2
Don't reboot.
9. Save "old" home by copying to "old_home" and creating empty home folder.
a. Run: "cd / && sudo mv /home /old_home && sudo mkdir /home"
OK to reboot.
Final Notes: I did this once and kept the notes you see above, I will not claim to be any sort of expert. Evidently, importing the text from LibreOffice wasn't helpful in terms of formatting this web-page. Please let me know if there are any correction and/or modifications that would benefit future readers.
No comments:
Post a Comment