So this is what i want to achieve,
- Unmount home partition at /home
- Remove home logical volume /dev/cl/home
- create new home logical volume from the same volume group cl and name home
- make xfs filesystem
- mount the new logical volume at /home.
for that i wrote this bash script
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/
the script fails at the line mkfs.xfs /dev/cl/home with msg mkfs.xfs: /dev/cl/home contains a mounted filesystem
, it seems lvcreate -L2G -n home cl
doesn't really create a new logical volume it just retrieves the previously removed logical volume with the same filesystem and mount it at the same mounting point /home, what could possible cause this?
0 Answers