LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 08-05-2005, 07:53 PM   #1
guideweb
Member
 
Registered: Mar 2004
Location: /planet/earth
Posts: 110

Rep: Reputation: 15
How to move linux to the beginning of a disk


Hi,

My problem is very simple and i hope the solution is also

My current linux partition is close to be full (900Mb free) and i want to move it to the beginning of my hda disk.
/dev/hda3 => /dev/hda1

What do i have to modify in my grub.conf and fstab to be able to boot in the new partition ?


Thanks.

Info on my system :
[root@sam ~]# uname -a
Code:
Linux sam.secretdomain.com 2.6.9-1.667 #1 Tue Nov 2 14:41:25 EST 2004 i686 athlon i386 GNU/Linux
[root@sam ~]# fdisk -l
Code:
 
Disk /dev/hda: 40.0 GB, 40025947648 bytes
255 heads, 63 sectors/track, 4866 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        3569    28667961    7  HPFS/NTFS     #  Current Windows XP
/dev/hda2            3570        3582      104422+  83  Linux
/dev/hda3            3583        4866    10313730   8e  Linux LVM     #Current linux

Disk /dev/sda: 300.0 GB, 300090728448 bytes
255 heads, 63 sectors/track, 36483 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           2       36483   293041665    f  W95 Ext'd (LBA)
/dev/sda5               2        2551    20482843+   b  W95 FAT32
/dev/sda6            2552        3188     5116671    7  HPFS/NTFS
/dev/sda7            3189        4080     7164958+   b  W95 FAT32
/dev/sda8            4081        5865    14337981    b  W95 FAT32
/dev/sda9            5866        7140    10241406    7  HPFS/NTFS
/dev/sda10           7141        8415    10241406    7  HPFS/NTFS
/dev/sda11           8416       11000    20763981   83  Linux
/dev/sda12          11001       12275    10241406    7  HPFS/NTFS
/dev/sda13          12276       12884     4891761   83  Linux
/dev/sda14          12885       14709    14659281   83  Linux
[root@sam ~]# mount
Code:
 /dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/hda2 on /boot type ext3 (rw)
none on /dev/shm type tmpfs (rw)
/dev/sda5 on /mnt/datadisk type vfat (rw,uid=501,gid=501,fmask=000,dmask=000)
/dev/sda8 on /mnt/music type vfat (rw,uid=501,gid=501,fmask=000,dmask=000)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
[root@sam ~]# cat /boot/grub/grub.conf
Code:
default=1
timeout=6
splashimage=(hd0,1)/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.12-1.1372_FC3)
        root (hd0,1)
        kernel /vmlinuz-2.6.12-1.1372_FC3 ro root=/dev/VolGroup00/LogVol00
        initrd /initrd-2.6.12-1.1372_FC3.img
title Fedora Core (2.6.9-1.667)
        root (hd0,1)
        kernel /vmlinuz-2.6.9-1.667 ro root=/dev/VolGroup00/LogVol00
        initrd /initrd-2.6.9-1.667.img
title Windoze XP
        rootnoverify (hd0,0)
        chainloader +1

Last edited by guideweb; 08-05-2005 at 07:54 PM.
 
Old 08-06-2005, 12:35 AM   #2
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151

Rep: Reputation: 46
If you “move” the partition, probably nothing needs to be changed (except to delete the “windoze” section, which will be gone), since you are using an LVM.

You will need to delete the “old” partition before starting it from the new location, since having duplicate volume groups and logical volumes with the same names will create major problems.


But how do you plan to “move” the partition? And after you “move” it, how do you plan to enlarge the size? Keep in mind that pvresize is not currently a supported lvm function.


As a simple, but somewhat inelegant alternative, you could always just convert the first partition to a physical volume and add it to the existing volume group.
 
Old 08-06-2005, 12:42 AM   #3
guideweb
Member
 
Registered: Mar 2004
Location: /planet/earth
Posts: 110

Original Poster
Rep: Reputation: 15
What i was planing to do is to copy linux (with cp -a) from the current location to a new partition at the begining of the disk.
My new linux will have 25Gb and my windoze 15 gb.

Thanks
 
Old 08-06-2005, 01:08 AM   #4
ciotog
Member
 
Registered: Mar 2004
Location: Canada
Distribution: Slackware current
Posts: 728
Blog Entries: 2

Rep: Reputation: 43
The parted utility makes it easy to move partitions around, provided you have the free space:
http://www.gnu.org/software/parted/
 
Old 08-06-2005, 07:33 AM   #5
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151

