Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
Last edited by berndbausch; 11-07-2015 at 04:51 AM.
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
I tried "losetup /dev/loop1" and I got
loop: can't get info on device /dev/loop1: No such device or address
Since you didn't create a loopback device with /dev/loop1, this is not really surprising.
Quote:
I am new to this.
Let's start at the beginning then.
For a volume group, you need one (or more) physical volumes. Create them as follows:
Code:
pvcreate devicefile
Usually, devicefile is a partition on a disk or a LUN, something like /dev/sdc1. You, however, have opted to put the physical volume on a disk file /tmp/netcoolstorage.
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)
will take the first free loopback device, associate it with /tmp/netcoolstorage, and assign the name of that loopback device to the shell variable DEVICE.
You should now turn this device in a physical volume and create a volume group with it:
Code:
pvcreate $DEVICE
vgcreate volgroupname $DEVICE
The LVM structures are persistent on /tmp/netcoolstorage. When you reboot, however, you have two problems:
the association between /dev/loopsomething and /tmp/netcoolstorage will be broken
/tmp/netcoolstorage might be deleted - there is no guarantee files on /tmp survive a reboot.
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
Of course, replace loopsomething with the correct device.
To fix #2, put /tmp/netcoolstorage somewhere else than /tmp.
This was four hours of system administration training in ten minutes.
Last edited by berndbausch; 11-07-2015 at 05:46 AM.
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.
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?
Strictly speaking it doesn't save it. If you are talking about losetup, it just recreates the structures that allow the system to find the VG. But perhaps this is splitting hairs.
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:
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?
Well, first of all don't use /tmp for anything that you want to keep.
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:
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.
If you want to use truncate after creating data on /opt/netcoolstorage, I have to say
Why?
If by chance you truncate the file to a smaller size, you will lose the contents
If on the other hand you just want to run truncate once, before creating your VG, no problem.
Strictly speaking it doesn't save it. If you are talking about losetup, it just recreates the structures that allow the system to find the VG. But perhaps this is splitting hairs.
But what is it that you put in /etc/rc.local? The system won't delete filesystems or logical volumes without you telling it.
I have put "losetup /dev/loop0 /tmp/netcoolstorage" in rc.local file. The directory structure of file system is retained but looks like mounting is removed. df -h does not show me any file system which were there before reboot.
Well, first of all don't use /tmp for anything that you want to keep.
Second, in case you lose the original file, just copy /opt/netcoolstorage back. You can use the cp or dd commands, and probably others.
Ok so I can copy /opt/netcoolstorage to /tmp/netcoolstorage and all my data would be retrieved?
If you want to use truncate after creating data on /opt/netcoolstorage, I have to say
Why?
If by chance you truncate the file to a smaller size, you will lose the contents
If on the other hand you just want to run truncate once, before creating your VG, no problem.
Yes I was asking about truncate before creating vg.
Yes I get this very clearly now. So instead of /tmp/netcoolstorage I should have used /opt/netcoolstorage.
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.
Yes I get this very clearly now. So instead of /tmp/netcoolstorage I should have used /opt/netcoolstorage.
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!
Why do you stubbornly want to use /tmp? Just setup everything in /opt or wherever you like, but NOT IN /TMP!!!
In most (all?) distros /tmp gets deleted on every reboot.
Yes I get this very clearly now. So instead of /tmp/netcoolstorage I should have used /opt/netcoolstorage.
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
By point 2 you mean adding a losetup command to rc.local, right?
Quote:
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.
I still don't know how you can lose your data. If you really do, investigate how it happens. I continue to believe that you lost your data because you kept it on /tmp. Repeat after me: Don't put data on /tmp that you want to keep. Or you didn't really lose it, instead the losetup wasn't executed after the reboot.
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?
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!
As far as I can see you only created a volume group without a logical volume. Then you just deactivate the volume group and delete the loopback device with
Code:
vgchange -an /dev/tivolivg
losetup -d /dev/loop0
Edit: Reading your previous posts again you will need to stop all services which access this logical volume and unmount it before running the above commands.
and copy netcoolstorage to from /tmp to /opt and run
Code:
losetup --show -f /opt/netcoolstorage
Finally adjust the commands in rc.local to reflect the new path.
This filesystem will be overwritten by the pvcreate command.
Quote:
Originally Posted by akajain
vgcreate tivolivg /dev/loop0
This is only possible if there was no tivolivg. If tivolivg existed before this command, the command must fail. If it didn't fail, tivolivg didn't exist.
Quote:
Originally Posted by akajain
How to add entries in /etc/fstab to make the FS persistent even after system reboot?
First, you must create logical volumes in tivolivg. The command is lvcreate.
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:
Originally Posted by akajain
I tried adding
/dev/mapper/tivolivg-backup /backup ext4 defaults 0 0
to fstab but on reboot I coudn't find the FS mounted.
You didn't make a filesystem on tivolivg-backup.
Perhaps you didn't even create the logical volume tivolivg-backup.
Well it looks like you created the logical volume. But is there a filesystem on it? If not, run mkfs /dev/mapper/tivolivg-backup.
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)
Last edited by berndbausch; 11-17-2015 at 03:21 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.