查看当前系统的卷组创建信息:
[root@templatecentos67 ~]# vgs VG #PV #LV #SN Attr VSize VFree vg_templatecento 1 3 0 wz--n- 59.51g 0
利用vgrname修改系统的卷组名称为”vg_root”:
[root@templatecentos67 ~]# vgrename vg_templatecento vg_root Volume group "vg_templatecento" successfully renamed to "vg_root"
df查看文件系统,已经挂载过的,不会自动显示为最新的。
[root@templatecentos67 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_templatecento-lv_root 45G 1.9G 41G 5% / tmpfs 7.8G 0 7.8G 0% /dev/shm /dev/sda1 477M 41M 411M 10% /boot
查看/etc/fstab的文件系统表文件,这里需要修改一下(下面有修改的步骤)。将/dev/mapper/vg_templatecento-lv_root中的“vg_templatecento”修改为”vg_root”。
[root@templatecentos67 ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Thu Jan 25 11:21:17 2018 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/vg_templatecento-lv_root / ext4 defaults 1 1 UUID=aef217ac-80bb-4d67-9830-439350c0e38e /boot ext4 defaults 1 2 #/dev/mapper/vg_templatecento-lv_home /home ext4 defaults 1 2 /dev/mapper/vg_templatecento-lv_swap swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0
查看/dev/mapper下的卷组名称,已经变更为“vg_root”。
<div id="inner-editor"><br class="Apple-interchange-newline">[root@templatecentos67 ~]# ls -l /dev/mapper total 0 crw-rw---- 1 root root 10, 58 Jan 25 12:10 control lrwxrwxrwx 1 root root 7 Jan 25 15:19 vg_root-lv_home -> ../dm-2 lrwxrwxrwx 1 root root 7 Jan 25 15:19 vg_root-lv_root -> ../dm-0 lrwxrwxrwx 1 root root 7 Jan 25 15:19 vg_root-lv_swap -> ../dm-1</div>
虽然是以vgrename修改了卷组名称,但是由于修改的是系统的根分区坐在的卷组,所以还需要修改的两个地方,否则开机系统就因为找不到系统引导信息而导致无法正常开机。
1)修改系统文件系统表文件 /etc/fstab
## 利用sed来查找替换 [root@templatecentos67 ~]# sed -i 's/vg_templatecento/vg_root/g' /etc/fstab [root@templatecentos67 ~]#cat /etc/fstab # # /etc/fstab # Created by anaconda on Thu Jan 25 11:21:17 2018 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/vg_root-lv_root / ext4 defaults 1 1 UUID=aef217ac-80bb-4d67-9830-439350c0e38e /boot ext4 defaults 1 2 #/dev/mapper/vg_root-lv_home /home ext4 defaults 1 2 /dev/mapper/vg_root-lv_swap swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0
2)修改grub引导配置文件 /boot/grub/grub.conf
[root@templatecentos67 ~]# sed -i 's/vg_templatecento/vg_root/g' /boot/grub/grub.conf [root@templatecentos67 ~]# cat /boot/grub/grub.conf # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/mapper/vg_root-lv_root # initrd /initrd-[generic-]version.img #boot=/dev/sda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS 6 (2.6.32-573.el6.x86_64) root (hd0,0) kernel /vmlinuz-2.6.32-573.el6.x86_64 ro root=/dev/mapper/vg_root-lv_root rd_NO_LUKS.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_DM rd_LVM_LV=vg_root/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg_root/lv_swap rhgb quiet initrd /initramfs-2.6.32-573.el6.x86_64.img
修改完成之后,就用reboot命令重启Linux。
[root@templatecentos67 ~]# reboot