LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Resizing Imaged Hard drive (https://www.linuxquestions.org/questions/linux-hardware-18/resizing-imaged-hard-drive-4175666202/)

yelirt5 12-18-2019 07:46 PM

Resizing Imaged Hard drive
 
Thought someone here might be able to advise me if what I'd like to do is even feasible.

Would like to take a Clonezilla image of a Rhel 7.6 Server system built on a 140GB and put that image on a 500GB drive. I'm wondering what tools I can use to take advantage of the HD space gain. The drive is split up into LVMs based on DOD Stig (/, /boot/ home/ /var /var/log, /var/log/audit, /tmp, and /swp.

What I'd like to do is to either create another LVM from the additional space or at least add it to home.

Can someone tell me if this is even possible?

Thanking you in advance....

syg00 12-18-2019 08:01 PM

Piece of cake.
Most people want to restore onto a smaller target - that's a no-no. For you, just restore it and either resize the pv (if just one), or create a new pv and add it to the appropriate vg. Then start resizing your lv(s)/filesystem(s).

yelirt5 12-18-2019 08:03 PM

yes, definitely will have a backup.

Thanks for the response Happy Holidays!

syg00 12-18-2019 08:24 PM

That's just my sigline. Your image is your backup. Do it.

yelirt5 12-19-2019 10:58 AM

Well, tried what was suggested and the system won't boot. So I'm putting the clonezilla image back on the system in order to try again.

Does it matter that the system boots from the new 500GB drive?

syg00 12-19-2019 04:31 PM

Seeing as we cannot know what you did, or didn't, do - and whether it was correct, you'll have to do some basic diagnostics.
Restore the image onto the new disk. Does it boot ?. Does it boot if you remove the old disk ?.
Once you have a boot-able system, proceed in steps and reboot each time. Where does it break ?.

uteck 12-19-2019 05:01 PM

Might be a silly question, but did you image the whole drive, or just the partition?

jefro 12-19-2019 05:16 PM

A few ways to go I'd think.

Either restore to the new drive and expand it all or restore to some other resource and then use a file by file method to move if you can't expand LVM. https://www.linuxtechi.com/extend-lvm-partitions/

Usually you have to use a similar level live media I'd think to access /boot. It could be that your data can be grown.

yelirt5 12-20-2019 07:18 AM

Yes I am imaging the whole drive. I have to, that's the way the image was originally created.

teckk 12-20-2019 11:03 AM

Smaller drive to larger drive.
Ext4, 3 partitions example.

Stick larger drive in machine, clone sda to sdb. Depending on the drive size this could take a while. A 160GB drive takes about 25 min. Also depends on bus speed, drive speed blahblah..
Code:

dd if=/dev/sda of=/dev/sdb bs=1M
New drive. You can move the end of the last partition to the end of the drive.
Code:

(parted) resizepart 3 100%
Then resize the file system to the end of that partition on the new drive.
Code:

resize2fs /dev/sdb3 100%
You can't move the start of the partitions. You can move the last partition on the drive to take the free space of the larger drive.

So if you have sdb1 sdb2 sdb3...you can move the end of sdb3 to the end of the drive, or move it a little and make a sdb4, etc.

fatmac 12-20-2019 01:04 PM

Maybe you could loop mount your imaged file, then create your new disk partitioning, then copy each partitions files to their new partitions(?).

yelirt5 12-20-2019 01:09 PM

I apologize for my confusion. I'm not exactly new to Linux, but definitely new to doing something like this.

This is a system that has only 1 drive in it. Originally that was a 300GB drive although it was loaded from a CLonezilla live CD with an OS originally configured with a 140GB drive. . Now they want to put a 500GB drive in this system, image it with the same Clonezilla image that captured as before, but be able to gain the space. So I've put the 500GB drive in the system and loaded the Clonezilla image. Below are the results of the command "df -h". As you can see it thinks that it's only a 140GB drive (or so).


Mounted on: Size:
/dev/mapper/rhel-root / 15G
devtmpfs /dev 16G
tmpfs /dev/shm 16G
tmpfs /run 16G
tmpfs /sys/fs/cgroup 16G
tmpfs /tmp 9.8G
/dev/sda1 /boot 9.8G
/dev/mapper/rhel-var /var 9.8G
/dev/mapper/rhel-home /home 45G
/dev/mapper/rhel-log /var/log 9.8G
/dev/mapper/rhel-audit /var/log/audit 9.8G
tmpfs /run/user/210 3.2G

Output of command "pvdisplay"

/dev/sda2 (there's more output I'm not sure what's relevant)


If I enter "lvdisplay" it basically lists all the volumes as above: /, /home /swap /tmp /home /var /var/log/ and /var/log/audit

I'm just not sure what the first step is. Last time I tried pvresize, then lvextend. I'm sure I'm omitting steps or something is out of order here.

teckk 12-20-2019 03:36 PM

Were you able to read post 10. I told you exactly how to resize it. Move the end of the last partition to wherever you want it, then extend the file system on it.

What is the output of
Code:

fdisk -l

or

parted -l

If you have sda1 sda2 and sda3, and you want to extend sda2 for example:

1. You'll need to backup sda3,

2. Then delete the partition sda3

3. Move the end of sda2 where you want it

4. Extent the FS on sda2

5. Make a new sda3 out of the free space that is left

6. Put a file system on sda3

7. Put your stuff back on it if it will fit.

Or if you just want to enlarge sda3, that's easy.

1. Move the end of the partition sda3 where you want it

2. Extend the file system on it.

uteck 12-20-2019 07:29 PM

You could get a gparted live image to boot from and use a nice GUI to resize things.
https://gparted.org/index.php

jefro 12-20-2019 08:28 PM

You have an LVM volume or more than one.
"
/dev/mapper/rhel-var /var 9.8G
/dev/mapper/rhel-home /home 45G
/dev/mapper/rhel-log /var/log 9.8G
/dev/mapper/rhel-audit /var/log/audit 9.8G"

Right?

The reference here is that the LVM sits on a drive. /dev/sda1 /boot 9.8G and that you seem to have a dedicated /boot outside of the LVM.

I believe that you could clone to the larger disk. Then expand the LVM using a live media. Leave /boot untouched.


All times are GMT -5. The time now is 10:02 AM.