lvcreate mount以前删除逻辑卷,cento 7

所以这就是我想要实现的,

  • 在/ home中卸载主分区
  • 删除家庭逻辑卷/ dev / cl / home
  • 从同一个卷组cl中创build新的家庭逻辑卷并将其命名为home
  • 制作xfs文件系统
  • 在/ home上挂载新的逻辑卷。

为此,我写了这个bash脚本

umount -v /home/ if [ $? -ne 0 ] then echo "Couldn't not unmount /home" exit 1 fi # delete lvremove /dev/cl/home if [ $? -ne 0 ] then echo "Couldn't delete LVM /dev/cl/home." exit 1 fi # create home lvcreate -L2G -n home cl if [ $? -ne 0 ] then echo "Couldn't create a new LVM /dev/cl/home." exit 1 fi mkfs.xfs /dev/cl/home if [ $? -ne 0 ] then echo "Couldn't create a file system for /dev/cl/home." exit 1 fi # restore home mount /dev/cl/home /home/ 

该脚本失败在mkfs.xfs / dev / cl / home用msg mkfs.xfs: /dev/cl/home contains a mounted filesystem ,看来lvcreate -L2G -n home cl并不真正创build一个新的逻辑卷它只是检索以前删除的逻辑卷与相同的文件系统,并挂载在同一挂载点/家庭,有什么可能的原因呢?