LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 06-17-2015, 10:27 PM   #1
roy.wong
LQ Newbie
 
Registered: Jun 2015
Posts: 3

Rep: Reputation: Disabled
After replace a larger HDD, CentOS cannot use the free space


Dears,

I had replace a larger HDD from 320GB to 500GB for my CentOS 6.4 x64

After replace, i want to extend sda2 to 80GB because it's already full. But when i use parted to create new partition, it have the below error, it still only can use 320GB.

May i know any step i goes wrong? Many Thanks!


(parted) print
Model: ATA WDC WD5000AAKX-0 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 1049kB 1075MB 1074MB primary ext4 boot
2 1075MB 22.5GB 21.5GB primary ext4
3 22.5GB 26.8GB 4295MB primary linux-swap(v1)
4 26.8GB 320GB 293GB extended
5 26.8GB 320GB 293GB logical ext4

(parted) mkpart
Partition type? [logical]? primery
parted: invalid token: primery
Partition type? [logical]? extended
parted: invalid token: extended
Partition type? [logical]?
File system type? [ext2]? ext4
Start? 320GB
End? 380GB
Warning: You requested a partition from 320GB to 380GB.
The closest location we can manage is 320GB to 320GB.
Is this still acceptable to you?
Yes/No? n
 
Old 06-18-2015, 09:52 AM   #2
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
How did you replace the hard drive?

What method did you use to restore the disk and data?
 
Old 06-18-2015, 10:05 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Welcome to LinuxQuestions.

To create additional partitions you have to increase the size of the extended partition i.e sda4. However, to increase the size of sda2 you need to move the sda3 and sda4 (which contains sda5) to the right.

Make sure you backup all important data and I assume that sda2 is your / so running gparted from a live CD or USB is required.
 
Old 06-18-2015, 10:59 AM   #4
gentisle
Member
 
Registered: May 2005
Location: Wisconsin, USA
Distribution: LinuxMint, OpenBSD
Posts: 263

Rep: Reputation: 9
What lazydog said. Plus this.

I've not used CentOS, but I doubt that is a problem here. When I want to move an OS to a different HDD, I will:
1. boot SystemRescueCD and use Gparted to get the sizes/types (as in how they are formatted) of the partitions. Though fdisk will give you a more accurate number. This is also for safety in case nothing works, at least you can bring it back to what you had. Hopefully, but no guarentees.
2. After writing down all these exact numbers, I can set the other HDD up with the new partition info.
3. Again, for safety, I make a back of the MBR w/
Code:
dd if=/dev/sda of=/dev/SomeUSBstick/mymbr.mbr bs=512 count=1
4. Now you can partition/format the "new" HDD with the new sizes you need.
5. Then I use partimage to backup the original partition(s) to a 3rd HDD or an extra partition on one of the 2 HDDs you have (wherever you have space available).
6. And finally, you use partimage to restore from wherever you backed up to, to the "new" partitions. Note that you need to start partimage w/the parameter that causes it to not store the MBR. I'm in Windows now, so I don't remember, but the man page will tell you. When I say you need to start it w/that parameter, I mean on backup and restore.
 
Old 06-18-2015, 07:07 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,980

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
I'd boot to a live something and use gparted instead. You might see why it can't do what you want.
 
Old 06-18-2015, 11:46 PM   #6
roy.wong
LQ Newbie
 
Registered: Jun 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks All.

I use dd to copy data from 320GB HDD to 500GB HDD. May i know the dd command which can increase the partition size to the new HDD?

Thanks!
 
Old 06-19-2015, 11:13 AM   #7
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
What was the exact command you used to copy your data?
 
Old 06-19-2015, 02:54 PM   #8
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,487

Rep: Reputation: Disabled
You have 'imaged' an exact copy of your 320GB drive onto your 500GB drive.
You may be able to use fdisk to create a partition in the extra space.
 
Old 06-21-2015, 08:49 PM   #9
roy.wong
LQ Newbie
 
Registered: Jun 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
i use "dd if=/dev/sda of=/dev/sdb bs=100M conv=notrunc"
 
Old 06-21-2015, 10:06 PM   #10
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by roy.wong View Post
May i know the dd command which can increase the partition size to the new HDD?
dd can't do that.

As suggested get a gparted liveCD and use that to move the partitions around - it has a GUI visualisation of the disk that is quite good. You will have to move all the partitions sda[345] to create free space immediately adjacent to sda2 - then you can increase its size (also with gparted).
Not trivial, but easy enough if you are careful.
 
  


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
CentOS 6.3 HDD space used but can't find where Angelic_Mew Linux - General 5 02-12-2014 02:40 AM
HDD Free Space JJJCR Linux - General 2 12-09-2013 11:27 PM
cannot install DSL to free space on partitioned HDD. davehateMS Linux - Newbie 2 09-19-2007 11:05 AM
How can I know hdd free space ? jhome4u Linux - Software 2 03-05-2004 08:19 AM
Need to replace HDD with a larger drive gvi Linux - Hardware 7 01-20-2004 10:20 AM

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

All times are GMT -5. The time now is 12:31 AM.

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