Rep: Reputation: 46
If you create a new partition and cp over the old contents, then you will need to modify grub.conf and fstab to point to the new partition/filesystem. Do you plan to create an LVM in the new partition or do you plan to avoid using LVMs and format the new partition as ext3?

Also, look into using “rsync -a” instead of “cp -a”. For a large transfer, rsync will run faster then cp.
 
Old 08-06-2005, 04:24 PM   #6
guideweb
Member
 
Registered: Mar 2004
Location: /planet/earth
Posts: 110

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by WhatsHisName
[B]If you create a new partition and cp over the old contents, then you will need to modify grub.conf and fstab to point to the new partition/filesystem.
So i need to add in /boot/grub/grub.conf
Code:
 title Fedora Core (2.6.9-1.667) COPY 
        root (hd0,1)
        kernel /vmlinuz-2.6.9-1.667 ro root=/dev/hda1
        initrd /initrd-2.6.9-1.667.img

and in my /etc/fstab :
i need to change
Code:
 /dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
TO
Code:
 /dev/hda1 /                       ext3    defaults        1 1

Quote:
Do you plan to create an LVM in the new partition or do you plan to avoid using LVMs and format the new partition as ext3?
Should I ? If i dont use LVM i am limited to 4 partitions on my HD, exact ?



Thanks
 
Old 08-06-2005, 09:08 PM   #7
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151

Rep: Reputation: 46
If the new partition is hda1 and you directly format it as ext3 (i.e., mke2fs -j /dev/hda1) without using LVMs, your changes in fstab and grub.conf look correct.

Remember, since you will probably be deleting a partition and creating a new partition, just because the partition is the first one on the drive, doesn’t mean that it will be hda1. In your case, it could be hda4. Also, don’t be surprised if you need to “reinstall” grub after making the changes, which is easy to do.


You are always limited to a maximum of either 4 primary partitions or 3 primary plus 1 extended partition. The extended partition can contain as many logical partitions as you need and a logical partition will function in linux as well as a primary partition. If a partition gets deleted by accident, it is usually a lot easier to redetect a primary partition than it is to redetect a logical partition.

LVMs are extremely useful, but if they make you uncomfortable, then avoid using them. There is a really good HowTo for LVMs here http://www.ibiblio.org/pub/Linux/doc...LVM-HOWTO.html

Be sure to read chapter 11 “Common Tasks”.

Note that you will not be able to easily resize the new ext3 formatted partition, or at least, how it is done makes most people really uncomfortable. Sorry, parted can’t do it with ext3's or with an ext3 converted to an ext2 (“unsupported feature”).

If you want to make at least one new logical volume in the new partition, here is what you will need to do from the terminal:

First, create the new partition using fdisk (or its equivalent) and change the partition type to “linux lvm” using the “t” command (linux lvm = 8e). Otherwise, you will get warning messages every time you boot.

Then:

pvcreate /dev/hda1
vgcreate -s32M VG01 /dev/hda1
lvcreate -L15G -nLV00 VG01

That will give you a 15GB logical volume named /dev/VG01/LV00. You can later increase the size of the logical volume by say 5GB increments by:

lvresize -L+5G /dev/VG01/LV00
resize2fs /dev/VG01/LV00

which increases the logical volume by 5GB and then resizes the ext3 filesystem to fill the new space.

As always, the man pages are your friend.

man pvcreate
man vgcreate
man lvcreate
man lvresize
man resize2fs
 
Old 08-11-2005, 03:38 AM   #8
guideweb
Member
 
Registered: Mar 2004
Location: /planet/earth
Posts: 110

Original Poster
Rep: Reputation: 15
thanks for your post WhatsHisName,


As i exepted it didint work but i can boot on the 'old' partition. I have created a new partition over my WinXP and i copy data from my hda3 to hda1.

I created a (tempoarly) swap in sda15, and i reinstall grub. Grub work fine.


But when i boot in the new partition, kernel start and when it try to mount new / mount give me an error 6
According to man pages :
2 system error (out of memory, cannot fork, no more loop devices)
4 internal mount bug or missing nfs support in mount

Few lines after kernel panic....

my new fstab :
Code:
# This file is edited by fstab-sync - see 'man fstab-sync' for details
/dev/hda1 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
/dev/sda15 swap                    swap    defaults        0 0
Any idea of the problem ?


Thanks in advance,
 
Old 08-11-2005, 09:27 AM   #9
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151

Rep: Reputation: 46
It’s probably something simple.

It would be helpful to see your grub.conf and the output of “fdisk -l”. Also, run “e2fsck -f /dev/hda1" just to check the new partition/filesystem.
 
Old 08-11-2005, 12:30 PM   #10
guideweb
Member
 
