Re: How to remove a virtual swap disk in a guest image?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 11, 2014 at 07:02:04PM -0500, Peng Yu wrote:
Hi,

The following blocks are from a guest. I have the block
mintaka--vg-swap_1 which I want to remove (it was created when the
guest was first made). Then I want the freed space be allocated to
mintaka--vg-root (so that it will be expanded to 7.7GB). Does anybody
know what I should do? (I know that this is not related to the usage
of virsh, but I'm not sure where I should ask this question as I don't
quite understand how /dev/mapper works) Thanks.


So, from what I see below, you managed to do a swapoff on the swap_1
and you want to just remove it and use the space for root, right?

I'm assuming it's in a virtual machine, but it shouldn't really
matter.  To understand what happens here and "how /dev/mapper works",
see some tutorial on logical volumes, etc.

you can remove the LV (swap_1) from the VG (mintaka-vg) using
'lvremove', then lvresize the root LV (root_1) and of course, resize
the filesystem underneath (/) as well.  For virtual machines, you can
use virt-resize from libguestfs as well, which makes it even easier,
I'd say.

However, I'm not writing all the commands here since I don't remember
perfectly what's the synopsys and whether there were any caveats, nor
am I that familiar with virt-resize (and its friends), however
"resizing an lv" is more than enough to google if you need more
guidance than this mail (and appropriate man pages).

Hope that helps,
Martin

pengy@saiph:~$ lsblk
NAME                          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sr0                            11:0    1  1024M  0 rom
vda                           253:0    0    50G  0 disk
├─vda1                        253:1    0   243M  0 part /boot
├─vda2                        253:2    0     1K  0 part
└─vda5                        253:5    0   7.8G  0 part
 ├─mintaka--vg-root (dm-0)   252:0    0   3.7G  0 lvm  /
 └─mintaka--vg-swap_1 (dm-1) 252:1    0     4G  0 lvm
vdb                           253:16   0   256G  0 disk
└─vdb1                        253:17   0   256G  0 part [SWAP]
pengy@saiph:~$ ll /dev/mapper/mintaka--vg-swap_1
lrwxrwxrwx 1 root root 7 May 11 18:53 /dev/mapper/mintaka--vg-swap_1 -> ../dm-1
pengy@saiph:~$ df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/mintaka--vg-root  3.7G  3.4G   78M  98% /
none                          4.0K     0  4.0K   0% /sys/fs/cgroup
udev                          106G   12K  106G   1% /dev
tmpfs                          22G  392K   22G   1% /run
none                          5.0M     0  5.0M   0% /run/lock
none                          106G     0  106G   0% /run/shm
none                          100M     0  100M   0% /run/user
/dev/vda1                     236M   88M  136M  40% /boot
pengy@saiph:~$ swapon -s
Filename                Type        Size    Used    Priority
/dev/vdb1                               partition    268435420    0    -1
pengy@saiph:~$ blkid
/dev/vda1: UUID="df99ebcd-2dcf-4703-ae7c-0e5ec48cc4ca" TYPE="ext2"
/dev/vda5: UUID="Uz8Imz-aADL-420e-CWo1-sdrS-Zufj-1UFF5u" TYPE="LVM2_member"
/dev/vdb1: UUID="730e895a-d3ad-4911-993f-dae39a190271" TYPE="swap"
/dev/mapper/mintaka--vg-root:
UUID="4bc04e08-add6-4f92-868f-81dce4560adc" TYPE="ext4"
/dev/mapper/mintaka--vg-swap_1:
UUID="302daede-eb31-4db5-ad17-6d048931e86e" TYPE="swap"
pengy@saiph:~$ sudo fdisk -l

Disk /dev/vda: 53.7 GB, 53687091200 bytes
16 heads, 63 sectors/track, 104025 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008a759

  Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048      499711      248832   83  Linux
/dev/vda2          501758    16775167     8136705    5  Extended
/dev/vda5          501760    16775167     8136704   8e  Linux LVM

Disk /dev/vdb: 274.9 GB, 274877906944 bytes
16 heads, 63 sectors/track, 532610 cylinders, total 536870912 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

  Device Boot      Start         End      Blocks   Id  System
/dev/vdb1              63   536870911   268435424+  83  Linux

Disk /dev/mapper/mintaka--vg-root: 4005 MB, 4005560320 bytes
255 heads, 63 sectors/track, 486 cylinders, total 7823360 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/mintaka--vg-root doesn't contain a valid partition table

Disk /dev/mapper/mintaka--vg-swap_1: 4290 MB, 4290772992 bytes
255 heads, 63 sectors/track, 521 cylinders, total 8380416 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/mintaka--vg-swap_1 doesn't contain a valid partition table


--
Regards,
Peng

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list

Attachment: signature.asc
Description: Digital signature

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list

[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux