How to create a persistent volume group
Hi,
I have created a volume group using the following instructions truncate --size=50G /tmp/netcoolstorage DEVICE=$(losetup --show -f /tmp/netcoolstorage) mkfs.ext4 $DEVICE vgcreate tivolivg /dev/loop0 Volue group gets created succesfully, but when I reboot the system the volume group gets deleted. Is there any way to make this VG permanent? Thanks, Akanksha |
Your loopback device is not persistent. Rerun losetup after boot (e.g. in rc.local) and your VG will reappear. Also put the loopback file somewhere else than /tmp - /tmp is the opposite of persistent.
By the way, I wonder why you need to make a filesystem on the loopback device, and why the vgcreate works without a pvcreate. |
Truncate chops off the physical volume I guess.
I tried "losetup /dev/loop1" and I got loop: can't get info on device /dev/loop1: No such device or address How to use this? BTW as of now I have my Volume group intact. I have not rebooted my server. How can I make sure that this volume group does not disappear on reboot? Just move the loopback file to some other location will help? Where can I find my loopback file? My device is /dev/loop0 Thanks much for your help. I am new to this. |
Quote:
Quote:
Quote:
For a volume group, you need one (or more) physical volumes. Create them as follows: Code:
pvcreate devicefile Since pvcreate and vgcreate expect disk devices to work on, rather than files, they can't use /tmp/netcoolstorage directly. You have to make a disk device out of /tmp/netcoolstorage, and that can be done using losetup. Code:
DEVICE=$(losetup --show -f /tmp/netcoolstorage) You should now turn this device in a physical volume and create a volume group with it: Code:
pvcreate $DEVICE
To fix #1, recreate the association, perhaps in /etc/rc.local, a shell script that is executed at the end of system initalization on most distros. Add this command: Code:
losetup /dev/loopsomething /tmp/netcoolstorage To fix #2, put /tmp/netcoolstorage somewhere else than /tmp. This was four hours of system administration training in ten minutes. |
Thanks a lot for your help here. This was very helpful. Last few questions on this :)
1) Adding entry in rc.local saves my vg after reboot. But the file systems on this vg gets deleted. How can save my file systems as well? 2) Now that I have installed an entire product on this volume group if I keep a backup of /tmp/netcoolstorage to /opt/netcoolstorage while restoring how can I restore using /opt/netcoolstorage? 3) If I follow the procedure you mentioned on /opt/netcoolstorage will my vg and fs be safe from reboot? Just wanted to understand if issue is with /tmp selection or the truncate procedure. Thanks again for your help. |
Quote:
But what is it that you put in /etc/rc.local? The system won't delete filesystems or logical volumes without you telling it. Quote:
Second, in case you lose the original file, just copy /opt/netcoolstorage back. You can use the cp or dd commands, and probably others. Quote:
And as I said, anything residing on /tmp is up for deletion. Depending on how your system is configured. This is a standard documented here: http://www.pathname.com/fhs/pub/fhs-...TEMPORARYFILES. |
Quote:
SO to save my setup here are the steps I can take , please correct me if I am wrong 1) Copy /tmp/netcoolstorage to /opt/netcoolstorage 2) edit rc.local to save the vg If my system reboots and I lose my filesystem and data 1) Copy /opt/netcoolstorage to /tmp/netcoolstorage 2) May be mount the unmounted file systems again. Thank you! |
Quote:
In most (all?) distros /tmp gets deleted on every reboot. |
Yes I get this point very clearly now. But since installation of product is complete I cannot move now :(
Next time onwards I will definitely not use /tmp I was looking for ways to clean up the mess which I have already done! |
In short I dont want to use /tmp at all.
I used it since I did not know /tmp gets flushed on reboot , else I would have not used it. |
Quote:
Quote:
If your data is lost, it would also mean that /opt/netcoolstorage is broken, so point 1 will be fairly useless, and point 2 will fail. One thing I have failed to ask: Why do you want to put a physical volume on a file? Why not keep the data in a normal subtree of your filesystem, such as /home/akajain/netcoolstorage? |
Hmmm I guess I am losing data because of /tmp
I repeat "I WILL NOT USE /TMP EVER" ! :) |
Quote:
Code:
vgchange -an /dev/tivolivg and copy netcoolstorage to from /tmp to /opt and run Code:
losetup --show -f /opt/netcoolstorage |
I just created a volume again using /opt this time using the following steps
truncate --size=50G /opt/netcoolstorage DEVICE=$(losetup --show -f /opt/netcoolstorage) mkfs.ext4 $DEVICE pvcreate $DEVICE vgcreate tivolivg /dev/loop0 added ""losetup /dev/loop0 /opt/netcoolstorage in /etc/rc.local After reboot - volume group is intact. But the file systems on tivolivg are lost How to add entries in /etc/fstab to make the FS persistent even after system reboot? For eg: One of the mount points I want is /backup on tivolivg volume group I tried adding /dev/mapper/tivolivg-backup /backup ext4 defaults 0 0 to fstab but on reboot I coudn't find the FS mounted. fdisk -l shows Disk /dev/mapper/tivolivg-backup: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 |
Quote:
Quote:
Quote:
Then make filesystems on those logical volumes. The command is mkfs. Then add a line for each new filesystem to fstab. It's easiest to copy an existing line and adapt it. Quote:
Perhaps you didn't even create the logical volume tivolivg-backup. Quote:
Actually I would start from zero. Remove tivolivg. Run losetup. Create the PV Create the VG Create the LVol Make the filesystem Ensure /backup exists Test everything by mounting the LVol and copying a file to it Unmount it again. Test fstab with mount -a If you are convinced that everything works, send me a check (the last point is optional) |
All times are GMT -5. The time now is 12:53 PM. |