Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
While installing Ubuntu I have created 50MB boot partition and was sure is enogugh, but now with growing initrd and kernel size, an autoupdates which were always killed by no sufficient disk space I decided to increase its size.
I had following partitions - in disk order:
sda1,primary bootable NTFS, 57GB
sda4, primary ext2, /boot, 47MB
extended sda2{
sda6, ext3, /(root), 43GB
8MB gap
4GB swap
sda7, ext3 /data, 62GB
sda8, ext3 /multimedia 87GB
sda5,ntfs, 30GB Lenovo recovery
}
1,16MB unallocated
sda3, primary NTFS, 15GB data
I tried to decrease size of sda6 with moving to the right to make more space for sda4 - boot. While doing this I unticked option Round to cylinders, and filled also the gap(about 8mb) between sda6 and swap. That was probably the source of all problems.
Gparted have done all steps, and while rereadig partition table gave error it's broken and displayed 300GB unallocated space. Although fdisk -l /dev/sda still showed the partitions.
I've made backup of first 2kB in disk with dd, run fdisk /dev/sda, and w. After that partitions appeared again in gparted, but sda6 came with warning sign.
I scanned disk with testdisk, it detects partitions and has option to show filenames for guessed partition position - although for boot it seems to be ok:
So all metadata broken although filenames are ok.
Is the problem still in bad begining of the partition saved or data are already broken ? If the first is there any mount option to really not touch filesystem ? Because I've read even if we mount readonly there are some options saved to disk (as last mount time etc) and I'm aware it could destroy entrie filesystem.
Has the ext3 some partition header as NTFS do? Or is there a way to locate real start of partition? because testdisk and gdisk shows only this one starting sector for sda6. When I moved the sda6 partition there was space between begin of extended partition and begin of sda6, now there is no space, so that's the main reason of suspecting partition begining is in fact over 100MB further.
Current partition schema in attached PNG. Also the swap partition was deleted, I don't know when, now there is 4GB hole.
I think I ran into this. I hit trouble doing a resize, and found once I screwed things up that there was a bug somewhere in the way gparted calls ntfsresize, and that the maintainer of each was looking at the other.
ntfsresize resizes the ntfs filesystem, not the drive partition. Get out of gparted, and think. Back up. What I would like to do is resize sda5 back to what it was, run a check on it, and then resize it down by calling ntfsresize from a console. If you delete sda5, all the partition numbers above drop by 1 and your new sda5 will be sda8 or sda9. The space on the smaller ntfs partitions is very tight; I wouldn't fill any drive over 90%
The problem is I don't know excatly to what size, from which sector and to which sector I resized. I need somehow locate old partition, tried testdisk and gpart, both detecting partition at old position - partition was moved to right to both are seeing begining of old already copied but still correct partition treating it as right one. And problem is with ext3 partition not ntfs
To be honest I don't know what the fuss is all about.
If you resize a partition the programs that pick up the partition files by the hard disk address must be accordingly readjusted. That is not broken if the changes are repairable.
The primary partition of sda1 to sda4 can never mixed with the logical partitions and if you don't know about it then it time to appreciate what partitioning is all about.
Your partition table tells us you have created sda1 first and then elected to create some logical partitions afterward, resulting the original primary sda2 become an extended partition holding sda5 to sda8. Think you are trying to create two more primaries sda3 and sda4 at the end of sda2 or more precisely at the end of sda8. If you read the output of fdisk -l you will find sda3 is physically behind sda8. The small 4Mb sda4 could have been created probably by you last by seizing whatever little space between sda1 and sda2.
Logical partition must work as a continuous chain with no space in between. If there are spaces they are dead and can only be absorbed by the adjoining partitions at either side.
MS systems do not format a partition at exactly the boundary of each cylinder as Linux does so you will have to accept some wastes which can be overcome if you use Linux to format the NTFS partition instead using a MS Windows. However MS Windows are gunning for the 4kB sector hard disks so they "align" the partition boundaries for this new technology. It is recommended that you leave it alone.
If you need the logical partitions realigned as ascending order like sda5 to sda8 use fdisk. It might call the same sda6, sda7 sda8 and sda5 as sda5, sda6,sda7 and sda8.
If you want the 4GB block absorbed into sda6 then continue the use of gParted.
If you want the 4GB block to become a new logical partition try cfdisk but the new partitions will sda7 with sda8 being pushed to become sda9.
The general rule is if cfdisk and gparted can read the partition table then it is healthy and can be understood by any Linux or MS system. Your real problem starts when both of these two programs can't understand the partition table and refuse to mount it. Then your last resort lies with fdisk.
Your problem is likely due to the inexperience of working with partitions. Using a GUI tool like gparted can be a disadvantage simply because the partition creation and file formatting are done together. A lot can be learned if you use the terminal tool like cfdisk where it shows the history of how each partition happens. More importantly the terminal partitioning tools never format a partition and so everything is reversible.
You probably don't see the problem, AFAIK there could be 4 primary partitions and any of them could be substituted with block with multi logical partitions and this coresponds to my setup
1. Primary sda1
2. Primary sda4
3. Logical(sda6-8)
4. Primary sda3
I setup it like this about 2 years ago and it worked like a charm, today I only resized one of partitions sda6 - with move to the right
About continuing and trying anythink with gparted, I don't want to use it, becase it run fsck automatically
My disk looks like that:
[x][yyyyyyyyyyyyyyyyyyy]
where x contains data from sda6 about what i moved partition to the right, and yyy contains the whole partition. If now in partition table the begining of sda6 is writen to point to x then if fsck of any tool read from it could e.g treat as journal data which aren't what it wants journal and basing on those data destroy rest of trying repair it.
About cfdisk I tried it also but it shows:
Code:
FATAL ERROR: Bad primary partition 2: Partition ends in the final partial cylinder
Press any key to exit cfdisk
I've just explored gdisk sources and this reminded me disk have its UUID, so I mounted /boot partition and saved UUID from grub menu.lst, after that done hexedit /dev/sda and searched fro begining of this string, and found one occurence near the begining and another one offseted exactly by 0x5000000h , so begining of real partition is probably by that position.
Here is testdisk backup file of current partition table:
Code:
ubuntu@ubuntu:/mnt$ cat backup.log
#1278278297 Disk /dev/sda - 320 GB / 298 GiB - CHS 38913 255 63
1 : start= 63, size=120005487, Id=07, *
4 : start=120005550, size= 96390, Id=83, P
2 : start=120101940, size=474094215, Id=0F, E
6 : start=120102066, size= 91361281, Id=83, L
7 : start=220010238, size=129997917, Id=83, L
8 : start=350008218, size=182980287, Id=83, L
5 : start=532988568, size= 61207587, Id=07, L
3 : start=594198528, size= 30943920, Id=12, P
How should I recalculate those values to offset begining of 6 by 5000000h - 80MB. Do I need to multiple it by sector size ? If so from where should I obtain it?
According to gparted your sda6 is 43.56Gb large and is empty? There should be nothing to fsck for.
I myself will treat the error warning from cfdisk as the first sign of problem in the partition table. Fdisk is usually the last one willing to work on a hard disk with a doggy partition table so keep a record of it if you need to rebuild the partition table.
I would not bother too much of the UUID references as I drop them as soon as they me any trouble. Linux boots and runs perfectly without them, even with the gpt partitions. People who do not know the disk order and the device names may think UUID is the best thing since slice bread.
root@ubuntu:~# LANG="en" fdisk -l /dev/sda
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc3ffc3ff
Device Boot Start End Blocks Id System
/dev/sda1 * 1 7470 60002743+ 7 HPFS/NTFS
/dev/sda2 7477 36987 237047107+ f W95 Ext'd (LBA)
/dev/sda3 36988 38914 15471960 12 Compaq diagnostics
/dev/sda4 7471 7476 48195 83 Linux
/dev/sda5 33178 36987 30603793+ 7 HPFS/NTFS
/dev/sda6 7477 13163 45680640+ 83 Linux
/dev/sda7 13696 21787 64998958+ 83 Linux
/dev/sda8 21788 33177 91490143+ 83 Linux
Partition table entries are not in disk order
root@ubuntu:~# LANG="en" fdisk -l -u /dev/sda
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 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: 0xc3ffc3ff
Device Boot Start End Blocks Id System
/dev/sda1 * 63 120005549 60002743+ 7 HPFS/NTFS
/dev/sda2 120101940 594196154 237047107+ f W95 Ext'd (LBA)
/dev/sda3 594198528 625142447 15471960 12 Compaq diagnostics
/dev/sda4 120005550 120101939 48195 83 Linux
/dev/sda5 532988568 594196154 30603793+ 7 HPFS/NTFS
/dev/sda6 120102066 211463346 45680640+ 83 Linux
/dev/sda7 220010238 350008154 64998958+ 83 Linux
/dev/sda8 350008218 532988504 91490143+ 83 Linux
Partition table entries are not in disk order
root@ubuntu:~#
I've backed up 2MB of sda6 to pendrive and wiped those 2MB on disk, than give testdisk another chance, it detected 6 partitions but neither the current sda6 nor that which boot block I found by UUID..
I don't think Linux would have an issue with your partition table looking like
Code:
Device Boot Start End Blocks Id System
/dev/sda1 * 1 7470 60002743+ 7 HPFS/NTFS
/dev/sda2 7477 36987 237047107+ f W95 Ext'd (LBA)
/dev/sda3 36988 38914 15471960 12 Compaq diagnostics
/dev/sda4 7471 7476 48195 83 Linux
/dev/sda5 33178 36987 30603793+ 7 HPFS/NTFS
/dev/sda6 7477 13163 45680640+ 83 Linux
/dev/sda7 13696 21787 64998958+ 83 Linux
/dev/sda8 21788 33177 91490143+ 83 Linux
Like I predicted the sda3 is at the back of the extended partition sda2 according to the starting and ending cylinder. Your sda4 is pretty useless for its size and you do get sda5 following sda8. This is likely due to using several partitioning tools. It pays to stick with one partitioning tool. In the past I use cfdisk a lot but fdisk (use Mb is unit) is good as it default unit is per cylinder which is a lot easier to follow and record.
Thus I still do not know your real concern if sda6 is empty and you are worrying about moving it to the right will do something to your data which is nil?
You can resize the sda6 to take up the small space. There is no law requiring a logical partition must be moved bodily as one unit every time! If you move a filing system everything then has to be re-constructed because your filing index will have to change completely for the new hard disk location.
Like I predicted the sda3 is at the back of the extended partition sda2 according to the starting and ending cylinder. Your sda4 is pretty useless for its size and you do get sda5 following sda8. This is likely due to using several partitioning tools.
You could see all those informations in first post.
Quote:
Thus I still do not know your real concern if sda6 is empty and you are worrying about moving it to the right will do something to your data which is nil?
You can resize the sda6 to take up the small space. There is no law requiring a logical partition must be moved bodily as one unit every time! If you move a filing system everything then has to be re-constructed because your filing index will have to change completely for the new hard disk location.
That's exactly my problem - gparted moved data from sda6 - moved those data exactly by 5000000h bytes to the right, now I need to know ho to calculate starting and ending sector, CHS form or any form that could be entered to any partitioning tool. And take in mind that partition was moved without "round to cylinders" option selected.
OK. Finally I divided 5000000h=(80*1024*1024)d over 512(sector size) what gave me offset 163840 and position 7486C 52H 41S ,after I entered those values to test disk it has shown my data uncorrupted, so I've done:
Code:
fdisk -c /dev/sda
u change display/entry units
x extra functionality (experts only)
b move beginning of data in a partition
than enteret calculated new size old+163840 and gparted started to see the partition and % of disk space usage. But now I must correct end of partition, both parted and gparted complains about filesystem greater than partition size but any of them can't fix the error in fdisk there is only option to move beginning of partition, not the end. And I'm not sure if I should offset also by 80MB because I setup it in gparted in way new partition should fill also the gap after - about 8MB, and don't know where the filesystem ends at the moment..
The reason I entered this thread with a critical tone was in the first post you quoted
Quote:
I tried to decrease size of sda6 with moving to the right to make more space for sda4
my reply was deliberately brunt (with the intention of making you think hard. It is designed for your own good)
Quote:
The primary partition of sda1 to sda4 can never mixed with the logical partitions and if you don't know about it then it time to appreciate what partitioning is all about.
I am also puzzled by the LBA mode being used in fdisk and yet you are insisting in knowing the exact boundary of sda6. When you format a partition Linux uses up the full boundary and there is no need to specify a different start and end positions, unless you want troubles.
From your partition table
Code:
Device Boot Start End Blocks Id System
/dev/sda1 * 1 7470 60002743+ 7 HPFS/NTFS
/dev/sda2 7477 36987 237047107+ f W95 Ext'd (LBA)
/dev/sda3 36988 38914 15471960 12 Compaq diagnostics
/dev/sda4 7471 7476 48195 83 Linux
/dev/sda5 33178 36987 30603793+ 7 HPFS/NTFS
/dev/sda6 7477 13163 45680640+ 83 Linux
/dev/sda7 13696 21787 64998958+ 83 Linux
/dev/sda8 21788 33177 91490143+ 83 Linux
Your sda6 commences at 7477th cylinder which is perfectly matching the starting cylinder of the extended partition. sda6 ends at the 13163th cylinder while your sda7 kicks off at the 13696th cylinder. Thus there is a gap of 13696-13163=533 cylinders of dead space. As one cylinder in your hard disk has 255 head and 63 sectors and each sector has 512 bytes therefore the dead space is 533x255x63x512=4,384,074,240 bytes or 4.384 GB or 4.083 GiB (divided 3 times by 1024)matching exactly what has been reported in gparted.
If you resize sda6 you simply drag its boundary to the right tight against sda7 and you should find the end cylinder changed to 13698th cylinder. There is no need to fiddle with ending sector because the smallest unit in fdisk is one cylinder as I mentioned earlier.
If you resize sda6 you simply drag its boundary to the right tight against sda7 and you should find the end cylinder changed to 13698th cylinder. There is no need to fiddle with ending sector because the smallest unit in fdisk is one cylinder as I mentioned earlier.
Maybe it's all about versions of software in fdisk you may use c and u options and smallest unit is sector. I tried to resize partition with parted but it again bugged about unsupported partition flags set what means it read boot block from where it should't, I bet from begining of cylinder not exact CHS position.
Gparted can't work because it run fsck before any operation and in current partition setup it shows:
Code:
root@ubuntu:/media# LANG="en" /dev/sda6
-su: /dev/sda6: Permission denied
root@ubuntu:/media# LANG="en" fsck /dev/sda6
fsck from util-linux-ng 2.17.2
e2fsck 1.41.11 (14-Mar-2010)
The filesystem size (according to the superblock) is 11420160 blocks
The physical size of the device is 11399680 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort<y>? yes
root@ubuntu:/media# expr 11420160 - 11399680
20480
So I have current end of sda6 - 211463346, have the offset 20480 so all I need is to substitute 211463346 by 211627186 but couldn't found a tool which do this without any additional actions..
I agree that in fdisk one can go into CHS details but I am not sure if it is wise to start and end a partition smaller than a cylinder.
If you have a problem of resizing sda6 it is possible that you are mounting it for use. If you download gparted or Parted Magic and run it as a Live CD you should find the behaviour a bit different.
I agree that in fdisk one can go into CHS details but I am not sure if it is wise to start and end a partition smaller than a cylinder.
Where I said that ? I have partition which starts and ends in the middle of cylinder but not the same cylinder. My data already are in such setup. I need to make partition table match ALREADY moved data. If my data will be again accessible I could do anything with aligning to cylinders etc with any tool.
Quote:
If you have a problem of resizing sda6 it is possible that you are mounting it for use. If you download gparted or Parted Magic and run it as a Live CD you should find the behaviour a bit different.
I'm on live cd all the time and the only mounted physical device is my pendrive.
According to the info provided your hard disk has two empty areas; one after sda6 and the other after sda5.
The sda6 is empty so there is no data inside.
The sda5 is at the end of the extended partition sda2 which currently being complained by cfdisk which refuses to mount it citing sda2 has the end straddling a partial cylinder.
gparted and fdisk both report the disk is healthy.
I have mentioned MS Windows can format a NTFS partition leaving space either at the beginning or the end unless the formatting is pre-executed in Linux, say using "mkfs.ntfs".
I have run disks with empty spaces for years and never had an issue but cfdisk did refuse to mount it saying something similar. I had also Solaris and BSD systems that like to start their partition at a partial cylinder too.
Unless the operating system is having difficulty in assessing the partition the untidiness in the partition table isn't a broken hard disk to me. If you want to get rid of this untidiness in future use one Linux tool for partitioning and do all the formatting in Linux too.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.