LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 02-04-2014, 02:35 PM   #1
pointer2null
Member
 
Registered: Mar 2012
Location: Bristol, UK
Distribution: CentOS, Debian
Posts: 32

Rep: Reputation: Disabled
Adding centos to fedora install as dual boot - lvm problems


I have a fedora installation that I've been using as a home server (I know - fedora was the *wrong* choice as a server as it changes to much; but it was a learning curve and served it's purpose). Now I want to upgrade to CentOS. I'm going to want to run them both initially as it will take me a while to get the new OS all set up with all the right s bits and pieces I want on it (get_iplayer, serviio, Pydio, Apache, ABCDE etc etc).

I've got a live USB and can boot from that, the problem comes when I select the "Reduce existing FS" option. It only shows me the boot partition and whatever I select simply says not enough space. The HDD is 250GB so I know it should be possible.

So on the current Fedora install:
Code:
[root@GDServer gary]# mount
/dev/mapper/vg_gdserver-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
/dev/mapper/vg_gdserver-lv_home on /home type ext4 (rw)
/dev/sdb on /audiovideo type ext4 (rw)
/dev/sdc on /data type ext4 (rw)
/dev/sdd on /backup type ext4 (rw)
Code:
[root@GDServer gary]# fdisk -l

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 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: 0x0005104a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   488396799   243685376   8e  Linux LVM

Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 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/sdc doesn't contain a valid partition table

Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdd: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 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/sdd doesn't contain a valid partition table

Disk /dev/dm-0: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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: 0x00000000

Disk /dev/dm-0 doesn't contain a valid partition table

Disk /dev/dm-1: 6174 MB, 6174015488 bytes
255 heads, 63 sectors/track, 750 cylinders, total 12058624 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/dm-1 doesn't contain a valid partition table

Disk /dev/dm-2: 189.6 GB, 189649649664 bytes
255 heads, 63 sectors/track, 23056 cylinders, total 370409472 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/dm-2 doesn't contain a valid partition table
sda is the OS
sdb, c and d are the NAS drives.

So, basically the question is a) am I doing something wrong? and b) if not, how do I shrink the fedora install so I can put the Centos on the same disk (sda) as a dual boot?
 
Old 02-05-2014, 08:46 AM   #2
pointer2null
Member
 
Registered: Mar 2012
Location: Bristol, UK
Distribution: CentOS, Debian
Posts: 32

Original Poster
Rep: Reputation: Disabled
I've spent the day playing around and still no luck.

I've reduced the the underlying fs size and shrunk the logical volume, but nothing seems to make the volume group reduce in size.

The basic sequence of commands I've used is: (this is run on a test setup using a VM with fedora 20 installed on a 250G hard drive)

Quote:
vgchange -a y

e2fsck -f /dev/fedora/home

resize2fs /dev/fedora/home 90G # make about 90% of the final partition size

lvreduce -L 100G /dev/fedora/home

resize2fs /dev/fedora/home
So now the lv is smaller (started at about 200G), but the volume group is still using the whole partition

Quote:
lvm> pvscan
PV /dev/sda2 VG fedora lvm2 [249.51 GiB / 91.62 GiB free]
Total: 1 [249.51 GiB] / in use: 1 [249.51 GiB] / in no VG: 0 [0 ]
lvm> lvdisplay
--- Logical volume ---
LV Path /dev/fedora/swap
LV Name swap
VG Name fedora
LV UUID ZrFE3x-Yj7J-JN6e-9ZPM-53Lt-Fesr-sz0Be9
LV Write Access read/write
LV Creation host, time localhost, 2014-02-05 06:41:17 -0500
LV Status NOT available
LV Size 7.89 GiB
Current LE 2020
Segments 1
Allocation inherit
Read ahead sectors auto

--- Logical volume ---
LV Path /dev/fedora/home
LV Name home
VG Name fedora
LV UUID dtwDMp-Hcy7-4IbD-ozf3-RCoF-0uC1-QusTP9
LV Write Access read/write
LV Creation host, time localhost, 2014-02-05 06:41:17 -0500
LV Status NOT available
LV Size 100.00 GiB
Current LE 25600
Segments 1
Allocation inherit
Read ahead sectors auto

