歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> linux下移動磁盤空間

linux下移動磁盤空間

日期:2017/3/1 14:50:23   编辑:關於Linux
linux下移動磁盤空間 目的:將/home下的磁盤空間移動到/下面 操作: 1.查看磁盤空間情況 [root@compute home]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_compute-lv_root 531G 48G 478G 10% / tmpfs 16G 88K 16G 1% /dev/shm /dev/mapper/ddf1_4c5349202020202010000055000000004711471100001450p1 485M 38M 422M 9% /boot 2.卸載/home umount /home/ 3.查看邏輯卷組信息 [root@compute home]# vgs VG #PV #LV #SN Attr VSize VFree vg_compute 1 3 0 wz--n- 556.44g 712.00m 4.檢查磁盤是否正常 e2fsck -f /dev/vg_compute/lv_home 5.縮小/home磁盤大小 resize2fs /dev/vg_compute/lv_home 1024M lvreduce -L 1024M /dev/vg_compute/lv_home 6.擴展/磁盤大小 lvextend -L + 489G /dev/vg_compute/lv_root resize2fs /dev/vg_compute/lv_root 7.掛載/home mount /home 8./home下的用戶文件夾恢復 一、新建用戶文件夾並修改所屬權限 mkdir /home/shome chown shome:shome /home/shome 二、將 /etc/skel 目錄裡所有的文件(隱藏文件) 復制到 用戶的默認目錄裡即可解決問題. cp /etc/skel/.bash* /home/shome/ 在Centos中創建新用戶,但不知道為什麼在用戶的默認目錄文件夾裡沒有產生".bash_profile". 在切換到新用戶的時候,會出現下面的問題,不會出現shell的名字 解決方法: 將 /etc/skel 目錄裡所有的文件(隱藏文件) 復制到 用戶的默認目錄裡即可解決問題. 由於Openstack的Volume需要一塊獨立的分卷,所以我在分區的時候就直接創建了一個Volume作為vg。這裡注意vg的名字一定要為"nova-vloumes",通過vgdisplay可以查看 附錄: 一 pvs,lvs vgs 使用 --1.1 顯示物理卷(pv)信息 [root@redhat6 lvm]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 vg_redhat6 lvm2 a-- 14.51g 0 /dev/sdb vg_redhat6 lvm2 a-- 4.00g 2.81g --1.2 顯示邏輯卷組(vg)信息 [root@redhat6 lvm]# vgs VG #PV #LV #SN Attr VSize VFree vg_redhat6 2 3 0 wz--n- 18.50g 2.81g --1.3顯示邏輯卷(lv)信息 [root@redhat6 lvm]# lvs LV VG Attr LSize Origin Snap% Move Log Copy% Convert lv_pgdata_01 vg_redhat6 -wi-ao 700.00m lv_root vg_redhat6 -wi-ao 13.10g lv_swap vg_redhat6 -wi-ao 1.91g 備注:前面的 pvs,lvs,vgs 命令簡單顯示 LVM 對像信息,都是默認的輸出。 二 格式化控制 --2.1 顯示額外信息 [root@redhat6 lvm]# pvs -v Scanning for physical volume names PV VG Fmt Attr PSize PFree DevSize PV UUID /dev/sda2 vg_redhat6 lvm2 a-- 14.51g 0 14.51g dpTW84-DHRy-PIA9-u1tY-YUH4-XQKw-8Hy2Zm /dev/sdb vg_redhat6 lvm2 a-- 4.00g 2.81g 4.00g YKIQwX-zc6H-TZ65-P3qr-sRfk-LX0p-T18vdG [root@redhat6 lvm]# vgs -v Finding all volume groups Finding volume group "vg_redhat6" VG Attr Ext #PV #LV #SN VSize VFree VG UUID vg_redhat6 wz--n- 4.00m 2 3 0 18.50g 2.81g E6cA2U-TL1x-ScCV-UnGU-3Kq4-1u6V-WUb5L4 備注:增加 -v 參數,會顯示LVM 對像的額外信息,例如 UUID字段。 --2.2 pvs 默認輸出 [root@redhat6 lvm]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 vg_redhat6 lvm2 a-- 14.51g 0 /dev/sdb vg_redhat6 lvm2 a-- 4.00g 2.81g --2.3 只顯示 pv_name,dev_size 字段 [root@redhat6 lvm]# pvs -o pv_name,dev_size PV DevSize /dev/sda2 14.51g /dev/sdb 4.00g 備注:增加 -o 參數,指定需要輸出的字段。 --2.4 在pvs 默認輸出上,增加字段 [root@redhat6 lvm]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 vg_redhat6 lvm2 a-- 14.51g 0 /dev/sdb vg_redhat6 lvm2 a-- 4.00g 2.81g [root@redhat6 lvm]# pvs -o +pv_uuid PV VG Fmt Attr PSize PFree PV UUID /dev/sda2 vg_redhat6 lvm2 a-- 14.51g 0 dpTW84-DHRy-PIA9-u1tY-YUH4-XQKw-8Hy2Zm /dev/sdb vg_redhat6 lvm2 a-- 4.00g 2.81g YKIQwX-zc6H-TZ65-P3qr-sRfk-LX0p-T18vdG 備注:如果想在默認輸出的前提下增加字段,可以使用 -o + 字段名。 --2.5 vgs 顯示卷組成員 [root@redhat6 lvm]# vgs VG #PV #LV #SN Attr VSize VFree vg_redhat6 2 3 0 wz--n- 18.50g 2.81g [root@redhat6 lvm]# vgs -o +lv_name VG #PV #LV #SN Attr VSize VFree LV vg_redhat6 2 3 0 wz--n- 18.50g 2.81g lv_root vg_redhat6 2 3 0 wz--n- 18.50g 2.81g lv_swap vg_redhat6 2 3 0 wz--n- 18.50g 2.81g lv_pgdata_01 三 字段排序 --3.1 根據 lv_size 字段排序 [root@redhat6 lvm]# lvs LV VG Attr LSize Origin Snap% Move Log Copy% Convert lv_pgdata_01 vg_redhat6 -wi-ao 700.00m lv_root vg_redhat6 -wi-ao 13.10g lv_swap vg_redhat6 -wi-ao 1.91g [root@redhat6 lvm]# lvs -O lv_size LV VG Attr LSize Origin Snap% Move Log Copy% Convert lv_pgdata_01 vg_redhat6 -wi-ao 700.00m lv_swap vg_redhat6 -wi-ao 1.91g lv_root vg_redhat6 -wi-ao 13.10g 備注:如果想根據輸出字段排序,可以使用 -O 字段名 選項。 四附 lvs,vgs,pvs 字段 --4.1 lvs 字段 --------------------- lv_all - All fields in this section. lv_uuid - Unique identifier. lv_name - Name. LVs created for internal use are enclosed in brackets. lv_path - Full pathname for LV. lv_attr - Various attributes - see man page. lv_major - Persistent major number or -1 if not persistent. lv_minor - Persistent minor number or -1 if not persistent. lv_read_ahead - Read ahead setting in current units. lv_kernel_major - Currently assigned major number or -1 if LV is not active. lv_kernel_minor - Currently assigned minor number or -1 if LV is not active. lv_kernel_read_ahead - Currently-in-use read ahead setting in current units. lv_size - Size of LV in current units. seg_count - Number of segments in LV. origin - For snapshots, the origin device of this LV. origin_size - For snapshots, the size of the origin device of this LV. snap_percent - For snapshots, the percentage full if LV is active. copy_percent - For mirrors and pvmove, current percentage in-sync. move_pv - For pvmove, Source PV of temporary LV created by pvmove. convert_lv - For lvconvert, Name of temporary LV created by lvconvert. lv_tags - Tags, if any. mirror_log - For mirrors, the LV holding the synchronisation log. modules - Kernel device-mapper modules required for this LV. --4.2 pvs 字段 pv_all - All fields in this section. pe_start - Offset to the start of data on the underlying device. pv_size - Size of PV in current units. pv_free - Total amount of unallocated space in current units. pv_used - Total amount of allocated space in current units. pv_attr - Various attributes - see man page. pv_pe_count - Total number of Physical Extents. pv_pe_alloc_count - Total number of allocated Physical Extents. pv_tags - Tags, if any. pv_mda_count - Number of metadata areas on this device. pv_mda_used_count - Number of metadata areas in use on this device. --4.3 vgs 字段 vg_all - All fields in this section. vg_fmt - Type of metadata. vg_uuid - Unique identifier. vg_name - Name. vg_attr - Various attributes - see man page. vg_size - Total size of VG in current units. vg_free - Total amount of free space in current units. vg_sysid - System ID indicating when and where it was created. vg_extent_size - Size of Physical Extents in current units. vg_extent_count - Total number of Physical Extents. vg_free_count - Total number of unallocated Physical Extents. max_lv - Maximum number of LVs allowed in VG or 0 if unlimited. max_pv - Maximum number of PVs allowed in VG or 0 if unlimited. pv_count - Number of PVs. lv_count - Number of LVs. snap_count - Number of snapshots. vg_seqno - Revision number of internal metadata. Incremented whenever it changes. vg_tags - Tags, if any. vg_mda_count - Number of metadata areas on this VG. vg_mda_used_count - Number of metadata areas in use on this VG. vg_mda_free - Free metadata area space for this VG in current units. vg_mda_size - Size of smallest metadata area for this VG in current units. vg_mda_copies - Target number of in use metadata areas in the VG.
Copyright © Linux教程網 All Rights Reserved