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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Thank's irmin, I tried ntfsresize before, but don't work with an entire disk image...
Code:
$ /media/DISK/$ ntfsresize -i sapbes.img
ntfsresize v2.0.0 (libntfs 10:0:0) Failed to startup volume: Invalid argument.
ERROR(22): Opening 'sapbes.img' as NTFS failed: Invalid argument The device 'sapbes.img' doesn't have a valid NTFS.
Maybe you selected the wrong partition? Or the whole disk instead of a partition (e.g. /dev/hda, not /dev/hda1)? This error might also occur if the disk was incorrectly repartitioned (see the ntfsresize FAQ).
Do you have another idea?
For now, I'm creating a new image, only with one partition...
Partitioning
When recreating the partition by a disk partitioning tool, make sure
you create it at the same starting sector and with the same partition
type as before. Otherwise you won't be able to access your filesystem.
Use the 'u' fdisk command to switch to the reliable sector unit from
the default cylinder one.
Also make sure you set the bootable flag for the partition if it
existed before. Failing to do so you might not be able to boot your
computer from the disk.
You cannot apply ntfsresize to a whole harddisk, but only to partitions. So you took the right steps ...
Once you have mounted the "partition" (it is really a file, but now you can treat it as a disk), you can then just copy the files to the new disk's formatted partition.
Don't forget to ummount everything before you start unplugging things.
$ ntfsresize -s 28G sapbes.img
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : sapbes.img
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 73394139648 bytes (73395 MB)
Current device size: 73394141184 bytes (73395 MB)
New volume size : 27999994368 bytes (28000 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use : 17519 MB (23.9%)
Collecting resizing constraints ...
Needed relocations : 1206303 (4942 MB)
WARNING: Every sanity check passed and only the dangerous operations left.
Make sure that important data has been backed up! Power outage or computer
crash may result major data loss!
Are you sure you want to proceed (y/[n])? y
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Relocating needed data ...
100.00 percent completed
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
Syncing device ...
Successfully resized NTFS on device 'sapbes.img'.
You can go on to shrink the device for example with Linux fdisk.
IMPORTANT: When recreating the partition, make sure that you
1) create it at the same disk sector (use sector as the unit!)
2) create it with the same partition type (usually 7, HPFS/NTFS)
3) do not make it smaller than the new NTFS filesystem size
4) set the bootable flag for the partition if it existed before
Otherwise you won't be able to access NTFS or can't boot from the disk!
If you make a mistake and don't have a partition table backup then you
can recover the partition table by TestDisk or Parted's rescue mode.
But the file size it's the same... (69GB instead of 28GB)
$ dd if=./mbr.img of=/dev/sda
0+1 records in
0+1 records out
512 bytes (512 B) copied, 0,0250117 s, 17,8 kB/s
$ dd if=./sapbes.img of=/dev/sda1
...
32 GB Copied. No space left on device
...
But the file size it's the same... (69GB instead of 28GB)
You have resized the filesystem (to the beginning of the partition) but the partition size is the same.
So there is empty space after the filesystem on that partition.
From man ntfsresize
Code:
Shrinkage
If you wish to shrink an NTFS partition, first use ntfsresize to shrink
the size of the filesystem. Then you could use fdisk(8) to shrink the
size of the partition by deleting the partition and recreating it with
the smaller size. Do not make the partition smaller than the new size
of NTFS otherwise you won’t be able to boot. If you did so notwith‐
standing then just recreate the partition to be as large as NTFS.
So you need to unmount your loop-mounted partition, and then use fdisk to repartition it to
a size that will hold your resized filesystem.
Easier, I think, is just to copy the files to a new filesystem on a partition of the right size on the disk
of your choice.
Ok, I tried to copy the files to a new system with the same result
I think it's a problem with the Windows 2003 and the disk controller drivers.
Now I try to explain why I'm doing this ...
We had an old server with Windows 2003. This server had a hard disk that began to fail and we cannot copy in any way (Veritas BackupExec, ntbackup, ...). To demostrate the versatility of Linux to my work colleagues I wanted to pass the old system of this machine to a host within a VMware ESX Server using Ubuntu LiveCD, but as you saw, does not boot. I think the installation of windows can not support this beasty hardware change (from an old Asus server to a VM ESX virtual host).
Tomorrow I try to restore it in another (phisical) machine with a similar hard as the initial I can.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.