--- Logical volume ---
LV Path /dev/fedora/root
LV Name root
VG Name fedora
LV UUID 8gtd26-E5uo-qTFx-nfCj-yGBJ-hwlS-v8JpKa
LV Write Access read/write
LV Creation host, time localhost, 2014-02-05 06:41:19 -0500
LV Status NOT available
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
When I try and install Centos, if I select shrink existing or use free space I get the same error:
Quote:
Could not allocate requested partitions: not enough free space on disks.
I've been Googling this all day but all I get are copycat "howto's" which I've already tried.
 
Old 02-05-2014, 09:44 AM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
You need to use "pvresize --setphysicalvolumesize ..." to shrink LVM's view of the physical volume and then shrink the partition with fdisk. After each step it is advisable to check that everything is still intact and that you haven't inadvertently clipped the end off of something (though pvresize does check that you are not doing that).
 
Old 02-06-2014, 05:21 AM   #4
pointer2null
Member
 
Registered: Mar 2012
Location: Bristol, UK
Distribution: CentOS, Debian
Posts: 32

Original Poster
Rep: Reputation: Disabled
failed. aborted.

The story continues with....

Quote:
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
home fedora -wi------- 100.00g
root fedora -wi------- 50.00g
swap fedora -wi------- 7.89g
[root@livecd centoslive]# pv
pvchange pvck pvcreate pvdisplay pvmove pvremove pvresize pvs pvscan pv.sh
[root@livecd centoslive]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name fedora
PV Size 249.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 63874
Free PE 23454
Allocated PE 40420
PV UUID 6i3tGr-GNcW-eD8c-JtOd-v6e8-rZFQ-MwtYyi

[root@livecd centoslive]# pvresize --setphysicalvolumesize 160G /dev/sda2
/dev/sda2: cannot resize to 40959 extents as later ones are allocated.
0 physical volume(s) resized / 1 physical volume(s) not resized



[root@livecd centoslive]# lvdisplay
--- Logical volume ---
LV Path /dev/fedora/swap
LV Name swap
VG Name fedora
LV UUID ZrFE3x-Yj7J-JN6e-9ZPM-53Lt-Fesr-sz0Be9
LV Write Access read/write
LV Creation host, time localhost, 2014-02-05 06:41:17 -0500
LV Status NOT available
LV Size 7.89 GiB
Current LE 2020
Segments 1
Allocation inherit
Read ahead sectors auto

--- Logical volume ---
LV Path /dev/fedora/home
LV Name home
VG Name fedora
LV UUID dtwDMp-Hcy7-4IbD-ozf3-RCoF-0uC1-QusTP9
LV Write Access read/write
LV Creation host, time localhost, 2014-02-05 06:41:17 -0500
LV Status NOT available
LV Size 100.00 GiB
Current LE 25600
Segments 1
Allocation inherit
Read ahead sectors auto

--- Logical volume ---
LV Path /dev/fedora/root
LV Name root
VG Name fedora
LV UUID 8gtd26-E5uo-qTFx-nfCj-yGBJ-hwlS-v8JpKa
LV Write Access read/write
LV Creation host, time localhost, 2014-02-05 06:41:19 -0500
LV Status NOT available
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto

[root@livecd centoslive]# pvdisplay --maps
--- Physical volume ---
PV Name /dev/sda2
VG Name fedora
PV Size 249.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 63874
Free PE 23454
Allocated PE 40420
PV UUID 6i3tGr-GNcW-eD8c-JtOd-v6e8-rZFQ-MwtYyi

--- Physical Segments ---
Physical extent 0 to 2019:
Logical volume /dev/fedora/swap
Logical extents 0 to 2019
Physical extent 2020 to 27619:
Logical volume /dev/fedora/home
Logical extents 0 to 25599
Physical extent 27620 to 51073:
FREE
Physical extent 51074 to 63873:
Logical volume /dev/fedora/root
Logical extents 0 to 12799

[root@livecd centoslive]# pvmove --alloc anywhere /dev/sda2:51074-63873 /dev/sda2:27626-40426
/dev/sda2: Moved: 0.0%
/dev/sda2: Moved: 1.5%
/dev/sda2: Moved: 2.7%
/dev/sda2: Moved: 3.9%


/dev/sda2: Moved: 98.8%
/dev/sda2: Moved: 100.0%
/dev/sda2: Moved: 100.0%
[root@livecd centoslive]#

[root@livecd centoslive]# pvdisplay --maps
--- Physical volume ---
PV Name /dev/sda2
VG Name fedora
PV Size 249.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 63874
Free PE 23454
Allocated PE 40420
PV UUID 6i3tGr-GNcW-eD8c-JtOd-v6e8-rZFQ-MwtYyi

--- Physical Segments ---
Physical extent 0 to 2019:
Logical volume /dev/fedora/swap
Logical extents 0 to 2019
Physical extent 2020 to 27619:
Logical volume /dev/fedora/home
Logical extents 0 to 25599
Physical extent 27620 to 27625:
FREE
Physical extent 27626 to 40425:
Logical volume /dev/fedora/root
Logical extents 0 to 12799
Physical extent 40426 to 63873:
FREE

[root@livecd centoslive]# pvresize --setphysicalvolumesize 160G /dev/sda2
Physical volume "/dev/sda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
<reboot to fedora and all seems ok, boot back to centos>

Quote:

[root@livecd centoslive]# vgchange -ay
3 logical volume(s) in volume group "fedora" now active
[root@livecd centoslive]# e2fsck -f /dev/fedora/home
e2fsck 1.41.12 (17-May-2010)
/dev/fedora/home: recovering journal
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/fedora/home: ***** FILE SYSTEM WAS MODIFIED *****
/dev/fedora/home: 154/6553600 files (1.9% non-contiguous), 460126/26214400 blocks

[root@livecd centoslive]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name fedora
PV Size 160.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 40959
Free PE 539
Allocated PE 40420
PV UUID 6i3tGr-GNcW-eD8c-JtOd-v6e8-rZFQ-MwtYyi


[root@livecd centoslive]# vgdisplay
--- Volume group ---
VG Name fedora
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 9
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 160.00 GiB
PE Size 4.00 MiB
Total PE 40959
Alloc PE / Size 40420 / 157.89 GiB
Free PE / Size 539 / 2.11 GiB
VG UUID j8qNwE-wyU0-YVV2-H0fE-zbJz-XuUx-heS9tb


(parted) print /dev/sda
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 268GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 1049kB 525MB 524MB primary ext4 boot
2 525MB 268GB 268GB primary lvm

(parted) resize 2 525MB 170GB
WARNING: you are attempting to use parted to operate on (resize) a file system.
parted's file system manipulation code is not as robust as what you'll find in
dedicated, file-system-specific packages like e2fsprogs. We recommend
you use parted only to manipulate partition tables, whenever possible.
Support for performing most operations on most types of file systems
will be removed in an upcoming release.
Error: Could not detect file system.

So another brick wall. It seems that although I have reduced the size of the logical volumes and the volume group I still cannot resize the partition.

So as far as actually trying this on my real server.... uh, no thanks lol. I simply have to swap disks until the new one is up and running.
 
Old 02-06-2014, 11:44 AM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
parted is simply the wrong tool. For a partition containing (just) a filesystem, it is clever enough to resize the filesystem along with the partition. Note that typing "help resize" from within parted will tell you this, and also tell you what types it can handle. Faced with a partition with content it does not understand, like an LVM PV or even an empty (all zero) partition, it refuses to do anything.

Just use fdisk to delete the partition and re-create it with the proper size.
 
Old 02-06-2014, 11:57 AM   #6
pointer2null
Member
 
Registered: Mar 2012
Location: Bristol, UK
Distribution: CentOS, Debian
Posts: 32

Original Poster
Rep: Reputation: Disabled
I'm confused - I can't delete the partition as it still has the volume group on, hence trying to shrink the volume group to make space to resize the partition (to make space to install the second OS)
 
  


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
Problems with creating LVM in dual boot (CentOS/Win7) system jeff_schaffzin Linux - Newbie 4 07-28-2011 04:48 PM
Centos / Fedora won't boot: kernel panic due to LVM messed up!!! please help!!!!! smileamiledr Linux - Server 23 01-21-2010 09:53 AM
Trying to dual boot Vista Ultimate/Fedora 6.0--Install Problems SlashAxlX Fedora - Installation 1 03-22-2007 01:38 PM
Fedora 5 install problems with dual boot configuration austinringding Fedora 3 10-07-2006 04:50 AM
Slack/Fedora dual-boot using LVM Phaete Fedora 3 04-14-2005 04:13 PM

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

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