Registered: Mar 2004
Location: /planet/earth
Posts: 110

Original Poster
Rep: Reputation: 15
[root@sam ~]# fdisk -l
Code:
Disk /dev/hda: 40.0 GB, 40025947648 bytes
255 heads, 63 sectors/track, 4866 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1        3569    28667961   83  Linux
/dev/hda2            3570        3582      104422+  83  Linux
/dev/hda3   *        3583        4866    10313730   8e  Linux LVM

Disk /dev/sda: 300.0 GB, 300090728448 bytes
255 heads, 63 sectors/track, 36483 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           2       36483   293041665    f  W95 Ext'd (LBA)
/dev/sda2               1           1        8001   83  Linux
/dev/sda5               2        2551    20482843+   b  W95 FAT32
/dev/sda6            2552        3188     5116671    7  HPFS/NTFS
/dev/sda7            3189        4080     7164958+   b  W95 FAT32
/dev/sda8            4081        5865    14337981    b  W95 FAT32
/dev/sda9            5866        7140    10241406    7  HPFS/NTFS
/dev/sda10           7141        8415    10241406    7  HPFS/NTFS
/dev/sda11           8416       11000    20763981   83  Linux
/dev/sda12          11001       12275    10241406    7  HPFS/NTFS
/dev/sda13          12276       12884     4891761   83  Linux
/dev/sda14          12885       14709    14659281   83  Linux
/dev/sda15          14710       15400     5550426   82  Linux swap

Partition table entries are not in disk order
[root@sam ~]# cat /boot/grub/grub.conf
Code:
 # grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,1)
#          kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
#          initrd /initrd-version.img
#boot=/dev/hda
default=
timeout=6
splashimage=(hd0,1)/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.12-1.1372_FC3)
        root (hd0,1)
        kernel /vmlinuz-2.6.12-1.1372_FC3 ro root=/dev/VolGroup00/LogVol00
        initrd /initrd-2.6.12-1.1372_FC3.img
title Fedora Core (2.6.9-1.667)
        root (hd0,1)
        kernel /vmlinuz-2.6.9-1.667 ro root=/dev/VolGroup00/LogVol00
        initrd /initrd-2.6.9-1.667.img
title Other
        rootnoverify (hd1,13)
        chainloader +1

title Fedora Core (2.6.9-1.667) COPY
        root (hd0,1)
        kernel /vmlinuz-2.6.9-1.667 ro root=/dev/hda0
        initrd /initrd-2.6.9-1.667.img
[root@sam ~]# e2fsck -fy /dev/hda1
Code:
  Unattached inode 4068
Connect to /lost+found? yes

Inode 4068 ref count is 2, should be 1.  Fix? yes
[[.....]]
Free inodes count wrong for group #60 (16192, counted=16168).
Fix? yes
[[.....]]
and many others errors ....
I run e2fsck one more time
Code:
Pass 1B: Rescan for duplicate/bad blocks
Duplicate/bad block(s) in inode 7: 4 5 6 11 12 14 16  [[.....]]

File /lost+found/#984595 (inode #984595, mod time Tue Mar  8 08:00:27 2005)
  has 509 duplicate block(s), shared with 1 file(s):
        <The group descriptor inode> (inode #7, mod time Thu Aug 11 13:25:37 2005)
Thanks for your input,

Last edited by guideweb; 08-11-2005 at 12:34 PM.
 
Old 08-11-2005, 03:16 PM   #11
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151

Rep: Reputation: 46
There is an error in the the FC “Copy” grub.conf entry. It should be /dev/hda1, not /dev/hda0.

grub.conf:
...
title Fedora Core (2.6.9-1.667) COPY
root (hd0,1)
kernel /vmlinuz-2.6.9-1.667 ro root=/dev/hda1
initrd /initrd-2.6.9-1.667.img
 
Old 08-11-2005, 09:07 PM   #12
guideweb
Member
 
Registered: Mar 2004
Location: /planet/earth
Posts: 110

Original Poster
Rep: Reputation: 15
Thanks a lot, evryrthing work fine
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
move mbr to different hard disk taiwf Linux - Hardware 4 08-11-2005 09:58 PM
Optical Disk Drive: no risk of damage when on the move? hanzj Linux - Laptop and Netbook 3 03-23-2005 12:57 AM
move files to new disk bosewicht Linux - Newbie 1 06-09-2004 12:51 AM
Beginning Programming, What Language To Use For Linux sovietpower Programming 21 02-11-2004 09:44 PM
Move hard disk with OS te_conway Linux - General 1 03-12-2002 09:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

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