LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 03-15-2021, 02:07 PM   #1
Danielb630
LQ Newbie
 
Registered: Mar 2021
Posts: 3

Rep: Reputation: Disabled
Script that mount LVM


hey guys, im trying to write a script that gets a .csv file and creates lvm's and mount points , mount the lvm to the mount points and writing into /etc/fstab,
but it seems that the for loop isnt working for me and it prints insted of creating my
variables , can someone give it a look and tell me where are my mistakes?

the .csv file
Code:
ProductsLV, /products
OracleLV, /products/Oracle
PlsqlLV, /products/plsql
my script:
Code:
#!/bin/bash


for i in 'cat list.csv'
do
    lv_name1='echo $i | cut -d, -f1 | sed '1!d''
    lv_name2='echo $i | cut -d, -f1 | sed '2!d''
    lv_name3='echo $i | cut -d, -f1 | sed '3!d''
    mount_point1='echo $i | cut -d, -f2 | cut -c 2- | sed '1!d''
    mount_point2='echo $i | cut -d, -f2 | cut -c 2- | sed '2!d''
    mount_point3='echo $i | cut -d, -f2 | cut -c 2- | sed '3!d''
    vg_name='centos'
        
        lvcreate -L 10m -n $lv_name1 $vg_name
	lvcreate -L 10m -n $lv_name2 $vg_name
	lvcreate -L 10m -n $lv_name3 $vg_name
	
	mkdir -p $mount_point1
	mkdir -p $mount_point2
	mkdir -p $mount_point3
	
	mount -t ext4 /dev/$vg_name/$lv_name1 $mount_point1
	mount -t ext4 /dev/$vg_name/$lv_name2 $mount_point2
	mount -t ext4 /dev/$vg_name/$lv_name3 $mount_point3
	mount -a
	
	echo "/dev/$vg_name/$lv_name1 $mount_point1 ext4 defaults 0 0">>/etc/fstab
	echo "/dev/$vg_name/$lv_name2 $mount_point2 ext4 defaults 0 0">>/etc/fstab
	echo "/dev/$vg_name/$lv_name3 $mount_point3 ext4 defaults 0 0">>/etc/fstab
done
 
Old 03-17-2021, 08:53 AM   #2
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,602

Rep: Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script that mount LVM Danielb630 Linux - Newbie 4 03-16-2021 03:10 AM
mount multiple lvm to single mount point mplike Linux - Software 3 03-02-2010 04:43 AM
Mount. Umount. Mount. Umount. Mount. Umount. Mount.. cwizardone Slackware 10 03-22-2007 09:30 AM
mount refusing to mount lvm volumes linuxmandrake Fedora 2 07-20-2005 06:06 PM
To LVM or not to LVM? illtbagu Linux - Software 3 12-29-2003 04:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration