Question about lvm file creation


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Question about lvm file creation
# 1  
Old 11-19-2014
Question about lvm file creation

Hi,

I have below code for disk creation

Code:
disk_list=$(ls /dev/sd[b-z])
for disk in $disk_list
do
pvcreate $i
done

So what my understanding is first it is checking the disk under /dev sdb,sdc,sdd,...sdz whether 25 disk are existing

if not then its creating the 25 physical volume.

I tried the below code from my local directory since can't take pvcreate risk

Code:
#!/bin/ksh
disk_list=$(ls /etc/mylocal/ab[a-c])
for i in $disk_list
do
touch  $i
done

I got below error
Code:
ls: cannot access /etc/mylocal/ab[a-c]: No such file or directory

I have not created any file like aba,abb...under my local so if the file not present then it should create all the files right why I am getting an error.

Please correct me if am I wrong

Last edited by stew; 11-19-2014 at 05:57 AM..
# 2  
Old 11-19-2014
Hi,

We will need to see all the script I think, to me it should read more like;

Code:
for disk in `ls /dev/sd[b-z]`
do
pvcreate ${disk}
done

But you might want to put some error checking in place, I think - reading your additional post that you need a more fundamental understanding of things. The second script is failing because the files donot exist.

Regards

Dave
# 3  
Old 11-19-2014
so you mean the first code pvcreation, will not go to for loop until /dev/sd[b-z] exist
# 4  
Old 11-19-2014
Hi,

The script you show seems very strange to me, as if "/dev/sd[b-z]" exist then the physical volumes would normally be there. So the "pvcreate" command seems strange in this context.

It might be more apt if you were to explain in detail what it is that you want to do!

Regards

Dave
# 5  
Old 11-19-2014
Hi stew
Code:
# Generate a list of device names that exist on your machine.
disk_list=$(ls /dev/sd[b-z])
for disk in $disk_list
do
# Avoid pvcreate risk!!
echo pvcreat $disk
done

This will generate a list of device names based on devices present on your machine, and then create the physical volumes if you remove 'echo '. Be sure of what you are doing! You can always remove volumes with pvremove if you mess up but your data on those drives will be gone!
Quote:
So what my understanding is first it is checking the disk under /dev sdb,sdc,sdd,...sdz whether 25 disk are existing
if not then its creating the 25 physical volume.
No. If they DO exist the volumes will be created. pvcreate will fail if the devices are not present.
Code:
#!/bin/ksh
disk_list=$(ls /etc/mylocal/ab[a-c])
...
...

This code is pointless! Why have two identical lists? /etc/mylocal is where the disk names would come from, not where they are going.

Not sure where you got this script, but you shouldn't use it! Be very picky about which drives/partitions you use for an LVM and make sure you don't have important data on them!

Last edited by ongoto; 11-19-2014 at 09:15 PM.. Reason: added caveat
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

LVM mirror creation problem

I apologize is this isn't an appropriate post for the 'advanced' UNIX, so please let me know if I should post this under UNIX for dummies, but here's my problem in a nutshell: I having problems creating a mirrored logical volume. I have created two new physical volumes ... (2 Replies)
Discussion started by: simonrodan
2 Replies

2. UNIX for Dummies Questions & Answers

How to convert non LVM root partition to LVM?

Hi Guys, I m using redhat 6, I have installed root partition as non-LVM . Is there any way i can convert it to LVM? (1 Reply)
Discussion started by: pinga123
1 Replies

3. UNIX for Dummies Questions & Answers

Linux LVM Question

I've three partitions on /dev/sda: sda1, sda2 sda3. There is FREE space between sda2 and sda3 and sda3 ends on the last sector. sda2 and sda3 have the same number of sectors allocated and so are the exact same size. /dev/sda2 is already part of the VG VolGroup. However, what puzzles me is that... (0 Replies)
Discussion started by: Devyn
0 Replies

4. Red Hat

SAN/LVM question

Hey everyone. I am working on designing a logging solution for a deployment we have going out in a few months. Right now we have a single storage head end, connected via fibre to a SAN. Basically the plan is to create a number of smaller LUNs on the SAN, and then use LVM2 to handle concatenating... (5 Replies)
Discussion started by: msarro
5 Replies

5. Red Hat

LVM question

Hi all; I have a quick question about LVM. 2.6.18-92.1.18.el5 Distributor ID: RedHatEnterpriseServer Description: Red Hat Enterprise Linux Server release 5.3 (Tikanga) Release: 5.3 Codename: Tikanga I was going through /etc/lvm.conf and I am not clear with lvm meta... (0 Replies)
Discussion started by: maverick_here
0 Replies

6. HP-UX

How to reduce LVM to create another LVM

Hi, I'm new to HP-UX. I have LVM on /var with 92Gig. I would like to reduce it to create another LVM for Oracle client with 800 meg or so. How to do it. I'm running 11.iv3 Thanks (4 Replies)
Discussion started by: lamoul
4 Replies

7. Filesystems, Disks and Memory

LVM snapshot question

Hi All, I am planning to do a LVM replicate to another server. Example : server1.foo.com has / , /boot , swap and few LVM partitions. All are in /dev/sda disk of size 80GB. /dev/sda5 is a LVM partition which has only one vg00 and it has 2 LV's (/var and /usr) and a SAN storage connected to... (0 Replies)
Discussion started by: rakrhn
0 Replies

8. Linux

LVM snapshot question

Hi All, I am planning to do a LVM replicate to another server. Example : server1.foo.com has / , /boot , swap and few LVM partitions. All are in /dev/sda disk of size 80GB. /dev/sda5 is a LVM partition which has only one vg00 and it has 2 LV's (/var and /usr) and a SAN storage connected to... (0 Replies)
Discussion started by: rakrhn
0 Replies

9. Programming

Question on creation of Thread pool

dear sir/madam presently i am in a process of creating a multithread pool using clone() system call in unix with c programming. i am facing some problem ie., i am able create multithread pool and able to keep all the threads in wait state,but when i call kill (afunction revoke a... (6 Replies)
Discussion started by: Radha
6 Replies

10. Solaris

DiskSuite 4.2.1 Database creation question

I'm trying to figure out how to simply create a 500Gb ufs file system named /rec using DiskSuite 4.2.1 on a Solaris 8 platform via command line using two 250Gb partitions on two different disks. Does anyone know what the proper command string and options are to perform this task? Would I use the... (2 Replies)
Discussion started by: ruger14
2 Replies
Login or Register to Ask a Question