LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-03-2015, 04:33 AM   #1
r0tty
Member
 
Registered: May 2011
Posts: 33

Rep: Reputation: 1
Creating a RHEL7 VM Template/dmsetup


Hi,

I'm creating a RHEL7 VM that I will upload to AWS and convert into an AMI from which I will create instances.

I've found lots of good info online to help with 'anonymizing' the VM, but I am having problems with mapper devices.

If I cat /etc/fstab I see lines like these:

Code:
/dev/mapper/rhel_myhostname-root /                       xfs     defaults        0 0
/dev/mapper/rhel_myhostname-swap swap                    swap    defaults        0 0
I don't want 'myhostname' to appear there. If I look at the output of dmsetup I see this:

Code:
# dmsetup ls
rhel_myhostname-swap	(253:1)
rhel_myhostname-root	(253:0)
I can use 'dmsetup rename' to rename those devices, but not in a persistent way - it always reverts after a reboot.

Where is the original hostname stored that it is coming back in this way? Does this take me into the realm of udev? Is there a simple way to remove this reference to the hostname from devices (I'd be completely happy with 'rhel-swap' and 'rhel-root')?

Thanks in advance for any help,
Rotty

PS, the VM is on Hyper-V.

Last edited by r0tty; 08-03-2015 at 04:38 AM.
 
Old 08-03-2015, 07:43 AM   #2
r0tty
Member
 
Registered: May 2011
Posts: 33

Original Poster
Rep: Reputation: 1
Hi,

I've found a solution to this (or a workaround anyway).

It occurred to me that a better solution would be to install the OS on the VM in such a way that it doesn't put the hostname in device names. While researching that I realised i had made a mistake with my initial build and was using 'autopart' to create the initial LVM config. When I swapped to use 'volgroup' and 'logvol' commands in my build script I was able to use generic device names. I don't know if it is possible to influence the names of devices when using 'autopart'.

While I was stumbling across the above (superior) solution I had come to the realization that my initial question was more specifically 'how can I rename the rootvg?', as the rest just falls into place when that is done. I hadn't found a full solution to that, but in the interests of completeness it would be something similar too this:

Code:
# oldhostname=myhostname
# newhostname=xxx
# vgrename $oldhostname $newhostname
# sed -i "s/$oldhostname/$newhostname/g" /etc/fstab
# sed -i "s/$oldhostname/\/$newhostname/g" /boot/grub/grub.cfg
There may be a requirement to use mkinitrd too, but since I discovered my preferred workaround I needn't investigate further.

Thanks,
Rotty
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to install RHEL7 KVM onto RHEL7 desktop redhatprat Red Hat 10 02-18-2015 03:44 AM
[SOLVED] Upon every boot I must do this: dmsetup ls, dmsetup remove... ezekieldas Linux - Newbie 3 10-02-2013 07:37 PM
Creating a template for new user accounts (like /etc/skel)? Richard Rasker Mandriva 0 07-08-2009 05:32 PM
LXer: Extending OpenOffice.org: Creating template and AutoText extensions LXer Syndicated Linux News 0 05-07-2007 04:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:07 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