Create a volume group consisting of at least two physical volumes of 10 Gb. The PE size is 8 MB, and then create a logical volume mylv1 with a size of 5 GB in the volume group, format it as an ext4 file system and mount it to the/users directory automatically upon startup;
Create a new mageedu user. Its home directory is/users/mageedu, And Then Su to mageedu user. Copy the/etc/fstab file to your home directory;
Expand mylv1 to 7 GB to ensure that data of/users/mageedu is not affected, and then su to mageedu users to verify normal access to the positive data;
Reduce mylv1 to 4 GB to ensure that the data of/users/mageedu is not affected. Then, Su to mageedu users, and the verified data can be accessed normally;
Create a snapshot volume snap-mylv1 for mylv1 and use the data in its CP to the/backups/directory. Keep the original owner group and other information;
First, create two partitions, one 6 GB and one 4 GB, and convert the partition format to 8E (LVM format). In this example,/dev/sda3 (6 GB) is used) and/dev/sda5 (4G );
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/3E/3C/wKioL1PGluvQ3l4tAAEs_WeYU9Q311.jpg "Title =" 1.png" alt = "wkiol1pgluvq3l4taaes_weyu9q311.jpg"/>
Create PV:
# Pvcreate/dev/sda3/dev/sda5
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/3E/3C/wKioL1PGl3nDGdn3AACx1lNsnSY016.jpg "Title =" 2.png" alt = "wkiol1pgl3ndgdn3aacx1lnsnsy016.jpg"/>
Create VG:
# Vgcreate-S 8 Mb/dev/myvg/dev/sda3/dev/sda5
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/3E/3D/wKioL1PGmZ-QTzR7AACJPoOsWS4512.jpg "Title =" 3.png" alt = "wKioL1PGmZ-QTzR7AACJPoOsWS4512.jpg"/>
# Vgdisplay/dev/myvg
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/3E/3D/wKioL1PGmcOR3DwMAAF3Jc_44tY690.jpg "Title =" 4.png" alt = "wkiol1pgmcor3dwmaaf3jc_44ty690.jpg"/>
Create 5g LV:
# Lvcreate-N/dev/myvg/mylv1-L 5g/dev/myvg
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/3E/3D/wKiom1PGmbiTKoBLAAFJGJ7HRMA919.jpg "Title =" 5.png" alt = "wkiom1pgmbitkoblafjgj7hrma919.jpg"/> Format the 5g LV and create the/users directory:
# Mke2fs-T ext4/dev/myvg/mylv1
# Mkdir/users
Set automatic mounting upon startup
# Vim/etc/fstab
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/3E/3D/wKiom1PGmqiCLIGmAAFm8eSc1eo409.jpg "Title =" 6.png" alt = "wkiom1pgmqicligmaafm8esc1eo409.jpg"/> # Mount-
# Mount
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/3E/3D/wKioL1PGnATjfWjDAAGa18hYRyg881.jpg "Title =" 7.png" alt = "wkiol1pgnatjfwjdaaga18hyryg881.jpg"/> New User mageedu
# Useradd-D/users/mageedu
# Su-mageedu
$ CP/etc/fstab.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/3E/3D/wKiom1PGm9_ShuFbAADKhh5tW_Q622.jpg "Title =" 8.png" alt = "wkiom1pgm9_shufbaadkhh5tw_q622.jpg"/>
Extend LV to 7G:
# Lvextend/dev/myvg/mylv-L 7G
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/3E/3D/wKiom1PGnImwUtdlAAFJPgAY-HQ513.jpg "Title =" 9.png" alt = "wKiom1PGnImwUtdlAAFJPgAY-HQ513.jpg"/> verify that data is accessible
# Su-mageedu
$ Cat fstab
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/3E/3D/wKiom1PGnOjg_4rvAAKGlv8bfcs825.jpg "Title =" 10.png" alt = "wkiom1pgnojg_4rvaakglv8bfcs825.jpg"/> reduce LV to 4G, uninstall the/users directory first, use e2fsck-F to detect mylv, later, we use resize2fs to reduce logical boundaries, and then lvreduce to reduce physical boundaries:
# Umount/users
# E2fsck-F/dev/myvg/mylv1
# Resize2fs/dev/myvg/mylv1 4G
# Lvreduce/dev/myvg/mylv1-L 4G
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/3E/3D/wKiom1PGni_B52dYAAIXcogI-V4653.jpg "Title =" 11.png" alt = "wKiom1PGni_B52dYAAIXcogI-V4653.jpg"/>
You can see the size change of mylv1:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/3E/3D/wKiom1PGnv6TvuJfAAHNn_Qj6Ms201.jpg "Title =" 12.png" alt = "wkiom1pgnv6tvujfaahnn_qj6ms201.jpg"/>
Re-mount the partition to the/users directory to verify whether the data is available:
# Mount-
# Mount
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/3E/3D/wKioL1PGoMDyQ9zaAAHKiFaE3Pk995.jpg "Title =" 13.png" alt = "wkiol1pgomdyq9zaaahkifae3pk995.jpg"/>
# Su-mageedu
$ Cat fstab
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/3E/3D/wKiom1PGn8nS2S9SAAJvdv9_hFY070.jpg "Title =" 14.png" alt = "wkiom1pgn8ns2s9saajvdv9_hfy070.jpg"/>
Create a snapshot volume snap-mylv1 for the mylv1 volume, first remount mylv1 to read-only mode, avoid other processes modifying data in the volume
# Mount-O remount, RO/dev/myvg/mylv1/users
# Lvcreate-S-N/dev/myvg/snap-mylv1-l 512 M-p r/dev/myvg/mylv1
# Mount-O remount, RW/dev/myvg/mylv1/users
# Mkdir/temp-Backup
# Mount/dev/myvg/snap-mylv1/temp-Backup
# Cp-A/temp-backup/backup
The entire process has ended.