[LVM]LV rename

回覆文章
schumi
Site Admin
文章: 696
註冊時間: 2004-04-15 14:30:34

[LVM]LV rename

文章 schumi »

http://www.tcpdump.com/kb/os/linux/lvm-renaming.html

Renaming a logical volume is a three step process:

Rename the LV
Remount the file system
Update /etc/fstab

Begin by listing all the logical volumes on the system

代碼: 選擇全部

[root@Linux01 ~]# lvs
LV	VG	Attr	LSize	Origin	Snap%	Move	Log	Copy%	Convert
DataLV	TCPDumpVolGRP	-wi-ao	2.00G				

LogVol00	VolGroup00	-wi-ao	1.00G				
LogVol01	VolGroup00	-wi-ao	1.94G				
LogVol02	VolGroup00	-wi-ao	1.00G				

LogVol03	VolGroup00	-wi-ao	2.00G				
LogVol04	VolGroup00	-wi-ao	3.94G				
[root@Linux01 ~]#
Let's find out where DataLV is mounted

代碼: 選擇全部

[root@Linux01 ~]# df -kh
Filesystem
Size
Used	Avail	Use%	Mounted on
/dev/mapper/VolGroup00-LogVol04
3.9G	2.2G	1.6G	59%	/
/dev/sda1
99M
12M	82M	13%	/boot
tmpfs
1006M
0	1006M	0%	/dev/shm
/dev/mapper/VolGroup00-LogVol00	992M	41M	901M	5%	/home
/dev/mapper/VolGroup00-LogVol02	992M	69M	872M	8%	/tmp
/dev/mapper/VolGroup00-LogVol03
2.0G
150M	1.7G	8%	/var
/dev/mapper/TCPDumpVolGRP-DataLV
2.0G
568M	1.4G	30%	/Data Note: The DataLV is mounted on /Data
Rename DataLV to TCPDumpLV

代碼: 選擇全部

[root@Linux01 /]# lvrename TCPDumpVolGRP DataLV TCPDumpLV
Renamed "DataLV" to "TCPDumpLV" in volume group "TCPDumpVolGRP"
[root@Linux01 /]# 
Verify the logical volume has been renamed

代碼: 選擇全部

[root@Linux01 ~]# lvs
LV	VG	Attr	LSize	Origin	Snap%	Move	Log	Copy%	Convert
TCPDumpLV	TCPDumpVolGRP	-wi-ao	2.00G				

LogVol00	VolGroup00	-wi-ao	1.00G				
LogVol01	VolGroup00	-wi-ao	1.94G				
LogVol02	VolGroup00	-wi-ao	1.00G				

LogVol03	VolGroup00	-wi-ao	2.00G				
LogVol04	VolGroup00	-wi-ao	3.94G				
[root@Linux01 ~]#
Notice the user space has yet to be updated, this is because the file system must be remounted

代碼: 選擇全部

[root@Linux01 ~]# df -kh
Filesystem
Size
Used	Avail	Use%	Mounted on
/dev/mapper/VolGroup00-LogVol04
3.9G	2.2G	1.6G	59%	/
/dev/sda1
99M
12M	82M	13%	/boot
tmpfs
1006M
0	1006M	0%	/dev/shm
/dev/mapper/VolGroup00-LogVol00	992M	41M	901M	5%	/home
/dev/mapper/VolGroup00-LogVol02	992M	69M	872M	8%	/tmp
/dev/mapper/VolGroup00-LogVol03
2.0G
150M	1.7G	8%	/var
/dev/mapper/TCPDumpVolGRP-DataLV
2.0G
568M	1.4G	30%	/Data
Remount the file system to update the user space

代碼: 選擇全部

[root@Linux01 /]# umount /dev/mapper/TCPDumpVolGRP-DataLV
[root@Linux01 /]# mount /dev/TCPDumpVolGRP/TCPDumpLV /Data/
[root@Linux01 /]# 
Verify the file system has been mounted

代碼: 選擇全部

[root@Linux01 ~]# df -kh
Filesystem
Size
Used	Avail	Use%	Mounted on
/dev/mapper/VolGroup00-LogVol04
3.9G	2.2G	1.6G	59%	/
/dev/sda1
99M
12M	82M	13%	/boot
tmpfs
1006M
0	1006M	0%	/dev/shm
/dev/mapper/VolGroup00-LogVol00	992M	41M	901M	5%	/home
/dev/mapper/VolGroup00-LogVol02	992M	69M	872M	8%	/tmp
/dev/mapper/VolGroup00-LogVol03
2.0G
150M	1.7G	8%	/var
/dev/mapper/TCPDumpVolGRP-TCPDumpLV
2.0G
568M	1.4G	30%	/Data
Update /etc/fstab to reflect the new name of the file system

代碼: 選擇全部

/dev/mapper/TCPDumpVolGRP-DataLV	/Data
ext3	defaults	0	0
/dev/mapper/TCPDumpVolGRP-TCPDumpLV	/Data
ext3	defaults	0	0


Nice work, you now know how to rename a logical volume!
回覆文章

回到「Linux」