[virt-tools-list] How to remove a virtual swap disk in a guest image?

Peng Yu pengyu.ut at gmail.com
Mon May 12 00:02:04 UTC 2014


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.

pengy at 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 at 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 at 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 at saiph:~$ swapon -s
Filename                Type        Size    Used    Priority
/dev/vdb1                               partition    268435420    0    -1
pengy at 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 at 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




More information about the virt-tools-list mailing list