Linux NTFS: Difference between revisions
Line 75: | Line 75: | ||
sudo ntfsresize --no-action --size 20000M /dev/loop0 # Testing |
sudo ntfsresize --no-action --size 20000M /dev/loop0 # Testing |
||
sudo ntfsresize --size 20000M /dev/loop0 |
sudo ntfsresize --size 20000M /dev/loop0 |
||
sudo truncate --size=20000M backup.img # For more safety, takes actual size of volume + cluster size |
|||
sudo losetup -c /dev/loop0 # Sync loop device with new file size |
|||
sudo ntfsclone --save-image -o - /dev/loop0 | gzip -c > backup-resized.img.gz |
sudo ntfsclone --save-image -o - /dev/loop0 | gzip -c > backup-resized.img.gz |
||
sudo losetup -d /dev/loop0 |
sudo losetup -d /dev/loop0 |
||
</source> |
</source> |
||
When truncating the file, check first the actual volume size (by calling ntfsclone), and use that size (that should be rounded to cluster size) plus another cluster size. |
Revision as of 00:14, 26 March 2010
This page is part of the Linux Disk Management pages.
Mounting
References
- https://help.ubuntu.com/community/MountingWindowsPartitions/ThirdPartyNTFS3G
- http://ubuntuforums.org/archive/index.php/t-1072025.html
Mounting an NTFS partition using file /etc/fstab
- First get the UUID of the partition to mount
sudo blkid
- Edit /etc/fstab accordingly:
UUID=XXXXXXXXXXXXXXXXXXXXX /media/windows ntfs defaults,umask=007,gid=46 0 1
- Note that gid=46 refers to plugdev group.
- Now the partition can be mounted with:
sudo mount /media/windows
Mounting a NTFS partition using command mount
- To mount an NTFS partition /dev/sda1 to mount point /media/windows:
sudo mkdir /media/windows
sudo chgrp plugdev /media/windows
sudo mount -t ntfs -o defaults,umask=007,gid=46 /dev/sda1 /media/windows
NTFSResize
Change the size of an existing NTFS partition
$ fdisk -l /dev/sda # List information on partitions on /dev/sda
$ ntfsresize --info /dev/sda1
$ ntfsresize --no-action --size 20152M /dev/sda1 # Testing
$ ntfsresize --no-action --size 20151M /dev/sda1 # Testing
$ ntfsresize --size 20151M /dev/sda1
$ ntfsresize --size 20000M /dev/sda1
NTFSClone
Backup an NTFS partition - Backup an NTFS partition to an image file
sudo ntfsclone --save-image -o - /dev/sda1 | gzip -c > backup-20090908.img.gz
Restore an NTFS partition - Restore an NTFS partition from an image file
gzip -d -c backup-20090908.img.gz | sudo ntfsclone --restore-image --overwrite /dev/sda1 -
Mount an NTFSClone image - Convert an image file to a file, and mount it
gzip -d -c backup-20090908.img.gz | sudo ntfsclone --restore-image --overwrite backup.img -
mount -t ntfs -o loop backup.ntfs /mnt/ntfsclone
! bug ! If you get an error Failed to read last sector (...): Invalid argument, it is probably because the size of the image volume created by ntfsclone does not match the Image device size (the last cluster is incomplete). To fix this bug, simply pad the file with zeroes as necessary. Let's assume the following output for ntfsclone:
... Cluster size : 4096 bytes Image volume size : 48057282560 bytes (48058 MB) Image device size : 48057286656 bytes ...
However the file generated by ntfsclone is smaller than the original device size:
-rw------- 1 root root 48057283072 2010-03-26 00:07 e6500.ntfs
We see that 3584 bytes are missing. Simply pad the file:
dd if=/dev/zero bs=3584 count=1 >> e6500ntfs
mount -t ntfs -o loop backup.ntfs /mnt/ntfsclone
Resizing an NTFSClone image - ntfsclone will fail if the original device size is bigger than the destination partition. To fix this, first resize the ntfsclone image by using a loop devices.
gzip -d -c backup.img.gz | sudo ntfsclone --restore-image --overwrite backup.img -
sudo losetup /dev/loop0 backup.img
sudo ntfsresize --no-action --size 20000M /dev/loop0 # Testing
sudo ntfsresize --size 20000M /dev/loop0
sudo truncate --size=20000M backup.img # For more safety, takes actual size of volume + cluster size
sudo losetup -c /dev/loop0 # Sync loop device with new file size
sudo ntfsclone --save-image -o - /dev/loop0 | gzip -c > backup-resized.img.gz
sudo losetup -d /dev/loop0
When truncating the file, check first the actual volume size (by calling ntfsclone), and use that size (that should be rounded to cluster size) plus another cluster size.